mirror of
https://github.com/clearlinux/graphene.git
synced 2026-08-23 07:15:50 +00:00
Remove parentheses from assert argument evaluation
This helps with catching errors like `assert(x = y)`.
This commit is contained in:
@@ -118,7 +118,7 @@ void shim_xstate_restore(const void* xstate_extended) {
|
||||
assert(fpx_sw->magic1 == SHIM_FP_XSTATE_MAGIC1);
|
||||
assert(fpx_sw->extended_size == g_shim_xsave_size + SHIM_FP_XSTATE_MAGIC2_SIZE);
|
||||
assert(fpx_sw->xfeatures == g_shim_xsave_features);
|
||||
assert(fpx_sw->xstate_size = g_shim_xsave_size);
|
||||
assert(fpx_sw->xstate_size == g_shim_xsave_size);
|
||||
assert(*((__typeof__(SHIM_FP_XSTATE_MAGIC2)*)bytes_after_xstate) == SHIM_FP_XSTATE_MAGIC2);
|
||||
|
||||
__UNUSED(bytes_after_xstate);
|
||||
|
||||
@@ -21,13 +21,15 @@ noreturn void __abort(void);
|
||||
* build system.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
#define assert(expr) \
|
||||
({ \
|
||||
(!(expr)) ? ({ \
|
||||
warn("assert failed " __FILE__ ":%d %s\n", __LINE__, #expr); \
|
||||
__abort(); \
|
||||
}) \
|
||||
: (void)0; \
|
||||
/* This `if` is weird intentionally - not to have parentheses around `expr` to catch `assert(x = y)`
|
||||
* errors. */
|
||||
#define assert(expr) \
|
||||
({ \
|
||||
if (expr) {} else { \
|
||||
warn("assert failed " __FILE__ ":%d %s\n", __LINE__, #expr); \
|
||||
__abort(); \
|
||||
} \
|
||||
(void)0; \
|
||||
})
|
||||
#else
|
||||
#define assert(expr) ((void)0)
|
||||
|
||||
Reference in New Issue
Block a user