mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
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 <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Reviewed-by: @ImAwsumm
Reviewed-by: Rob Norris <robn@despairlabs.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
(cherry picked from commit 4866c2fabf)
This commit is contained in:
committed by
Tony Hutter
parent
7fde3933fb
commit
243a46f28d
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user