summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-device/device-util.h15
-rw-r--r--src/udev/udev-rules.c22
2 files changed, 27 insertions, 10 deletions
diff --git a/src/libsystemd/sd-device/device-util.h b/src/libsystemd/sd-device/device-util.h
index 0585c57bc9..e2adfe8132 100644
--- a/src/libsystemd/sd-device/device-util.h
+++ b/src/libsystemd/sd-device/device-util.h
@@ -45,20 +45,27 @@
device; \
device = sd_device_enumerator_get_subsystem_next(enumerator))
-#define log_device_full_errno(device, level, error, ...) \
+#define log_device_full_errno_zerook(device, level, error, ...) \
({ \
const char *_sysname = NULL; \
sd_device *_d = (device); \
- int _level = (level), _error = (error); \
+ int _level = (level), _e = (error); \
\
if (_d && _unlikely_(log_get_max_level() >= LOG_PRI(_level))) \
(void) sd_device_get_sysname(_d, &_sysname); \
- log_object_internal(_level, _error, PROJECT_FILE, __LINE__, __func__, \
+ log_object_internal(_level, _e, PROJECT_FILE, __LINE__, __func__, \
_sysname ? "DEVICE=" : NULL, _sysname, \
NULL, NULL, __VA_ARGS__); \
})
-#define log_device_full(device, level, ...) (void) log_device_full_errno(device, level, 0, __VA_ARGS__)
+#define log_device_full_errno(device, level, error, ...) \
+ ({ \
+ int _error = (error); \
+ ASSERT_NON_ZERO(_error); \
+ log_device_full_errno_zerook(device, level, _error, __VA_ARGS__); \
+ })
+
+#define log_device_full(device, level, ...) (void) log_device_full_errno_zerook(device, level, 0, __VA_ARGS__)
#define log_device_debug(device, ...) log_device_full(device, LOG_DEBUG, __VA_ARGS__)
#define log_device_info(device, ...) log_device_full(device, LOG_INFO, __VA_ARGS__)
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index ee7404b9f6..58e66bec84 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -184,19 +184,28 @@ struct UdevRules {
/*** Logging helpers ***/
-#define log_rule_full_errno(device, rules, level, error, fmt, ...) \
+#define log_rule_full_errno_zerook(device, rules, level, error, fmt, ...) \
({ \
UdevRules *_r = (rules); \
UdevRuleFile *_f = _r ? _r->current_file : NULL; \
UdevRuleLine *_l = _f ? _f->current_line : NULL; \
const char *_n = _f ? _f->filename : NULL; \
\
- log_device_full_errno(device, level, error, "%s:%u " fmt, \
- strna(_n), _l ? _l->line_number : 0, \
- ##__VA_ARGS__); \
+ log_device_full_errno_zerook( \
+ device, level, error, "%s:%u " fmt, \
+ strna(_n), _l ? _l->line_number : 0, \
+ ##__VA_ARGS__); \
+ })
+
+#define log_rule_full_errno(device, rules, level, error, fmt, ...) \
+ ({ \
+ int _error = (error); \
+ ASSERT_NON_ZERO(_error); \
+ log_rule_full_errno_zerook( \
+ device, rules, level, _error, fmt, ##__VA_ARGS__); \
})
-#define log_rule_full(device, rules, level, ...) (void) log_rule_full_errno(device, rules, level, 0, __VA_ARGS__)
+#define log_rule_full(device, rules, level, ...) (void) log_rule_full_errno_zerook(device, rules, level, 0, __VA_ARGS__)
#define log_rule_debug(device, rules, ...) log_rule_full(device, rules, LOG_DEBUG, __VA_ARGS__)
#define log_rule_info(device, rules, ...) log_rule_full(device, rules, LOG_INFO, __VA_ARGS__)
@@ -210,8 +219,9 @@ struct UdevRules {
#define log_rule_warning_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_WARNING, error, __VA_ARGS__)
#define log_rule_error_errno(device, rules, error, ...) log_rule_full_errno(device, rules, LOG_ERR, error, __VA_ARGS__)
+#define log_token_full_errno_zerook(rules, level, error, ...) log_rule_full_errno_zerook(NULL, rules, level, error, __VA_ARGS__)
#define log_token_full_errno(rules, level, error, ...) log_rule_full_errno(NULL, rules, level, error, __VA_ARGS__)
-#define log_token_full(rules, level, ...) (void) log_token_full_errno(rules, level, 0, __VA_ARGS__)
+#define log_token_full(rules, level, ...) (void) log_token_full_errno_zerook(rules, level, 0, __VA_ARGS__)
#define log_token_debug(rules, ...) log_token_full(rules, LOG_DEBUG, __VA_ARGS__)
#define log_token_info(rules, ...) log_token_full(rules, LOG_INFO, __VA_ARGS__)