From 4866c2fabf6e657ba3bac7954e2ff04dee05d841 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Wed, 16 Apr 2025 12:01:32 -0400 Subject: [PATCH] Cleanup VERIFY() macros (#17163) - Fix VERIFY3B() when given non-boolean values. - Map EQUIV() into VERIFY3B(,==,) as equivalent. - Tune messages for better readability and to closer match source code for easier search. Unify user-space messages with kernel. - Tune printed types and remove %px outside of Linux kernel. Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Reviewed-by: @ImAwsumm Reviewed-by: Rob Norris Reviewed-by: Tony Hutter --- include/os/freebsd/spl/sys/debug.h | 71 ++++++++++++------------------ include/os/linux/spl/sys/debug.h | 67 ++++++++++++---------------- lib/libspl/include/assert.h | 65 +++++++++++++-------------- 3 files changed, 89 insertions(+), 114 deletions(-) diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index c1a7cfdec..974704e92 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -112,14 +112,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) } while (0) #define VERIFY3B(LEFT, OP, RIGHT) do { \ - const boolean_t _verify3_left = (boolean_t)(LEFT); \ - const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + const boolean_t _verify3_left = (boolean_t)!!(LEFT); \ + const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%d " #OP " %d)\n", \ - (boolean_t)_verify3_left, \ - (boolean_t)_verify3_right); \ + _verify3_left, _verify3_right); \ } while (0) #define VERIFY3S(LEFT, OP, RIGHT) do { \ @@ -127,7 +126,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify3_right = (int64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%lld " #OP " %lld)\n", \ (long long)_verify3_left, \ (long long)_verify3_right); \ @@ -138,7 +137,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uint64_t _verify3_right = (uint64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%llu " #OP " %llu)\n", \ (unsigned long long)_verify3_left, \ (unsigned long long)_verify3_right); \ @@ -149,8 +148,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ - "failed (%px " #OP " %px)\n", \ + "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \ + "failed (%p " #OP " %p)\n", \ (void *)_verify3_left, \ (void *)_verify3_right); \ } while (0) @@ -159,8 +158,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify0_right = (int64_t)(RIGHT); \ if (unlikely(!(0 == _verify0_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(" #RIGHT ") " \ - "failed (0 == %lld)\n", \ + "VERIFY0(" #RIGHT ") failed (%lld)\n", \ (long long)_verify0_right); \ } while (0) @@ -168,8 +166,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \ if (unlikely(!(0 == _verify0_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0P(" #RIGHT ") " \ - "failed (NULL == %px)\n", \ + "VERIFY0P(" #RIGHT ") failed (%p)\n", \ (void *)_verify0_right); \ } while (0) @@ -182,14 +179,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) */ #define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \ - const boolean_t _verify3_left = (boolean_t)(LEFT); \ - const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + const boolean_t _verify3_left = (boolean_t)!!(LEFT); \ + const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%d " #OP " %d) " STR "\n", \ - (boolean_t)(_verify3_left), \ - (boolean_t)(_verify3_right), \ + _verify3_left, _verify3_right, \ __VA_ARGS__); \ } while (0) @@ -198,10 +194,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify3_right = (int64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%lld " #OP " %lld) " STR "\n", \ - (long long)(_verify3_left), \ - (long long)(_verify3_right), \ + (long long)_verify3_left, (long long)_verify3_right,\ __VA_ARGS__); \ } while (0) @@ -210,10 +205,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uint64_t _verify3_right = (uint64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%llu " #OP " %llu) " STR "\n", \ - (unsigned long long)(_verify3_left), \ - (unsigned long long)(_verify3_right), \ + (unsigned long long)_verify3_left, \ + (unsigned long long)_verify3_right, \ __VA_ARGS__); \ } while (0) @@ -222,32 +217,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ - "failed (%px " #OP " %px) " STR "\n", \ - (void *) (_verify3_left), \ - (void *) (_verify3_right), \ + "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \ + "failed (%p " #OP " %p) " STR "\n", \ + (void *)_verify3_left, (void *)_verify3_right, \ __VA_ARGS__); \ } while (0) #define VERIFY0PF(RIGHT, STR, ...) do { \ - const uintptr_t _verify3_left = (uintptr_t)(0); \ const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ - if (unlikely(!(_verify3_left == _verify3_right))) \ + if (unlikely(!(0 == _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(0 == " #RIGHT ") " \ - "failed (0 == %px) " STR "\n", \ - (long long) (_verify3_right), \ + "VERIFY0P(" #RIGHT ") failed (%p) " STR "\n", \ + (void *)_verify3_right, \ __VA_ARGS__); \ } while (0) #define VERIFY0F(RIGHT, STR, ...) do { \ - const int64_t _verify3_left = (int64_t)(0); \ const int64_t _verify3_right = (int64_t)(RIGHT); \ - if (unlikely(!(_verify3_left == _verify3_right))) \ + if (unlikely(!(0 == _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(0 == " #RIGHT ") " \ - "failed (0 == %lld) " STR "\n", \ - (long long) (_verify3_right), \ + "VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \ + (long long)_verify3_right, \ __VA_ARGS__); \ } while (0) @@ -256,10 +246,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) spl_assert("(" #A ") implies (" #B ")", \ __FILE__, __FUNCTION__, __LINE__))) -#define VERIFY_EQUIV(A, B) \ - ((void)(likely(!!(A) == !!(B)) || \ - spl_assert("(" #A ") is equivalent to (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) +#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B) /* * Debugging disabled (--disable-debug) diff --git a/include/os/linux/spl/sys/debug.h b/include/os/linux/spl/sys/debug.h index 700cc85b6..1671ba407 100644 --- a/include/os/linux/spl/sys/debug.h +++ b/include/os/linux/spl/sys/debug.h @@ -116,14 +116,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) } while (0) #define VERIFY3B(LEFT, OP, RIGHT) do { \ - const boolean_t _verify3_left = (boolean_t)(LEFT); \ - const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + const boolean_t _verify3_left = (boolean_t)!!(LEFT); \ + const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%d " #OP " %d)\n", \ - (boolean_t)_verify3_left, \ - (boolean_t)_verify3_right); \ + _verify3_left, _verify3_right); \ } while (0) #define VERIFY3S(LEFT, OP, RIGHT) do { \ @@ -131,7 +130,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify3_right = (int64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%lld " #OP " %lld)\n", \ (long long)_verify3_left, \ (long long)_verify3_right); \ @@ -142,7 +141,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uint64_t _verify3_right = (uint64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%llu " #OP " %llu)\n", \ (unsigned long long)_verify3_left, \ (unsigned long long)_verify3_right); \ @@ -153,7 +152,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%px " #OP " %px)\n", \ (void *)_verify3_left, \ (void *)_verify3_right); \ @@ -163,8 +162,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify0_right = (int64_t)(RIGHT); \ if (unlikely(!(0 == _verify0_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(" #RIGHT ") " \ - "failed (0 == %lld)\n", \ + "VERIFY0(" #RIGHT ") failed (%lld)\n", \ (long long)_verify0_right); \ } while (0) @@ -172,8 +170,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \ if (unlikely(!(0 == _verify0_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0P(" #RIGHT ") " \ - "failed (NULL == %px)\n", \ + "VERIFY0P(" #RIGHT ") failed (%px)\n", \ (void *)_verify0_right); \ } while (0) @@ -186,14 +183,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line) */ #define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \ - const boolean_t _verify3_left = (boolean_t)(LEFT); \ - const boolean_t _verify3_right = (boolean_t)(RIGHT); \ + const boolean_t _verify3_left = (boolean_t)!!(LEFT); \ + const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%d " #OP " %d) " STR "\n", \ - (boolean_t)(_verify3_left), \ - (boolean_t)(_verify3_right), \ + _verify3_left, _verify3_right, \ __VA_ARGS__); \ } while (0) @@ -202,10 +198,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const int64_t _verify3_right = (int64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%lld " #OP " %lld) " STR "\n", \ - (long long)(_verify3_left), \ - (long long)(_verify3_right), \ + (long long)_verify3_left, (long long)_verify3_right,\ __VA_ARGS__); \ } while (0) @@ -214,10 +209,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uint64_t _verify3_right = (uint64_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%llu " #OP " %llu) " STR "\n", \ - (unsigned long long)(_verify3_left), \ - (unsigned long long)(_verify3_right), \ + (unsigned long long)_verify3_left, \ + (unsigned long long)_verify3_right, \ __VA_ARGS__); \ } while (0) @@ -226,32 +221,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line) const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ if (unlikely(!(_verify3_left OP _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ + "VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \ "failed (%px " #OP " %px) " STR "\n", \ - (void *) (_verify3_left), \ - (void *) (_verify3_right), \ + (void *)_verify3_left, (void *)_verify3_right, \ __VA_ARGS__); \ } while (0) #define VERIFY0PF(RIGHT, STR, ...) do { \ - const uintptr_t _verify3_left = (uintptr_t)(0); \ const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \ - if (unlikely(!(_verify3_left == _verify3_right))) \ + if (unlikely(!(0 == _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(0 == " #RIGHT ") " \ - "failed (0 == %px) " STR "\n", \ - (long long) (_verify3_right), \ + "VERIFY0P(" #RIGHT ") failed (%px) " STR "\n", \ + (void *)_verify3_right, \ __VA_ARGS__); \ } while (0) #define VERIFY0F(RIGHT, STR, ...) do { \ - const int64_t _verify3_left = (int64_t)(0); \ const int64_t _verify3_right = (int64_t)(RIGHT); \ - if (unlikely(!(_verify3_left == _verify3_right))) \ + if (unlikely(!(0 == _verify3_right))) \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \ - "VERIFY0(0 == " #RIGHT ") " \ - "failed (0 == %lld) " STR "\n", \ - (long long) (_verify3_right), \ + "VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \ + (long long)_verify3_right, \ __VA_ARGS__); \ } while (0) @@ -260,10 +250,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line) spl_assert("(" #A ") implies (" #B ")", \ __FILE__, __FUNCTION__, __LINE__))) -#define VERIFY_EQUIV(A, B) \ - ((void)(likely(!!(A) == !!(B)) || \ - spl_assert("(" #A ") is equivalent to (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) +#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B) /* * Debugging disabled (--disable-debug) diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index 9497ce16f..e704a899e 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -86,12 +86,13 @@ do { \ #define VERIFY3B(LEFT, OP, RIGHT) \ do { \ - const boolean_t __left = (boolean_t)(LEFT); \ - const boolean_t __right = (boolean_t)(RIGHT); \ + const boolean_t __left = (boolean_t)!!(LEFT); \ + const boolean_t __right = (boolean_t)!!(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ + "VERIFY3B(%s, %s, %s) failed " \ + "(%d %s %d)", #LEFT, #OP, #RIGHT, \ + __left, #OP, __right); \ } while (0) #define VERIFY3S(LEFT, OP, RIGHT) \ @@ -100,8 +101,9 @@ do { \ const int64_t __right = (int64_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ + "VERIFY3S(%s, %s, %s) failed " \ + "(%lld %s 0x%lld)", #LEFT, #OP, #RIGHT, \ + (longlong_t)__left, #OP, (longlong_t)__right); \ } while (0) #define VERIFY3U(LEFT, OP, RIGHT) \ @@ -110,7 +112,8 @@ do { \ const uint64_t __right = (uint64_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \ + "VERIFY3U(%s, %s, %s) failed " \ + "(%llu %s %llu)", #LEFT, #OP, #RIGHT, \ (u_longlong_t)__left, #OP, (u_longlong_t)__right); \ } while (0) @@ -120,7 +123,8 @@ do { \ const uintptr_t __right = (uintptr_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (%p %s %p)", #LEFT, #OP, #RIGHT, \ + "VERIFY3P(%s, %s, %s) failed " \ + "(%p %s %p)", #LEFT, #OP, #RIGHT, \ (void *)__left, #OP, (void *)__right); \ } while (0) @@ -129,7 +133,7 @@ do { \ const uint64_t __left = (uint64_t)(LEFT); \ if (!(__left == 0)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s == 0 (0x%llx == 0)", #LEFT, \ + "VERIFY0(%s) failed (%lld)", #LEFT, \ (u_longlong_t)__left); \ } while (0) @@ -138,7 +142,7 @@ do { \ const uintptr_t __left = (uintptr_t)(LEFT); \ if (!(__left == 0)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s == 0 (%p == 0)", #LEFT, \ + "VERIFY0P(%s) failed (%p)", #LEFT, \ (void *)__left); \ } while (0) @@ -150,13 +154,13 @@ do { \ /* BEGIN CSTYLED */ #define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) \ do { \ - const boolean_t __left = (boolean_t)(LEFT); \ - const boolean_t __right = (boolean_t)(RIGHT); \ + const boolean_t __left = (boolean_t)!!(LEFT); \ + const boolean_t __right = (boolean_t)!!(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx) " STR, \ - #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + "VERIFY3B(%s, %s, %s) failed " \ + "(%d %s %d) " STR, #LEFT, #OP, #RIGHT, \ + __left, #OP, __right, \ __VA_ARGS__); \ } while (0) @@ -166,9 +170,9 @@ do { \ const int64_t __right = (int64_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx) " STR, \ - #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + "VERIFY3S(%s, %s, %s) failed " \ + "(%lld %s %lld) " STR, #LEFT, #OP, #RIGHT, \ + (longlong_t)__left, #OP, (longlong_t)__right, \ __VA_ARGS__); \ } while (0) @@ -178,8 +182,8 @@ do { \ const uint64_t __right = (uint64_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx) " STR, \ - #LEFT, #OP, #RIGHT, \ + "VERIFY3U(%s, %s, %s) failed " \ + "(%llu %s %llu) " STR, #LEFT, #OP, #RIGHT, \ (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ __VA_ARGS__); \ } while (0) @@ -190,20 +194,20 @@ do { \ const uintptr_t __right = (uintptr_t)(RIGHT); \ if (!(__left OP __right)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s %s %s (0x%llx %s 0x%llx) " STR, \ - #LEFT, #OP, #RIGHT, \ - (u_longlong_t)__left, #OP, (u_longlong_t)__right, \ + "VERIFY3P(%s, %s, %s) failed " \ + "(%p %s %p) " STR, #LEFT, #OP, #RIGHT, \ + (void *)__left, #OP, (void *)__right, \ __VA_ARGS__); \ } while (0) /* END CSTYLED */ #define VERIFY0F(LEFT, STR, ...) \ do { \ - const uint64_t __left = (uint64_t)(LEFT); \ + const int64_t __left = (int64_t)(LEFT); \ if (!(__left == 0)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s == 0 (0x%llx == 0) " STR, #LEFT, \ - (u_longlong_t)__left, __VA_ARGS__); \ + "VERIFY0(%s) failed (%lld) " STR, #LEFT, \ + (longlong_t)__left, __VA_ARGS__); \ } while (0) #define VERIFY0PF(LEFT, STR, ...) \ @@ -211,8 +215,8 @@ do { \ const uintptr_t __left = (uintptr_t)(LEFT); \ if (!(__left == 0)) \ libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \ - "%s == 0 (%p == 0) " STR, #LEFT, \ - (u_longlong_t)__left, __VA_ARGS__); \ + "VERIFY0P(%s) failed (%p) " STR, #LEFT, \ + (void *)__left, __VA_ARGS__); \ } while (0) #ifdef assert @@ -264,10 +268,7 @@ do { \ ((void)(((!(A)) || (B)) || \ libspl_assert("(" #A ") implies (" #B ")", \ __FILE__, __FUNCTION__, __LINE__))) -#define EQUIV(A, B) \ - ((void)((!!(A) == !!(B)) || \ - libspl_assert("(" #A ") is equivalent to (" #B ")", \ - __FILE__, __FUNCTION__, __LINE__))) +#define EQUIV(A, B) VERIFY3B(A, ==, B) #endif /* NDEBUG */