1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-07 14:24:14 +01:00

WUtil: change 'wassertr(v)' to still perform check even if NDEBUG is set

In many places of the code these functions are counting on the "return"
effect of these macros to gracefully handle incorrect arguments. So, when
debug is not enabled, if it is okay to not display a message it is however
not good to completely skip the check and skip the early return.

This patch changes the macro to always perform the check and return to
avoid crashes, displaying a message only when NDEBUG is not set.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-05-18 00:56:45 +02:00
committed by Carlos R. Mafra
parent c5f103984a
commit 0350026866

View File

@@ -55,21 +55,14 @@
#ifdef NDEBUG
#define wassertr(expr) {}
#define wassertrv(expr, val) {}
#define wassertr(expr) \
if (!(expr)) { return; }
#define wassertrv(expr, val) \
if (!(expr)) { return (val); }
#else /* !NDEBUG */
#ifdef DEBUG
#include <assert.h>
#define wassertr(expr) assert(expr)
#define wassertrv(expr, val) assert(expr)
#else /* !DEBUG */
#define wassertr(expr) \
if (!(expr)) { \
wwarning("%s line %i (%s): assertion %s failed",\
@@ -83,7 +76,6 @@
__FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\
return (val);\
}
#endif /* !DEBUG */
#endif /* !NDEBUG */