ASSERT should evaluate to an expression not a statement.
[pintos-anon] / src / lib / debug.h
index 2af8ba421ebe248b07c3a03d5e80fe09dbba3acc..76c3f77b732f8aa807847fb9be13a7af91c2bb8d 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef HEADER_DEBUG_H
-#define HEADER_DEBUG_H 1
+#ifndef __LIB_DEBUG_H
+#define __LIB_DEBUG_H
 
 /* GCC lets us add "attributes" to functions, function
    parameters, etc. to indicate their properties.
@@ -37,12 +37,10 @@ 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)
 #define NOT_REACHED() for (;;)
-#endif
+#endif /* lib/debug.h */