Skip to content
Snippets Groups Projects
Commit b8990efd authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

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
parent 348e0245
No related branches found
No related tags found
No related merge requests found
......@@ -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__); \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment