]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge branch 'bug30189_035' into bug30189_041
authorNick Mathewson <nickm@torproject.org>
Mon, 15 Apr 2019 18:27:32 +0000 (14:27 -0400)
committerNick Mathewson <nickm@torproject.org>
Mon, 15 Apr 2019 18:27:32 +0000 (14:27 -0400)
1  2 
src/lib/log/util_bug.c
src/lib/log/util_bug.h

Simple merge
index 63c5309c98bfefc569d8ccd9543e96097b0765c0,2a4d68127e5b7372ffc5f49d5db792cfe3f76820..2e220b72865e431e9eddbb3fff1c0c981b896889
  #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
  #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);