]> git.proxmox.com Git - ovs.git/blobdiff - lib/util.h
ovs_assert, tests: Support NDEBUG.
[ovs.git] / lib / util.h
index f171dbfc6cd2738b8041d39043de67fc09674352..79501af0150e604e7ede4ca00e1e1808c49ad9ca 100644 (file)
 #define BUILD_ASSERT_DECL_GCCONLY(EXPR) ((void) 0)
 #endif
 
-/* Like the standard assert macro, except:
- *
- *   - Writes the failure message to the log.
- *
- *   - Not affected by NDEBUG. */
+/* Like the standard assert macro, except writes the failure message to the
+ * log. */
+#ifndef NDEBUG
 #define ovs_assert(CONDITION)                                           \
     if (!OVS_LIKELY(CONDITION)) {                                       \
         ovs_assert_failure(SOURCE_LOCATOR, __func__, #CONDITION);       \
     }
+#else
+#define ovs_assert(CONDITION) ((void) (CONDITION))
+#endif
 NO_RETURN void ovs_assert_failure(const char *, const char *, const char *);
 
 /* Casts 'pointer' to 'type' and issues a compiler warning if the cast changes