From bc40713a8f2e78ce8b4bdef587d5233d313f06f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Fri, 21 Jan 2022 19:20:11 +0100 Subject: [PATCH] libspl: ASSERT*: !! for sizeof MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD build configurations: work around this by !!ing ‒ this makes the sizeof target the ! result type (_Bool), instead Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia Ziemiańska Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used") Closes #12984 Closes #12986 --- include/os/freebsd/spl/sys/debug.h | 16 ++++++++-------- include/os/linux/spl/sys/debug.h | 16 ++++++++-------- lib/libspl/include/assert.h | 18 +++++++++--------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index 6a0c2fe07..6df76db7e 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -133,14 +133,14 @@ void spl_dumpstack(void); */ #ifdef NDEBUG -#define ASSERT(x) ((void)sizeof(x)) -#define ASSERT3B(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3S(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3U(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3P(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT0(x) ((void)sizeof(x)) -#define IMPLY(A, B) ((void)sizeof(A), (void)sizeof(B)) -#define EQUIV(A, B) ((void)sizeof(A), (void)sizeof(B)) +#define ASSERT(x) ((void) sizeof (!!(x))) +#define ASSERT3B(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3S(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3U(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3P(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT0(x) ((void) sizeof (!!(x))) +#define IMPLY(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) +#define EQUIV(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) /* * Debugging enabled (--enable-debug) diff --git a/include/os/linux/spl/sys/debug.h b/include/os/linux/spl/sys/debug.h index e3cbf62d1..102fc640b 100644 --- a/include/os/linux/spl/sys/debug.h +++ b/include/os/linux/spl/sys/debug.h @@ -133,14 +133,14 @@ void spl_dumpstack(void); */ #ifdef NDEBUG -#define ASSERT(x) ((void)sizeof(x)) -#define ASSERT3B(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3S(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3U(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT3P(x,y,z) ((void)sizeof(x), (void)sizeof(z)) -#define ASSERT0(x) ((void)sizeof(x)) -#define IMPLY(A, B) ((void)sizeof(A), (void)sizeof(B)) -#define EQUIV(A, B) ((void)sizeof(A), (void)sizeof(B)) +#define ASSERT(x) ((void) sizeof (!!(x))) +#define ASSERT3B(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3S(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3U(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3P(x,y,z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT0(x) ((void) sizeof (!!(x))) +#define IMPLY(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) +#define EQUIV(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) /* * Debugging enabled (--enable-debug) diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 2a6e8a1e4..fadff14cc 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -120,15 +120,15 @@ do { \ __compile_time_assertion__ ## y[(x) ? 1 : -1] #ifdef NDEBUG -#define ASSERT3B(x, y, z) ((void) sizeof (x), (void) sizeof (z)) -#define ASSERT3S(x, y, z) ((void) sizeof (x), (void) sizeof (z)) -#define ASSERT3U(x, y, z) ((void) sizeof (x), (void) sizeof (z)) -#define ASSERT3P(x, y, z) ((void) sizeof (x), (void) sizeof (z)) -#define ASSERT0(x) ((void) sizeof (x)) -#define ASSERT(x) ((void) sizeof (x)) -#define assert(x) ((void) sizeof (x)) -#define IMPLY(A, B) ((void) sizeof (A), (void) sizeof (B)) -#define EQUIV(A, B) ((void) sizeof (A), (void) sizeof (B)) +#define ASSERT3B(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3S(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3U(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT3P(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) +#define ASSERT0(x) ((void) sizeof (!!(x))) +#define ASSERT(x) ((void) sizeof (!!(x))) +#define assert(x) ((void) sizeof (!!(x))) +#define IMPLY(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) +#define EQUIV(A, B) ((void) sizeof (!!(A)), (void) sizeof (!!(B))) #else #define ASSERT3B VERIFY3B #define ASSERT3S VERIFY3S