[tor-commits] [tor/master] util_bug.h: Coccinelle does not understand IF_BUG_ONCE or #nodef.

teor at torproject.org teor at torproject.org
Thu Oct 24 00:01:21 UTC 2019


commit c77f57d37bbea4e7281c2de95a9f19b885290111
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed Oct 9 13:07:15 2019 -0400

    util_bug.h: Coccinelle does not understand IF_BUG_ONCE or #nodef.
---
 src/lib/log/util_bug.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lib/log/util_bug.h b/src/lib/log/util_bug.h
index 546ae1e3e..8c233da73 100644
--- a/src/lib/log/util_bug.h
+++ b/src/lib/log/util_bug.h
@@ -131,7 +131,9 @@
 #undef BUG
 // Coverity defines this in global headers; let's override it.  This is a
 // magic coverity-only preprocessor thing.
+#ifndef COCCI
 #nodef BUG(x) (x)
+#endif
 #endif /* defined(__COVERITY__) */
 
 #if defined(__COVERITY__) || defined(__clang_analyzer__)
@@ -200,6 +202,7 @@
    : 0)
 #endif /* defined(ALL_BUGS_ARE_FATAL) || ... */
 
+#ifndef COCCI
 #ifdef __GNUC__
 #define IF_BUG_ONCE__(cond,var)                                         \
   if (( {                                                               \
@@ -208,7 +211,7 @@
       if (bool_result && !var) {                                        \
         var = 1;                                                        \
         tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__,             \
-                          "!("#cond")", 1, NULL);                       \
+                          ("!("#cond")"), 1, NULL);                     \
       }                                                                 \
       bool_result; } ))
 #else /* !(defined(__GNUC__)) */
@@ -218,10 +221,12 @@
       (var ? 1 :                                                        \
        (var=1,                                                          \
         tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__,             \
-                           "!("#cond")", 1, NULL),                      \
+                          ("!("#cond")"), 1, NULL),                     \
         1))                                                             \
       : 0)
 #endif /* defined(__GNUC__) */
+#endif
+
 #define IF_BUG_ONCE_VARNAME_(a)               \
   warning_logged_on_ ## a ## __
 #define IF_BUG_ONCE_VARNAME__(a)              \





More information about the tor-commits mailing list