From b8990efd84c95b0eb15acee0c37a3399880e7a5c Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Wed, 9 Jun 2021 22:58:57 +0200 Subject: [PATCH] diag: introduce diag_set_detailed() diag_set() uses the current file and line as built-in macros. In the future patches there are going to appear a couple of new diag_set-like helpers which also would want to preserve the original file and line. For that they must be macros at least partially, like diag_set(), and pass their own file and line. Because they are going not to be very trivial and won't be implemented in the header. The patch introduces diag_set_detailed() which allows to pass custom file and line. Needed for #6027 --- src/lib/core/diag.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h index b07eea8381..fa85326adf 100644 --- a/src/lib/core/diag.h +++ b/src/lib/core/diag.h @@ -347,17 +347,20 @@ struct error * BuildSocketError(const char *file, unsigned line, const char *socketname, const char *format, ...); -#define diag_set(class, ...) do { \ +#define diag_set_detailed(file, line, class, ...) do { \ /* Preserve the original errno. */ \ int save_errno = errno; \ - say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ + say_debug("%s at %s:%i", #class, file, line); \ struct error *e; \ - e = Build##class(__FILE__, __LINE__, ##__VA_ARGS__); \ + e = Build##class(file, line, ##__VA_ARGS__); \ diag_set_error(diag_get(), e); \ /* Restore the errno which might have been reset. */ \ errno = save_errno; \ } while (0) +#define diag_set(...) \ + diag_set_detailed(__FILE__, __LINE__, __VA_ARGS__) + #define diag_add(class, ...) do { \ int save_errno = errno; \ say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \ -- GitLab