aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDeHackEd <[email protected]>2018-02-21 17:54:26 -0500
committerBrian Behlendorf <[email protected]>2018-02-21 14:54:26 -0800
commit2b5cd5990f587dedf5cfe3f857105af70c7a21ed (patch)
tree47d07feb2a7e926c8184f2280d4e4b54e4c03539 /include
parent48ef8ba07094afcd67355940ca8db92d76f7c096 (diff)
Fix multiple evaluations of VERIFY() and ASSERT() on failures
Reviewed-by: loli10K <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: DHE <[email protected]> Closes #684 Closes #685
Diffstat (limited to 'include')
-rw-r--r--include/sys/debug.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/include/sys/debug.h b/include/sys/debug.h
index cd78171df..a4a458066 100644
--- a/include/sys/debug.h
+++ b/include/sys/debug.h
@@ -63,12 +63,15 @@ void spl_dumpstack(void);
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"%s", "VERIFY(" #cond ") failed\n"))
-#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) \
- (void) ((!((TYPE)(LEFT) OP (TYPE)(RIGHT))) && \
- spl_panic(__FILE__, __FUNCTION__, __LINE__, \
- "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
- "failed (" FMT " " #OP " " FMT ")\n", \
- CAST (LEFT), CAST (RIGHT)))
+#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) do { \
+ TYPE _verify3_left = (TYPE)(LEFT); \
+ TYPE _verify3_right = (TYPE)(RIGHT); \
+ if (!(_verify3_left OP _verify3_right)) \
+ spl_panic(__FILE__, __FUNCTION__, __LINE__, \
+ "VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
+ "failed (" FMT " " #OP " " FMT ")\n", \
+ CAST (_verify3_left), CAST (_verify3_right)); \
+ } while (0)
#define VERIFY3B(x,y,z) VERIFY3_IMPL(x, y, z, boolean_t, "%d", (boolean_t))
#define VERIFY3S(x,y,z) VERIFY3_IMPL(x, y, z, int64_t, "%lld", (long long))