
commit 358df18064d0389219e610cf9aa5b08bbd6a0ec8 Merge: 9ae267538 802ac8ad6 Author: Nick Mathewson <nickm@torproject.org> Date: Mon Apr 15 14:27:32 2019 -0400 Merge branch 'bug30189_035' into bug30189_041 changes/bug30189 | 4 ++++ src/lib/log/util_bug.c | 14 ++++++++++++++ src/lib/log/util_bug.h | 8 +++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --cc src/lib/log/util_bug.h index 63c5309c9,2a4d68127..2e220b728 --- a/src/lib/log/util_bug.h +++ b/src/lib/log/util_bug.h @@@ -99,22 -95,19 +99,22 @@@ #else /** Like assert(3), but send assertion failures to the log as well as to * stderr. */ -#define tor_assert(expr) STMT_BEGIN \ +#define tor_assert(expr) tor_assertf(expr, NULL) + +#define tor_assertf(expr, fmt, ...) STMT_BEGIN \ if (ASSERT_PREDICT_LIKELY_(expr)) { \ } else { \ - tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr); \ - tor_abort_(); \ + tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr, \ + fmt, ##__VA_ARGS__); \ - abort(); \ ++ tor_abort_(); \ } STMT_END #endif /* defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS) */ #define tor_assert_unreached() \ STMT_BEGIN { \ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, \ - "line should be unreached"); \ + "line should be unreached", NULL); \ - abort(); \ + tor_abort_(); \ } STMT_END /* Non-fatal bug assertions. The "unreached" variants mean "this line should @@@ -240,12 -221,13 +240,14 @@@ #define tor_fragile_assert() tor_assert_nonfatal_unreached_once() void tor_assertion_failed_(const char *fname, unsigned int line, - const char *func, const char *expr); + const char *func, const char *expr, + const char *fmt, ...); void tor_bug_occurred_(const char *fname, unsigned int line, const char *func, const char *expr, - int once); + int once, const char *fmt, ...); + void tor_abort_(void) ATTR_NORETURN; + #ifdef _WIN32 #define SHORT_FILE__ (tor_fix_source_file(__FILE__)) const char *tor_fix_source_file(const char *fname);