Merge branch 'ab/bug-if-bug'
A new bug() and BUG_if_bug() API is introduced to make it easier to uniformly log "detect multiple bugs and abort in the end" pattern. * ab/bug-if-bug: cache-tree.c: use bug() and BUG_if_bug() receive-pack: use bug() and BUG_if_bug() parse-options.c: use optbug() instead of BUG() "opts" check parse-options.c: use new bug() API for optbug() usage.c: add a non-fatal bug() function to go with BUG() common-main.c: move non-trace2 exit() behavior out of trace2.c
This commit is contained in:
@ -1326,9 +1326,19 @@ static inline int regexec_buf(const regex_t *preg, const char *buf, size_t size,
|
||||
/* usage.c: only to be used for testing BUG() implementation (see test-tool) */
|
||||
extern int BUG_exit_code;
|
||||
|
||||
/* usage.c: if bug() is called we should have a BUG_if_bug() afterwards */
|
||||
extern int bug_called_must_BUG;
|
||||
|
||||
__attribute__((format (printf, 3, 4))) NORETURN
|
||||
void BUG_fl(const char *file, int line, const char *fmt, ...);
|
||||
#define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__)
|
||||
__attribute__((format (printf, 3, 4)))
|
||||
void bug_fl(const char *file, int line, const char *fmt, ...);
|
||||
#define bug(...) bug_fl(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#define BUG_if_bug(...) do { \
|
||||
if (bug_called_must_BUG) \
|
||||
BUG_fl(__FILE__, __LINE__, __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#ifndef FSYNC_METHOD_DEFAULT
|
||||
#ifdef __APPLE__
|
||||
@ -1459,8 +1469,8 @@ int cmd_main(int, const char **);
|
||||
* Intercept all calls to exit() and route them to trace2 to
|
||||
* optionally emit a message before calling the real exit().
|
||||
*/
|
||||
int trace2_cmd_exit_fl(const char *file, int line, int code);
|
||||
#define exit(code) exit(trace2_cmd_exit_fl(__FILE__, __LINE__, (code)))
|
||||
int common_exit(const char *file, int line, int code);
|
||||
#define exit(code) exit(common_exit(__FILE__, __LINE__, (code)))
|
||||
|
||||
/*
|
||||
* You can mark a stack variable with UNLEAK(var) to avoid it being
|
||||
|
Reference in New Issue
Block a user