mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
Merge pull request #16979 from keszybz/return-log-debug
Fix 'return log_error()' and 'return log_warning()' patterns
This commit is contained in:
@@ -234,12 +234,12 @@ void log_assert_failed_return_realm(
|
||||
#define log_full_errno(level, error, ...) \
|
||||
log_full_errno_realm(LOG_REALM, (level), (error), __VA_ARGS__)
|
||||
|
||||
#define log_full(level, ...) log_full_errno((level), 0, __VA_ARGS__)
|
||||
#define log_full(level, ...) (void) log_full_errno((level), 0, __VA_ARGS__)
|
||||
|
||||
int log_emergency_level(void);
|
||||
|
||||
/* Normal logging */
|
||||
#define log_debug(...) log_full(LOG_DEBUG, __VA_ARGS__)
|
||||
#define log_debug(...) log_full_errno(LOG_DEBUG, 0, __VA_ARGS__)
|
||||
#define log_info(...) log_full(LOG_INFO, __VA_ARGS__)
|
||||
#define log_notice(...) log_full(LOG_NOTICE, __VA_ARGS__)
|
||||
#define log_warning(...) log_full(LOG_WARNING, __VA_ARGS__)
|
||||
|
||||
@@ -6240,8 +6240,13 @@ int exec_runtime_deserialize_one(Manager *m, const char *value, FDSet *fds) {
|
||||
|
||||
n = strcspn(v, " ");
|
||||
buf = strndupa(v, n);
|
||||
if (safe_atoi(buf, &fdpair[0]) < 0 || !fdset_contains(fds, fdpair[0]))
|
||||
return log_debug("Unable to process exec-runtime netns fd specification.");
|
||||
|
||||
r = safe_atoi(buf, &fdpair[0]);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Unable to parse exec-runtime specification netns-socket-0=%s: %m", buf);
|
||||
if (!fdset_contains(fds, fdpair[0]))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADF),
|
||||
"exec-runtime specification netns-socket-0= refers to unknown fd %d: %m", fdpair[0]);
|
||||
fdpair[0] = fdset_remove(fds, fdpair[0]);
|
||||
if (v[n] != ' ')
|
||||
goto finalize;
|
||||
@@ -6254,8 +6259,12 @@ int exec_runtime_deserialize_one(Manager *m, const char *value, FDSet *fds) {
|
||||
|
||||
n = strcspn(v, " ");
|
||||
buf = strndupa(v, n);
|
||||
if (safe_atoi(buf, &fdpair[1]) < 0 || !fdset_contains(fds, fdpair[1]))
|
||||
return log_debug("Unable to process exec-runtime netns fd specification.");
|
||||
r = safe_atoi(buf, &fdpair[1]);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Unable to parse exec-runtime specification netns-socket-1=%s: %m", buf);
|
||||
if (!fdset_contains(fds, fdpair[0]))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EBADF),
|
||||
"exec-runtime specification netns-socket-1= refers to unknown fd %d: %m", fdpair[1]);
|
||||
fdpair[1] = fdset_remove(fds, fdpair[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,14 +211,16 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to extract instance: %m");
|
||||
if (isempty(name))
|
||||
return log_error("Unit %s is missing the instance name.", *i);
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Unit %s is missing the instance name.", *i);
|
||||
|
||||
r = unit_name_template(*i, &template);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to extract template: %m");
|
||||
if (arg_template && !streq(arg_template, template))
|
||||
return log_error("Unit %s template %s does not match specified template %s.",
|
||||
*i, template, arg_template);
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Unit %s template %s does not match specified template %s.",
|
||||
*i, template, arg_template);
|
||||
} else {
|
||||
name = strdup(*i);
|
||||
if (!name)
|
||||
|
||||
@@ -349,7 +349,8 @@ static int determine_hostname(char **full_hostname, char **llmnr_hostname, char
|
||||
#if HAVE_LIBIDN2
|
||||
r = idn2_to_unicode_8z8z(label, &utf8, 0);
|
||||
if (r != IDN2_OK)
|
||||
return log_error("Failed to undo IDNA: %s", idn2_strerror(r));
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EUCLEAN),
|
||||
"Failed to undo IDNA: %s", idn2_strerror(r));
|
||||
assert(utf8_is_valid(utf8));
|
||||
|
||||
r = strlen(utf8);
|
||||
|
||||
@@ -160,14 +160,13 @@ static int lock_all_homes(void) {
|
||||
|
||||
r = sd_bus_call(bus, m, DEFAULT_TIMEOUT_USEC, &error, NULL);
|
||||
if (r < 0) {
|
||||
if (bus_error_is_unknown_service(&error))
|
||||
return log_debug("systemd-homed is not running, skipping locking of home directories.");
|
||||
if (!bus_error_is_unknown_service(&error))
|
||||
return log_error_errno(r, "Failed to lock home directories: %s", bus_error_message(&error, r));
|
||||
|
||||
return log_error_errno(r, "Failed to lock home directories: %s", bus_error_message(&error, r));
|
||||
return log_debug("systemd-homed is not running, locking of home directories skipped.");
|
||||
}
|
||||
|
||||
log_debug("Successfully requested for all home directories to be locked.");
|
||||
return 0;
|
||||
return log_debug("Successfully requested locking of all home directories.");
|
||||
}
|
||||
|
||||
static int execute(char **modes, char **states) {
|
||||
|
||||
@@ -2085,8 +2085,10 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (streq(key, "systemd.unit")) {
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
if (!unit_name_is_valid(value, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE))
|
||||
return log_warning("Unit name specified on %s= is not valid, ignoring: %s", key, value);
|
||||
if (!unit_name_is_valid(value, UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE)) {
|
||||
log_warning("Unit name specified on %s= is not valid, ignoring: %s", key, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return free_and_strdup_warn(ret, key);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
|
||||
|
||||
r = write_string_file_atomic_label_ts(path, message, ts);
|
||||
if (r == -EROFS)
|
||||
return log_debug("Cannot create \"%s\", file system is read-only.", path);
|
||||
return log_debug_errno(r, "Cannot create \"%s\", file system is read-only.", path);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write \"%s\": %m", path);
|
||||
return 0;
|
||||
|
||||
@@ -187,8 +187,10 @@ static int on_runlevel(Context *c) {
|
||||
runlevel = get_current_runlevel(c);
|
||||
if (runlevel < 0)
|
||||
return runlevel;
|
||||
if (runlevel == 0)
|
||||
return log_warning("Failed to get new runlevel, utmp update skipped.");
|
||||
if (runlevel == 0) {
|
||||
log_warning("Failed to get new runlevel, utmp update skipped.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (previous == runlevel)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user