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=0a60e906e608f4505584281acfe6c699d04ef00b;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)