Skip to content

Commit ca6b92d

Browse files
cypharandrewc12
authored andcommitted
debug: add VERIFY_{IMPLY,EQUIV} variants
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
1 parent 24fdf44 commit ca6b92d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

include/os/linux/spl/sys/debug.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
140140
(long long) (_verify3_right)); \
141141
} while (0)
142142

143+
#define VERIFY_IMPLY(A, B) \
144+
((void)(likely((!(A)) || (B)) || \
145+
spl_assert("(" #A ") implies (" #B ")", \
146+
__FILE__, __FUNCTION__, __LINE__)))
147+
148+
#define VERIFY_EQUIV(A, B) \
149+
((void)(likely(!!(A) == !!(B)) || \
150+
spl_assert("(" #A ") is equivalent to (" #B ")", \
151+
__FILE__, __FUNCTION__, __LINE__)))
152+
143153
/*
144154
* Debugging disabled (--disable-debug)
145155
*/
@@ -171,14 +181,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
171181
#define ASSERT3P VERIFY3P
172182
#define ASSERT0 VERIFY0
173183
#define ASSERT VERIFY
174-
#define IMPLY(A, B) \
175-
((void)(likely((!(A)) || (B)) || \
176-
spl_assert("(" #A ") implies (" #B ")", \
177-
__FILE__, __FUNCTION__, __LINE__)))
178-
#define EQUIV(A, B) \
179-
((void)(likely(!!(A) == !!(B)) || \
180-
spl_assert("(" #A ") is equivalent to (" #B ")", \
181-
__FILE__, __FUNCTION__, __LINE__)))
184+
#define IMPLY VERIFY_IMPLY
185+
#define EQUIV VERIFY_EQUIV
182186

183187
#endif /* NDEBUG */
184188

0 commit comments

Comments
 (0)