From: Yu Watanabe Date: Thu, 15 Apr 2021 23:43:59 +0000 (+0900) Subject: core: make log_unit_xxx_errno() refuse zero errno X-Git-Tag: v249-rc1~399^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac513634961651f69885e0b93de2bf43abe5d886;p=thirdparty%2Fsystemd.git core: make log_unit_xxx_errno() refuse zero errno --- diff --git a/src/core/unit.h b/src/core/unit.h index 128122b8df7..88d1074aacb 100644 --- a/src/core/unit.h +++ b/src/core/unit.h @@ -919,7 +919,7 @@ int unit_thaw_vtable_common(Unit *u); /* Macros which append UNIT= or USER_UNIT= to the message */ -#define log_unit_full_errno(unit, level, error, ...) \ +#define log_unit_full_errno_zerook(unit, level, error, ...) \ ({ \ const Unit *_u = (unit); \ (log_get_max_level() < LOG_PRI(level)) ? -ERRNO_VALUE(error) : \ @@ -927,9 +927,16 @@ int unit_thaw_vtable_common(Unit *u); log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \ }) -#define log_unit_full(unit, level, ...) (void) log_unit_full_errno(unit, level, 0, __VA_ARGS__) +#define log_unit_full_errno(unit, level, error, ...) \ + ({ \ + int _error = (error); \ + ASSERT_NON_ZERO(_error); \ + log_unit_full_errno_zerook(unit, level, _error, ##__VA_ARGS__); \ + }) + +#define log_unit_full(unit, level, ...) (void) log_unit_full_errno_zerook(unit, level, 0, __VA_ARGS__) -#define log_unit_debug(unit, ...) log_unit_full_errno(unit, LOG_DEBUG, 0, __VA_ARGS__) +#define log_unit_debug(unit, ...) log_unit_full(unit, LOG_DEBUG, __VA_ARGS__) #define log_unit_info(unit, ...) log_unit_full(unit, LOG_INFO, __VA_ARGS__) #define log_unit_notice(unit, ...) log_unit_full(unit, LOG_NOTICE, __VA_ARGS__) #define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, __VA_ARGS__)