]> 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)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 5 Feb 2020 08:08:35 +0000 (09:08 +0100)
(cherry picked from commit 668a972d1e71ccc7282601906dff4bc4bb3a7d1c)

lib/isc/include/isc/util.h

index 20d0937f48105a66c2f96db666a827d0ad98e6f0..2140d839e853229928c797a9852b19b1a9800c89 100644 (file)
@@ -275,12 +275,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 */