From: Ben Pfaff Date: Mon, 18 Oct 2004 17:42:40 +0000 (+0000) Subject: ASSERT should evaluate to an expression not a statement. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8899ce6c4b4fad8cc52cc1ffe02ca9e01a6b5ad;p=pintos-anon ASSERT should evaluate to an expression not a statement. --- diff --git a/src/lib/debug.h b/src/lib/debug.h index 947dff2..76c3f77 100644 --- a/src/lib/debug.h +++ b/src/lib/debug.h @@ -37,10 +37,8 @@ void debug_backtrace (void); #undef NOT_REACHED #ifndef NDEBUG -#define ASSERT(CONDITION) \ - if (CONDITION) { } else { \ - PANIC ("assertion `%s' failed.", #CONDITION); \ - } +#define ASSERT(CONDITION) \ + ((void) ((CONDITION) || PANIC ("assertion `%s' failed.", #CONDITION))) #define NOT_REACHED() PANIC ("executed an unreachable statement"); #else #define ASSERT(CONDITION) ((void) 0)