]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
simplify RUNTIME_CHECK for cppcheck
authorMark Andrews <marka@isc.org>
Thu, 30 Jan 2020 06:14:42 +0000 (17:14 +1100)
committerMark Andrews <marka@isc.org>
Thu, 30 Jan 2020 06:14:42 +0000 (17:14 +1100)
lib/isc/include/isc/util.h

index c4a872cba7c2da5d610fdf2a142498286a3ec7bb..20f107b8c6264b9ad512b9bf60469c82d54c861f 100644 (file)
@@ -285,12 +285,17 @@ extern void mock_assert(const int result, const char* const expression,
 #ifdef UNIT_TESTING
 
 #define RUNTIME_CHECK(expression)                                      \
-       mock_assert((int)(expression), #expression, __FILE__, __LINE__)
+       ((!(expression)) ?                                              \
+       (mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
 
 #else /* UNIT_TESTING */
 
+#ifndef CPPCHECK
 /*% Runtime Check */
 #define RUNTIME_CHECK(cond)            ISC_ERROR_RUNTIMECHECK(cond)
+#else
+#define RUNTIME_CHECK(e)               if (!(e)) abort()
+#endif
 
 #endif /* UNIT_TESTING */