Skip to content

Commit

Permalink
libspl: ASSERT*: +0 for sizeof
Browse files Browse the repository at this point in the history
sizeof(bitfield.member) is invalid, and this shows up in some FreeBSD
build configurations: work around this by +0ing ‒ this takes the size of
the arithmetic result type, instead

Fixes: 42aaf0e ("libspl: ASSERT*: mark arguments as used")
Closes: openzfs#12984
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
  • Loading branch information
nabijaczleweli committed Jan 19, 2022
1 parent e1c720d commit e6b3ea3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
16 changes: 8 additions & 8 deletions include/os/freebsd/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)+0))
#define ASSERT3B(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3S(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3U(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3P(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT0(x) ((void) sizeof ((x)+0))
#define IMPLY(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))
#define EQUIV(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))

/*
* Debugging enabled (--enable-debug)
Expand Down
16 changes: 8 additions & 8 deletions include/os/linux/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)+0))
#define ASSERT3B(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3S(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3U(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3P(x,y,z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT0(x) ((void) sizeof ((x)+0))
#define IMPLY(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))
#define EQUIV(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))

/*
* Debugging enabled (--enable-debug)
Expand Down
18 changes: 9 additions & 9 deletions lib/libspl/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)+0), (void) sizeof ((z)+0))
#define ASSERT3S(x, y, z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3U(x, y, z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT3P(x, y, z) ((void) sizeof ((x)+0), (void) sizeof ((z)+0))
#define ASSERT0(x) ((void) sizeof ((x)+0))
#define ASSERT(x) ((void) sizeof ((x)+0))
#define assert(x) ((void) sizeof ((x)+0))
#define IMPLY(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))
#define EQUIV(A, B) ((void) sizeof ((A)+0), (void) sizeof ((B)+0))
#else
#define ASSERT3B VERIFY3B
#define ASSERT3S VERIFY3S
Expand Down

0 comments on commit e6b3ea3

Please sign in to comment.