summaryrefslogtreecommitdiff
path: root/src/common/util_bug.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-09-06 20:59:07 -0400
committerNick Mathewson <nickm@torproject.org>2016-09-06 21:00:51 -0400
commit2b39c927c7f2c13f17d9883371a12131b6c6df40 (patch)
tree5c3d4ddf13e2be6d263769d5cc94b7e7ded366d9 /src/common/util_bug.h
parent2a4a815f5801e79e67e9906eecdd544d25fcbfd6 (diff)
downloadtor-2b39c927c7f2c13f17d9883371a12131b6c6df40.tar.gz
tor-2b39c927c7f2c13f17d9883371a12131b6c6df40.zip
Add !(...) to BUG() log messages
They use the same code as reporting assertion failures, so we should invert the sense of what we're "asserting". Fixes bug 20093.
Diffstat (limited to 'src/common/util_bug.h')
-rw-r--r--src/common/util_bug.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/util_bug.h b/src/common/util_bug.h
index 3f77e0a99e..8b85d472b6 100644
--- a/src/common/util_bug.h
+++ b/src/common/util_bug.h
@@ -65,7 +65,8 @@
#define tor_assert_nonfatal_once(cond) tor_assert((cond))
#define BUG(cond) \
(PREDICT_UNLIKELY(cond) ? \
- (tor_assertion_failed_(SHORT_FILE__,__LINE__,__func__,#cond), abort(), 1) \
+ (tor_assertion_failed_(SHORT_FILE__,__LINE__,__func__,"!("#cond")"), \
+ abort(), 1) \
: 0)
#elif defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS)
#define tor_assert_nonfatal_unreached() STMT_NIL
@@ -98,18 +99,19 @@
STMT_END
#define BUG(cond) \
(PREDICT_UNLIKELY(cond) ? \
- (tor_bug_occurred_(SHORT_FILE__,__LINE__,__func__,#cond,0), 1) \
+ (tor_bug_occurred_(SHORT_FILE__,__LINE__,__func__,"!("#cond")",0), 1) \
: 0)
#endif
#ifdef __GNUC__
#define IF_BUG_ONCE__(cond,var) \
- if (( { \
+ if (( { \
static int var = 0; \
int bool_result = (cond); \
if (PREDICT_UNLIKELY(bool_result) && !var) { \
var = 1; \
- tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__, #cond, 1); \
+ tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__, \
+ "!("#cond")", 1); \
} \
PREDICT_UNLIKELY(bool_result); } ))
#else
@@ -118,7 +120,8 @@
if (PREDICT_UNLIKELY(cond)) ? \
(var ? 1 : \
(var=1, \
- tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__, #cond, 1), \
+ tor_bug_occurred_(SHORT_FILE__, __LINE__, __func__, \
+ "!("#cond")", 1), \
1)) \
: 0)
#endif