summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-06-25 14:30:45 -0400
committerTavian Barnes <tavianator@tavianator.com>2025-07-04 08:21:30 -0400
commit458c99ba19ccafb637f25bfb7f5a1de2dd84c6dc (patch)
treeaf6e9828c21d913ab216c41ddebce841f610b10c
parentf1fa639bdfb6e8da91b57f892acf26d438d30fd3 (diff)
downloadbfs-458c99ba19ccafb637f25bfb7f5a1de2dd84c6dc.tar.xz
diag: Fix bfs_eabort() macro
-rw-r--r--src/diag.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/diag.h b/src/diag.h
index 645dbb1..0a4d3b9 100644
--- a/src/diag.h
+++ b/src/diag.h
@@ -18,6 +18,7 @@
*
* bfs: func@src/file.c:0: Message
*/
+// Use (format) ? "..." : "" so the format string is required
#define BFS_DIAG_FORMAT_(format) \
((format) ? "%s: %s@%s:%d: " format "%s" : "")
@@ -75,7 +76,7 @@ void bfs_abortf(const char *format, ...);
bfs_eabort_(__VA_ARGS__, )
#define bfs_eabort_(format, ...) \
- ((format) ? bfs_abort_(format ": %s", __VA_ARGS__ errstr(), ) : (void)0)
+ bfs_abort_(format "%s%s", __VA_ARGS__ (sizeof("" format) > 1 ? ": " : ""), errstr(), )
/**
* Abort in debug builds; no-op in release builds.
@@ -116,7 +117,6 @@ void bfs_abortf(const char *format, ...);
#define bfs_everify(...) \
bfs_everify_(#__VA_ARGS__, __VA_ARGS__, "", )
-
#define bfs_everify_(str, cond, format, ...) \
((cond) ? (void)0 : bfs_everify__(format, BFS_DIAG_MSG_(format, str), __VA_ARGS__))