9front - general discussion about 9front
 help / color / mirror / Atom feed
* Ape: Fix assert warnings.
@ 2019-06-17 19:36 Ori Bernstein
  0 siblings, 0 replies; only message in thread
From: Ori Bernstein @ 2019-06-17 19:36 UTC (permalink / raw)
  To: 9front

Currently, we don't compile ape with warnings. When we do,
cc will complain that we're discarding a value when the
if condition can be evaluated at compile time:

	assert(0 == 0);
	warning: /sys/include/ape/test.c:6[stdin:25] result of operation not used

This causes warnings in some software I'm porting, as well
as in ape (if I turn on warnings there; patch pending).

diff -r 40949afe3df8 sys/include/ape/assert.h
--- a/sys/include/ape/assert.h	Mon Jun 17 13:17:16 2019 +0930
+++ b/sys/include/ape/assert.h	Mon Jun 17 12:17:46 2019 -0700
@@ -13,5 +13,5 @@
 #ifdef __cplusplus
 }
 #endif
-#define assert(e) ((e) ? (void)0 : _assert(__FILE__, __LINE__))
+#define assert(e) do {if(e) {} else _assert(__FILE__, __LINE__);} while(0)
 #endif /* NDEBUG */

-- 
Ori Bernstein <ori@eigenstate.org>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-06-17 19:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 19:36 Ape: Fix assert warnings Ori Bernstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).