]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Clean up existing VERIFY*() macros.
authorDag-Erling Smørgrav <des@FreeBSD.org>
Wed, 30 Aug 2023 15:13:06 +0000 (17:13 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 20 Sep 2023 00:21:01 +0000 (17:21 -0700)
Chiefly:

- Remove unnecessary parentheses around variable names.
- Remove spaces between the type and variable in casts.
- Make the panic message for VERIFY0() reflect how the macro is used.
- Use %p to format pointers, except in Linux kernel code.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Kay Pedersen <mail@mkwg.de>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Dag-Erling Smørgrav <des@FreeBSD.org>
Closes #15225

include/os/freebsd/spl/sys/debug.h
include/os/linux/spl/sys/debug.h
lib/libspl/include/assert.h

index 3e67cf0e9a7d88ea88656e3fd93f459a338bfb17..b29d0daecc4bb6b66fc9e5c46696c89492b8f572 100644 (file)
@@ -89,8 +89,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%d " #OP " %d)\n",                         \
-                   (boolean_t)(_verify3_left),                         \
-                   (boolean_t)(_verify3_right));                       \
+                   (boolean_t)_verify3_left,                           \
+                   (boolean_t)_verify3_right);                         \
        } while (0)
 
 #define        VERIFY3S(LEFT, OP, RIGHT)       do {                            \
@@ -100,8 +100,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%lld " #OP " %lld)\n",                     \
-                   (long long) (_verify3_left),                        \
-                   (long long) (_verify3_right));                      \
+                   (long long)_verify3_left,                           \
+                   (long long)_verify3_right);                         \
        } while (0)
 
 #define        VERIFY3U(LEFT, OP, RIGHT)       do {                            \
@@ -111,8 +111,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%llu " #OP " %llu)\n",                     \
-                   (unsigned long long) (_verify3_left),               \
-                   (unsigned long long) (_verify3_right));             \
+                   (unsigned long long)_verify3_left,                  \
+                   (unsigned long long)_verify3_right);                \
        } while (0)
 
 #define        VERIFY3P(LEFT, OP, RIGHT)       do {                            \
@@ -121,19 +121,18 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                if (unlikely(!(_verify3_left OP _verify3_right)))       \
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
-                   "failed (%px " #OP " %px)\n",                       \
-                   (void *) (_verify3_left),                           \
-                   (void *) (_verify3_right));                         \
+                   "failed (%p " #OP " %p)\n",                         \
+                   (void *)_verify3_left,                              \
+                   (void *)_verify3_right);                            \
        } while (0)
 
 #define        VERIFY0(RIGHT)  do {                                            \
-               const int64_t _verify3_left = (int64_t)(0);             \
-               const int64_t _verify3_right = (int64_t)(RIGHT);        \
-               if (unlikely(!(_verify3_left == _verify3_right)))       \
+               const int64_t _verify0_right = (int64_t)(RIGHT);        \
+               if (unlikely(!(0 == _verify0_right)))                   \
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
-                   "VERIFY0(0 == " #RIGHT ") "                         \
+                   "VERIFY0(" #RIGHT ") "                              \
                    "failed (0 == %lld)\n",                             \
-                   (long long) (_verify3_right));                      \
+                   (long long)_verify0_right);                         \
        } while (0)
 
 /*
index 007238574fe13ee6904088e4b7c34dc4598e3f2e..9bcc2e1d19238c2cdeb2f45a09c76963fef3682d 100644 (file)
@@ -93,8 +93,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%d " #OP " %d)\n",                         \
-                   (boolean_t)(_verify3_left),                         \
-                   (boolean_t)(_verify3_right));                       \
+                   (boolean_t)_verify3_left,                           \
+                   (boolean_t)_verify3_right);                         \
        } while (0)
 
 #define        VERIFY3S(LEFT, OP, RIGHT)       do {                            \
@@ -104,8 +104,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%lld " #OP " %lld)\n",                     \
-                   (long long)(_verify3_left),                         \
-                   (long long)(_verify3_right));                       \
+                   (long long)_verify3_left,                           \
+                   (long long)_verify3_right);                         \
        } while (0)
 
 #define        VERIFY3U(LEFT, OP, RIGHT)       do {                            \
@@ -115,8 +115,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%llu " #OP " %llu)\n",                     \
-                   (unsigned long long)(_verify3_left),                \
-                   (unsigned long long)(_verify3_right));              \
+                   (unsigned long long)_verify3_left,                  \
+                   (unsigned long long)_verify3_right);                \
        } while (0)
 
 #define        VERIFY3P(LEFT, OP, RIGHT)       do {                            \
@@ -126,18 +126,17 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
                    "VERIFY3(" #LEFT " "  #OP " "  #RIGHT ") "          \
                    "failed (%px " #OP " %px)\n",                       \
-                   (void *) (_verify3_left),                           \
-                   (void *) (_verify3_right));                         \
+                   (void *)_verify3_left,                              \
+                   (void *)_verify3_right);                            \
        } while (0)
 
 #define        VERIFY0(RIGHT)  do {                                            \
-               const int64_t _verify3_left = (int64_t)(0);             \
-               const int64_t _verify3_right = (int64_t)(RIGHT);        \
-               if (unlikely(!(_verify3_left == _verify3_right)))       \
+               const int64_t _verify0_right = (int64_t)(RIGHT);        \
+               if (unlikely(!(0 == _verify0_right)))                   \
                    spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
-                   "VERIFY0(0 == " #RIGHT ") "                         \
+                   "VERIFY0(" #RIGHT ") "                              \
                    "failed (0 == %lld)\n",                             \
-                   (long long) (_verify3_right));                      \
+                   (long long)_verify0_right);                         \
        } while (0)
 
 #define        VERIFY_IMPLY(A, B) \
index c5bf0f0cc8f14b07cea2dfc607f4d70f1cd27ed5..e92f28300d20c99e652f27aa8167aa36857ded4f 100644 (file)
@@ -107,8 +107,8 @@ 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)", #LEFT, #OP, #RIGHT,  \
-                   (u_longlong_t)__left, #OP, (u_longlong_t)__right);  \
+                   "%s %s %s (%p %s %p)", #LEFT, #OP, #RIGHT,          \
+                   (void *)__left, #OP, (void *)__right);              \
 } while (0)
 
 #define        VERIFY0(LEFT)                                                   \