chiark / gitweb /
log: change log_xyz_errno() calls to always return the negative error
[elogind.git] / src / shared / log.h
index 3180dfd638c7c02430570e03bbf0c3bf6ee0f7c8..a6b933605d3b17ba84ba8b55130172be5714ba52 100644 (file)
@@ -155,11 +155,13 @@ void log_assert_failed_return(
                 const char *func);
 
 /* Logging with level */
-#define log_full_errno(level, error, ...)                               \
-        do {                                                            \
-                if (log_get_max_level() >= (level))                     \
-                        log_internal((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
-        } while (false)
+#define log_full_errno(level, error, ...)                                         \
+        ({                                                                        \
+                int _l = (level), _e = (error);                                   \
+                (log_get_max_level() >= _l)                                       \
+                ? log_internal(_l, _e, __FILE__, __LINE__, __func__, __VA_ARGS__) \
+                : -abs(_e); \
+        })
 
 #define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)