util_bug.h: Coccinelle does not understand IF_BUG_ONCE or #nodef.

This commit is contained in:
Nick Mathewson 2019-10-09 13:07:15 -04:00
parent fb4b6b6436
commit c77f57d37b

View File

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