diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2025-03-03 16:57:28 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2025-03-04 11:46:00 -0500 |
commit | 5c5ae3962c46cf4051bcd6d4e2355422e63de42b (patch) | |
tree | 6552fb22344d8385fc1b253448d5a29982488f3a /src/diag.c | |
parent | 1aefb830360e43b6e5ddee96791eb83cdad766cc (diff) | |
download | bfs-5c5ae3962c46cf4051bcd6d4e2355422e63de42b.tar.xz |
diag: Get rid of struct bfs_location
Just add the standard prefix to the passed format string in the
diagnostic macros themselves. This lets us write the whole message with
one dprintf() call, minimizing interleaving.
It's also a net win for binary size.
Diffstat (limited to 'src/diag.c')
-rw-r--r-- | src/diag.c | 18 |
1 files changed, 4 insertions, 14 deletions
@@ -21,33 +21,23 @@ * async-signal-safe in practice. */ #if BFS_HAS_DPRINTF -# define eprintf(...) dprintf(STDERR_FILENO, __VA_ARGS__) # define veprintf(...) vdprintf(STDERR_FILENO, __VA_ARGS__) #else -# define eprintf(...) fprintf(stderr, __VA_ARGS__) # define veprintf(...) vfprintf(stderr, __VA_ARGS__) #endif -/** bfs_diagf() implementation. */ -_printf(2, 0) -static void bfs_vdiagf(const struct bfs_loc *loc, const char *format, va_list args) { - eprintf("%s: %s@%s:%d: ", xgetprogname(), loc->func, loc->file, loc->line); - veprintf(format, args); - eprintf("\n"); -} - -void bfs_diagf(const struct bfs_loc *loc, const char *format, ...) { +void bfs_diagf(const char *format, ...) { va_list args; va_start(args, format); - bfs_vdiagf(loc, format, args); + veprintf(format, args); va_end(args); } _noreturn -void bfs_abortf(const struct bfs_loc *loc, const char *format, ...) { +void bfs_abortf(const char *format, ...) { va_list args; va_start(args, format); - bfs_vdiagf(loc, format, args); + veprintf(format, args); va_end(args); abort(); |