Fix multiple evaluations of VERIFY() and ASSERT() on failures

Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: DHE <git@dehacked.net>
Closes #684 
Closes #685
This commit is contained in:
DeHackEd 2018-02-21 17:54:26 -05:00 committed by Brian Behlendorf
parent 48ef8ba070
commit 2b5cd5990f

View File

@ -63,12 +63,15 @@ void spl_dumpstack(void);
spl_panic(__FILE__, __FUNCTION__, __LINE__, \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"%s", "VERIFY(" #cond ") failed\n")) "%s", "VERIFY(" #cond ") failed\n"))
#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) \ #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) do { \
(void) ((!((TYPE)(LEFT) OP (TYPE)(RIGHT))) && \ TYPE _verify3_left = (TYPE)(LEFT); \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \ TYPE _verify3_right = (TYPE)(RIGHT); \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \ if (!(_verify3_left OP _verify3_right)) \
"failed (" FMT " " #OP " " FMT ")\n", \ spl_panic(__FILE__, __FUNCTION__, __LINE__, \
CAST (LEFT), CAST (RIGHT))) "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 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)) #define VERIFY3S(x,y,z) VERIFY3_IMPL(x, y, z, int64_t, "%lld", (long long))