From d2df7632321c473cd57064e2350b219fbc3f6677 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 27 Feb 2023 04:06:19 +0100 Subject: log, conf, tap: Define die() as err() plus exit(), drop cppcheck workarounds If we define die() as a variadic macro, passing __VA_ARGS__ to err(), and calling exit() outside err() itself, we can drop the workarounds introduced in commit 36f0199f6ef4 ("conf, tap: Silence two false positive invalidFunctionArg from cppcheck"). Suggested-by: David Gibson Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- log.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'log.h') diff --git a/log.h b/log.h index d4e9d85..d4ea141 100644 --- a/log.h +++ b/log.h @@ -10,12 +10,17 @@ #define LOGFILE_CUT_RATIO 30 /* When full, cut ~30% size */ #define LOGFILE_SIZE_MIN (5UL * MAX(BUFSIZ, PAGE_SIZE)) -void die(const char *format, ...); void err(const char *format, ...); void warn(const char *format, ...); void info(const char *format, ...); void debug(const char *format, ...); +#define die(...) \ + do { \ + err(__VA_ARGS__); \ + exit(EXIT_FAILURE); \ + } while (0) + extern int log_trace; void trace_init(int enable); #define trace(...) \ -- cgit v1.2.3