From: Christophe CURIS <christophe.cu...@free.fr> 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.cu...@free.fr> --- WINGs/WINGs/WUtil.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/WINGs/WINGs/WUtil.h b/WINGs/WINGs/WUtil.h index da74dfc..01d0368 100644 --- a/WINGs/WINGs/WUtil.h +++ b/WINGs/WINGs/WUtil.h @@ -55,20 +55,13 @@ #ifdef NDEBUG -#define wassertr(expr) {} -#define wassertrv(expr, val) {} +#define wassertr(expr) \ + if (!(expr)) { return; } -#else /* !NDEBUG */ - -#ifdef DEBUG - -#include <assert.h> +#define wassertrv(expr, val) \ + if (!(expr)) { return (val); } -#define wassertr(expr) assert(expr) - -#define wassertrv(expr, val) assert(expr) - -#else /* !DEBUG */ +#else /* !NDEBUG */ #define wassertr(expr) \ if (!(expr)) { \ @@ -83,7 +76,6 @@ __FILE__, __LINE__, __ASSERT_FUNCTION, #expr);\ return (val);\ } -#endif /* !DEBUG */ #endif /* !NDEBUG */ -- 1.9.2 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.