timedate: make log_unit_xxx_errno() refuse zero errno
This commit is contained in:
+24
-15
@@ -65,24 +65,33 @@ typedef struct Context {
|
||||
LIST_HEAD(UnitStatusInfo, units);
|
||||
} Context;
|
||||
|
||||
#define log_unit_full(unit, level, error, ...) \
|
||||
#define log_unit_full_errno_zerook(unit, level, error, ...) \
|
||||
({ \
|
||||
const UnitStatusInfo *_u = (unit); \
|
||||
log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, \
|
||||
"UNIT=", _u->name, NULL, NULL, ##__VA_ARGS__); \
|
||||
_u ? log_object_internal(level, error, PROJECT_FILE, __LINE__, __func__, "UNIT=", _u->name, NULL, NULL, ##__VA_ARGS__) : \
|
||||
log_internal(level, error, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
#define log_unit_debug(unit, ...) log_unit_full(unit, LOG_DEBUG, 0, ##__VA_ARGS__)
|
||||
#define log_unit_info(unit, ...) log_unit_full(unit, LOG_INFO, 0, ##__VA_ARGS__)
|
||||
#define log_unit_notice(unit, ...) log_unit_full(unit, LOG_NOTICE, 0, ##__VA_ARGS__)
|
||||
#define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, 0, ##__VA_ARGS__)
|
||||
#define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, 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_debug_errno(unit, error, ...) log_unit_full(unit, LOG_DEBUG, error, ##__VA_ARGS__)
|
||||
#define log_unit_info_errno(unit, error, ...) log_unit_full(unit, LOG_INFO, error, ##__VA_ARGS__)
|
||||
#define log_unit_notice_errno(unit, error, ...) log_unit_full(unit, LOG_NOTICE, error, ##__VA_ARGS__)
|
||||
#define log_unit_warning_errno(unit, error, ...) log_unit_full(unit, LOG_WARNING, error, ##__VA_ARGS__)
|
||||
#define log_unit_error_errno(unit, error, ...) log_unit_full(unit, LOG_ERR, 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(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__)
|
||||
#define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, ##__VA_ARGS__)
|
||||
|
||||
#define log_unit_debug_errno(unit, error, ...) log_unit_full_errno(unit, LOG_DEBUG, error, ##__VA_ARGS__)
|
||||
#define log_unit_info_errno(unit, error, ...) log_unit_full_errno(unit, LOG_INFO, error, ##__VA_ARGS__)
|
||||
#define log_unit_notice_errno(unit, error, ...) log_unit_full_errno(unit, LOG_NOTICE, error, ##__VA_ARGS__)
|
||||
#define log_unit_warning_errno(unit, error, ...) log_unit_full_errno(unit, LOG_WARNING, error, ##__VA_ARGS__)
|
||||
#define log_unit_error_errno(unit, error, ...) log_unit_full_errno(unit, LOG_ERR, error, ##__VA_ARGS__)
|
||||
|
||||
static void unit_status_info_clear(UnitStatusInfo *p) {
|
||||
assert(p);
|
||||
@@ -485,8 +494,8 @@ static int unit_start_or_stop(UnitStatusInfo *u, sd_bus *bus, sd_bus_error *erro
|
||||
"ss",
|
||||
u->name,
|
||||
"replace");
|
||||
log_unit_full(u, r < 0 ? LOG_WARNING : LOG_DEBUG, r,
|
||||
"%s unit: %m", start ? "Starting" : "Stopping");
|
||||
log_unit_full_errno_zerook(u, r < 0 ? LOG_WARNING : LOG_DEBUG, r,
|
||||
"%s unit: %m", start ? "Starting" : "Stopping");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user