[Tarantool-patches] [PATCH v2 01/11] diag: return created error from diag_set()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri Nov 12 02:54:20 MSK 2021
And from diag_add(). This will be helpful not to bother with
box_error_last() and diag_last_error(diag_get()) in the future
patch. It will change some attributes of a just created
ER_READONLY error to add more details.
Part of #5568
---
src/lib/core/diag.h | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/lib/core/diag.h b/src/lib/core/diag.h
index fa85326ad..d7d09f6fb 100644
--- a/src/lib/core/diag.h
+++ b/src/lib/core/diag.h
@@ -347,7 +347,7 @@ struct error *
BuildSocketError(const char *file, unsigned line, const char *socketname,
const char *format, ...);
-#define diag_set_detailed(file, line, class, ...) do { \
+#define diag_set_detailed(file, line, class, ...) ({ \
/* Preserve the original errno. */ \
int save_errno = errno; \
say_debug("%s at %s:%i", #class, file, line); \
@@ -356,19 +356,21 @@ BuildSocketError(const char *file, unsigned line, const char *socketname,
diag_set_error(diag_get(), e); \
/* Restore the errno which might have been reset. */ \
errno = save_errno; \
-} while (0)
+ e; \
+})
#define diag_set(...) \
diag_set_detailed(__FILE__, __LINE__, __VA_ARGS__)
-#define diag_add(class, ...) do { \
+#define diag_add(class, ...) ({ \
int save_errno = errno; \
say_debug("%s at %s:%i", #class, __FILE__, __LINE__); \
struct error *e; \
e = Build##class(__FILE__, __LINE__, ##__VA_ARGS__); \
diag_add_error(diag_get(), e); \
errno = save_errno; \
-} while (0)
+ e; \
+})
#if defined(__cplusplus)
} /* extern "C" */
--
2.24.3 (Apple Git-128)
More information about the Tarantool-patches
mailing list