summaryrefslogtreecommitdiff
path: root/src/common/util_bug.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-07-28 10:02:38 -0400
committerNick Mathewson <nickm@torproject.org>2017-07-28 10:02:38 -0400
commit602c52cad486516defc9d5ed375effd74cfe4529 (patch)
treecb832219a39e6cc84067512fd7493faf44dee307 /src/common/util_bug.h
parent5f0fa480dd94f4fec7b8b026dbd0a524f7b9c786 (diff)
downloadtor-602c52cad486516defc9d5ed375effd74cfe4529.tar.gz
tor-602c52cad486516defc9d5ed375effd74cfe4529.zip
Coverity deadcode shenanigans on BUG() macro.
We don't actually want Coverity to complain when a BUG() check can never fail, since such checks can prevent us from introducing bugs later on. Closes ticket 23054. Closes CID 1415720, 1415724.
Diffstat (limited to 'src/common/util_bug.h')
-rw-r--r--src/common/util_bug.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/common/util_bug.h b/src/common/util_bug.h
index ae7e7a37fd..de39317d1c 100644
--- a/src/common/util_bug.h
+++ b/src/common/util_bug.h
@@ -59,10 +59,13 @@
*/
#ifdef __COVERITY__
+extern int bug_macro_deadcode_dummy__;
#undef BUG
// Coverity defines this in global headers; let's override it. This is a
// magic coverity-only preprocessor thing.
-#nodef BUG(x) ((x)?(__coverity_panic__(),1):0)
+// We use this "deadcode_dummy__" trick to prevent coverity from
+// complaining about unreachable bug cases.
+#nodef BUG(x) ((x)?(__coverity_panic__(),1):(0+bug_macro_deadcode_dummy__))
#endif
#if defined(__COVERITY__) || defined(__clang_analyzer__)