From 8d1c9489ef373fc4d8de326b49086faa01185f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 15 Apr 2021 11:56:22 +0200 Subject: Assert zero is not passed to log_{device,rule,token}_*_errno() --- src/libsystemd/sd-device/device-util.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/libsystemd/sd-device/device-util.h') 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__) -- cgit v1.2.1