Skip to content

Commit

Permalink
debug: add VERIFY_{IMPLY,EQUIV} variants
Browse files Browse the repository at this point in the history
This allows for much cleaner VERIFY-level assertions.

Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Aleksa Sarai <[email protected]>
Closes openzfs#14070
  • Loading branch information
cyphar authored and shodanshok committed Nov 3, 2022
1 parent d6428d6 commit feb7d79
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions include/os/linux/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
(long long) (_verify3_right)); \
} while (0)

#define VERIFY_IMPLY(A, B) \
((void)(likely((!(A)) || (B)) || \
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__)))

/*
* Debugging disabled (--disable-debug)
*/
Expand Down Expand Up @@ -171,14 +181,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
#define ASSERT3P VERIFY3P
#define ASSERT0 VERIFY0
#define ASSERT VERIFY
#define IMPLY(A, B) \
((void)(likely((!(A)) || (B)) || \
spl_assert("(" #A ") implies (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
#define EQUIV(A, B) \
((void)(likely(!!(A) == !!(B)) || \
spl_assert("(" #A ") is equivalent to (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
#define IMPLY VERIFY_IMPLY
#define EQUIV VERIFY_EQUIV

#endif /* NDEBUG */

Expand Down

0 comments on commit feb7d79

Please sign in to comment.