From 41c5738fe63670106247135d8785c541c0a010ec Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Fri, 4 Aug 2017 08:03:34 +0200 Subject: [PATCH] error_prints.h: add *_func_* printing macros In order to reduce boilerplate for the cases when __func__ is desired to be printed. * error_prints.h (error_func_msg, perror_func_msg, debug_func_msg, debug_func_perror_msg, error_func_msg_and_die, perror_func_msg_and_die): New macro definitions. --- error_prints.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/error_prints.h b/error_prints.h index 19ecb8f7..99c80389 100644 --- a/error_prints.h +++ b/error_prints.h @@ -62,4 +62,18 @@ void error_msg_and_die(const char *fmt, ...) perror_msg(__VA_ARGS__); \ } while (0) +/* Simple wrappers for providing function name in error messages */ +#define error_func_msg(fmt_, ...) \ + error_msg("%s: " fmt_, __func__, ##__VA_ARGS__) +#define perror_func_msg(fmt_, ...) \ + perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__) +#define debug_func_msg(fmt_, ...) \ + debug_msg("%s: " fmt_, __func__, ##__VA_ARGS__) +#define debug_func_perror_msg(fmt_, ...) \ + debug_perror_msg("%s: " fmt_, __func__, ##__VA_ARGS__) +#define error_func_msg_and_die(fmt_, ...) \ + error_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__) +#define perror_func_msg_and_die(fmt_, ...) \ + perror_msg_and_die("%s: " fmt_, __func__, ##__VA_ARGS__) + #endif /* !STRACE_ERROR_PRINTS_H */ -- 2.50.1