glibc 2.25 compat: remove assert(X=Y)

The assert() related definitions in glibc 2.25 were altered to warn
about assert(X=Y) when -Wparentheses is used.  See
https://abi-laboratory.pro/tracker/changelog/glibc/2.25/log.html

lib/list.c used this construct to set the value of a magic field which
is defined only when debugging.

Replaced the assert()s with #ifndef/#endifs.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #610
This commit is contained in:
Olaf Faaland 2017-04-03 13:33:49 -07:00 committed by Brian Behlendorf
parent bf8abea4da
commit 481762f6a9

View File

@ -220,7 +220,9 @@ list_create (ListDelF f)
l->fDel = f; l->fDel = f;
l->count = 0; l->count = 0;
list_mutex_init(&l->mutex); list_mutex_init(&l->mutex);
assert(l->magic = LIST_MAGIC); /* set magic via assert abuse */ #ifndef NDEBUG
l->magic = LIST_MAGIC;
#endif
return(l); return(l);
} }
@ -238,7 +240,9 @@ list_destroy (List l)
while (i) { while (i) {
assert(i->magic == LIST_MAGIC); assert(i->magic == LIST_MAGIC);
iTmp = i->iNext; iTmp = i->iNext;
assert(i->magic = ~LIST_MAGIC); /* clear magic via assert abuse */ #ifndef NDEBUG
i->magic = ~LIST_MAGIC;
#endif /* !NDEBUG */
list_iterator_free(i); list_iterator_free(i);
i = iTmp; i = iTmp;
} }
@ -250,7 +254,9 @@ list_destroy (List l)
list_node_free(p); list_node_free(p);
p = pTmp; p = pTmp;
} }
assert(l->magic = ~LIST_MAGIC); /* clear magic via assert abuse */ #ifndef NDEBUG
l->magic = ~LIST_MAGIC;
#endif /* !NDEBUG */
list_mutex_unlock(&l->mutex); list_mutex_unlock(&l->mutex);
list_mutex_destroy(&l->mutex); list_mutex_destroy(&l->mutex);
list_free(l); list_free(l);
@ -520,7 +526,9 @@ list_iterator_create (List l)
i->prev = &l->head; i->prev = &l->head;
i->iNext = l->iNext; i->iNext = l->iNext;
l->iNext = i; l->iNext = i;
assert(i->magic = LIST_MAGIC); /* set magic via assert abuse */ #ifndef NDEBUG
i->magic = LIST_MAGIC;
#endif /* !NDEBUG */
list_mutex_unlock(&l->mutex); list_mutex_unlock(&l->mutex);
return(i); return(i);
} }
@ -557,7 +565,9 @@ list_iterator_destroy (ListIterator i)
} }
} }
list_mutex_unlock(&i->list->mutex); list_mutex_unlock(&i->list->mutex);
assert(i->magic = ~LIST_MAGIC); /* clear magic via assert abuse */ #ifndef NDEBUG
i->magic = ~LIST_MAGIC;
#endif /* !NDEBUG */
list_iterator_free(i); list_iterator_free(i);
return; return;
} }