aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorнаб <[email protected]>2022-01-25 02:05:42 +0100
committerGitHub <[email protected]>2022-01-24 17:05:42 -0800
commita9e2788ffe8f45c190ad442dda2e83e719cfb14f (patch)
tree22a851583295bcbbc9bea28fb769fe22ad47564d /lib
parentcd26b217dcc136d025b845e61692bb34cf37552b (diff)
libspl: cast to uintptr_t instead of !!ing
This led to these two warning types: debug.h:139:67: warning: the address of ‘ARC_anon’ will always evaluate as ‘true’ [-Waddress] 139 | #define ASSERT3P(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) | ^ arc.c:1591:2: note: in expansion of macro ‘ASSERT3P’ 1591 | ASSERT3P(hdr->b_l1hdr.b_state, ==, arc_anon); | ^~~~~~~~ and arc.h:66:44: warning: ‘<<’ in boolean context, did you mean ‘<’? [-Wint-in-bool-context] 66 | #define HDR_GET_LSIZE(hdr) ((hdr)->b_lsize << SPA_MINBLOCKSHIFT) debug.h:138:46: note: in definition of macro ‘ASSERT3U’ 138 | #define ASSERT3U(x, y, z) ((void) sizeof (!!(x)), (void) sizeof (!!(z))) | ^ arc.c:1760:12: note: in expansion of macro ‘HDR_GET_LSIZE’ 1760 | ASSERT3U(HDR_GET_LSIZE(hdr), !=, 0); | ^~~~~~~~~~~~~ Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #13009
Diffstat (limited to 'lib')
-rw-r--r--lib/libspl/include/assert.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h
index fadff14cc..e129ef7df 100644
--- a/lib/libspl/include/assert.h
+++ b/lib/libspl/include/assert.h
@@ -120,15 +120,21 @@ 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 ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
+#define ASSERT3S(x, y, z) \
+ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
+#define ASSERT3U(x, y, z) \
+ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
+#define ASSERT3P(x, y, z) \
+ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
+#define ASSERT0(x) ((void) sizeof ((uintptr_t)(x)))
+#define ASSERT(x) ((void) sizeof ((uintptr_t)(x)))
+#define assert(x) ((void) sizeof ((uintptr_t)(x)))
+#define IMPLY(A, B) \
+ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
+#define EQUIV(A, B) \
+ ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
#else
#define ASSERT3B VERIFY3B
#define ASSERT3S VERIFY3S