shithub: riscv

Download patch

ref: 034d0b08e91ee11278875168176954bb4572c76e
parent: 013122b993652f0b76af026a15219e103ed94468
author: mischief <mischief@offblast.org>
date: Mon Apr 2 17:44:21 EDT 2018

ape: improve assert macro

in a statement such as:

if(expr)
	assert(a);
else
	assert(b);

the previous definition of assert would fail to compile, as the else
would be dangling.  with a ternary expression, this construct works
fine.

--- a/sys/include/ape/assert.h
+++ b/sys/include/ape/assert.h
@@ -13,5 +13,5 @@
 #ifdef __cplusplus
 }
 #endif
-#define assert(e) {if(!(e))_assert(__FILE__, __LINE__);}
+#define assert(e) ((e) ? (void)0 : _assert(__FILE__, __LINE__))
 #endif /* NDEBUG */