1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

Merge pull request #9817 from yuwata/shorten-error-logging

tree-wide: Shorten error logging and several code cleanups
This commit is contained in:
Lennart Poettering 2018-08-07 10:44:44 +02:00 committed by GitHub
commit 91f4424012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 227 additions and 372 deletions

View File

@ -162,10 +162,8 @@ static int bus_get_uint64_property(sd_bus *bus, const char *path, const char *in
&error, &error,
't', val); 't', val);
if (r < 0) { if (r < 0)
log_error("Failed to parse reply: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to parse reply: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -187,10 +185,8 @@ static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char
property, property,
&error, &error,
strv); strv);
if (r < 0) { if (r < 0)
log_error("Failed to get unit property %s: %s", property, bus_error_message(&error, -r)); return log_error_errno(r, "Failed to get unit property %s: %s", property, bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -405,10 +401,8 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
"ListUnits", "ListUnits",
&error, &reply, &error, &reply,
NULL); NULL);
if (r < 0) { if (r < 0)
log_error("Failed to list units: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)"); r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)");
if (r < 0) if (r < 0)
@ -1031,10 +1025,8 @@ static int list_dependencies(sd_bus *bus, const char *name) {
&error, &error,
&reply, &reply,
"s"); "s");
if (r < 0) { if (r < 0)
log_error("Failed to get ID: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to get ID: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "s", &id); r = sd_bus_message_read(reply, "s", &id);
if (r < 0) if (r < 0)
@ -1293,10 +1285,8 @@ static int dot(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
""); "");
if (r < 0) { if (r < 0)
log_error("Failed to list units: %s", bus_error_message(&error, -r)); log_error_errno(r, "Failed to list units: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)"); r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssssssouso)");
if (r < 0) if (r < 0)

View File

@ -1298,9 +1298,9 @@ int verify_run_space_and_log(const char *message) {
r = verify_run_space(message, &error); r = verify_run_space(message, &error);
if (r < 0) if (r < 0)
log_error_errno(r, "%s", bus_error_message(&error, r)); return log_error_errno(r, "%s", bus_error_message(&error, r));
return r; return 0;
} }
static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) {

View File

@ -1584,8 +1584,7 @@ static int mount_setup_unit(
return 0; return 0;
fail: fail:
log_warning_errno(r, "Failed to set up mount unit: %m"); return log_warning_errno(r, "Failed to set up mount unit: %m");
return r;
} }
static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) { static int mount_load_proc_self_mountinfo(Manager *m, bool set_flags) {

View File

@ -695,10 +695,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
if (r >= 0) if (r >= 0)
break; break;
if (r != -EAGAIN) { if (r != -EAGAIN)
log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error_message(e, r)); return log_warning_errno(r, "Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error_message(e, r));
return r;
}
/* Let's see if the resulting transaction ordering /* Let's see if the resulting transaction ordering
* graph is still cyclic... */ * graph is still cyclic... */
@ -712,10 +710,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
if (r >= 0) if (r >= 0)
break; break;
if (r != -EAGAIN) { if (r != -EAGAIN)
log_warning("Requested transaction contains unmergeable jobs: %s", bus_error_message(e, r)); return log_warning_errno(r, "Requested transaction contains unmergeable jobs: %s", bus_error_message(e, r));
return r;
}
/* Seventh step: an entry got dropped, let's garbage /* Seventh step: an entry got dropped, let's garbage
* collect its dependencies. */ * collect its dependencies. */
@ -731,10 +727,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error
/* Ninth step: check whether we can actually apply this */ /* Ninth step: check whether we can actually apply this */
r = transaction_is_destructive(tr, mode, e); r = transaction_is_destructive(tr, mode, e);
if (r < 0) { if (r < 0)
log_notice("Requested transaction contradicts existing jobs: %s", bus_error_message(e, r)); return log_notice_errno(r, "Requested transaction contradicts existing jobs: %s", bus_error_message(e, r));
return r;
}
/* Tenth step: apply changes */ /* Tenth step: apply changes */
r = transaction_apply(tr, m, mode); r = transaction_apply(tr, m, mode);

View File

@ -227,8 +227,9 @@ static int set_simple_string(sd_bus *bus, const char *method, const char *value)
&error, NULL, &error, NULL,
"sb", value, arg_ask_password); "sb", value, arg_ask_password);
if (r < 0) if (r < 0)
log_error("Could not set property: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not set property: %s", bus_error_message(&error, -r));
return r;
return 0;
} }
static int set_hostname(int argc, char **argv, void *userdata) { static int set_hostname(int argc, char **argv, void *userdata) {

View File

@ -81,7 +81,7 @@ static const char *translate_runlevel(int runlevel, bool *isolate) {
return NULL; return NULL;
} }
static void change_runlevel(Server *s, int runlevel) { static int change_runlevel(Server *s, int runlevel) {
const char *target; const char *target;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *mode; const char *mode;
@ -93,7 +93,7 @@ static void change_runlevel(Server *s, int runlevel) {
target = translate_runlevel(runlevel, &isolate); target = translate_runlevel(runlevel, &isolate);
if (!target) { if (!target) {
log_warning("Got request for unknown runlevel %c, ignoring.", runlevel); log_warning("Got request for unknown runlevel %c, ignoring.", runlevel);
return; return 0;
} }
if (isolate) if (isolate)
@ -112,10 +112,10 @@ static void change_runlevel(Server *s, int runlevel) {
&error, &error,
NULL, NULL,
"ss", target, mode); "ss", target, mode);
if (r < 0) { if (r < 0)
log_error("Failed to change runlevel: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to change runlevel: %s", bus_error_message(&error, -r));
return;
} return 0;
} }
static void request_process(Server *s, const struct init_request *req) { static void request_process(Server *s, const struct init_request *req) {
@ -156,7 +156,7 @@ static void request_process(Server *s, const struct init_request *req) {
break; break;
default: default:
change_runlevel(s, req->runlevel); (void) change_runlevel(s, req->runlevel);
} }
return; return;

View File

@ -128,10 +128,8 @@ static int client(struct context *c) {
return log_error_errno(r, "Failed to allocate method call: %m"); return log_error_errno(r, "Failed to allocate method call: %m");
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to issue method call: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }

View File

@ -515,10 +515,8 @@ int device_read_uevent_file(sd_device *device) {
else if (r == -ENOENT) else if (r == -ENOENT)
/* some devices may not have uevent files, see set_syspath() */ /* some devices may not have uevent files, see set_syspath() */
return 0; return 0;
else if (r < 0) { else if (r < 0)
log_debug_errno(r, "sd-device: failed to read uevent file '%s': %m", path); return log_debug_errno(r, "sd-device: failed to read uevent file '%s': %m", path);
return r;
}
for (i = 0; i < uevent_len; i++) for (i = 0; i < uevent_len; i++)
switch (state) { switch (state) {

View File

@ -184,10 +184,8 @@ static int set_locale(int argc, char **argv, void *userdata) {
return bus_log_create_error(r); return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, NULL); r = sd_bus_call(bus, m, 0, &error, NULL);
if (r < 0) { if (r < 0)
log_error("Failed to issue method call: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -229,9 +227,9 @@ static int set_vconsole_keymap(int argc, char **argv, void *userdata) {
NULL, NULL,
"ssbb", map, toggle_map, arg_convert, arg_ask_password); "ssbb", map, toggle_map, arg_convert, arg_ask_password);
if (r < 0) if (r < 0)
log_error("Failed to set keymap: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to set keymap: %s", bus_error_message(&error, -r));
return r; return 0;
} }
static int list_vconsole_keymaps(int argc, char **argv, void *userdata) { static int list_vconsole_keymaps(int argc, char **argv, void *userdata) {
@ -273,9 +271,9 @@ static int set_x11_keymap(int argc, char **argv, void *userdata) {
"ssssbb", layout, model, variant, options, "ssssbb", layout, model, variant, options,
arg_convert, arg_ask_password); arg_convert, arg_ask_password);
if (r < 0) if (r < 0)
log_error("Failed to set keymap: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to set keymap: %s", bus_error_message(&error, -r));
return r; return 0;
} }
static int list_x11_keymaps(int argc, char **argv, void *userdata) { static int list_x11_keymaps(int argc, char **argv, void *userdata) {

View File

@ -104,8 +104,9 @@ static int vconsole_reload(sd_bus *bus) {
"ss", "systemd-vconsole-setup.service", "replace"); "ss", "systemd-vconsole-setup.service", "replace");
if (r < 0) if (r < 0)
log_error("Failed to issue method call: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
return r;
return 0;
} }
static int vconsole_convert_to_x11_and_emit(Context *c, sd_bus_message *m) { static int vconsole_convert_to_x11_and_emit(Context *c, sd_bus_message *m) {

View File

@ -856,10 +856,9 @@ static int show_session(int argc, char *argv[], void *userdata) {
session = getenv("XDG_SESSION_ID"); session = getenv("XDG_SESSION_ID");
if (session) { if (session) {
r = get_session_path(bus, session, &error, &path); r = get_session_path(bus, session, &error, &path);
if (r < 0) { if (r < 0)
log_error("Failed to get session path: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get session path: %s", bus_error_message(&error, r));
return r;
}
p = path; p = path;
} }
@ -868,10 +867,8 @@ static int show_session(int argc, char *argv[], void *userdata) {
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
r = get_session_path(bus, argv[i], &error, &path); r = get_session_path(bus, argv[i], &error, &path);
if (r < 0) { if (r < 0)
log_error("Failed to get session path: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get session path: %s", bus_error_message(&error, r));
return r;
}
if (properties) if (properties)
r = show_properties(bus, path, &new_line); r = show_properties(bus, path, &new_line);
@ -924,10 +921,8 @@ static int show_user(int argc, char *argv[], void *userdata) {
"GetUser", "GetUser",
&error, &reply, &error, &reply,
"u", (uint32_t) uid); "u", (uint32_t) uid);
if (r < 0) { if (r < 0)
log_error("Failed to get user: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get user: %s", bus_error_message(&error, r));
return r;
}
r = sd_bus_message_read(reply, "o", &path); r = sd_bus_message_read(reply, "o", &path);
if (r < 0) if (r < 0)
@ -979,10 +974,8 @@ static int show_seat(int argc, char *argv[], void *userdata) {
"GetSeat", "GetSeat",
&error, &reply, &error, &reply,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Failed to get seat: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get seat: %s", bus_error_message(&error, r));
return r;
}
r = sd_bus_message_read(reply, "o", &path); r = sd_bus_message_read(reply, "o", &path);
if (r < 0) if (r < 0)
@ -1036,10 +1029,8 @@ static int activate(int argc, char *argv[], void *userdata) {
"ActivateSession", "ActivateSession",
&error, NULL, &error, NULL,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Failed to issue method call: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to issue method call: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1068,10 +1059,8 @@ static int kill_session(int argc, char *argv[], void *userdata) {
"KillSession", "KillSession",
&error, NULL, &error, NULL,
"ssi", argv[i], arg_kill_who, arg_signal); "ssi", argv[i], arg_kill_who, arg_signal);
if (r < 0) { if (r < 0)
log_error("Could not kill session: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not kill session: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1121,10 +1110,8 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
"SetUserLinger", "SetUserLinger",
&error, NULL, &error, NULL,
"ubb", (uint32_t) uid, b, true); "ubb", (uint32_t) uid, b, true);
if (r < 0) { if (r < 0)
log_error("Could not enable linger: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not enable linger: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1155,10 +1142,8 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
"TerminateUser", "TerminateUser",
&error, NULL, &error, NULL,
"u", (uint32_t) uid); "u", (uint32_t) uid);
if (r < 0) { if (r < 0)
log_error("Could not terminate user: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate user: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1192,10 +1177,8 @@ static int kill_user(int argc, char *argv[], void *userdata) {
"KillUser", "KillUser",
&error, NULL, &error, NULL,
"ui", (uint32_t) uid, arg_signal); "ui", (uint32_t) uid, arg_signal);
if (r < 0) { if (r < 0)
log_error("Could not kill user: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not kill user: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1222,10 +1205,8 @@ static int attach(int argc, char *argv[], void *userdata) {
&error, NULL, &error, NULL,
"ssb", argv[1], argv[i], true); "ssb", argv[1], argv[i], true);
if (r < 0) { if (r < 0)
log_error("Could not attach device: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not attach device: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1250,9 +1231,9 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
&error, NULL, &error, NULL,
"b", true); "b", true);
if (r < 0) if (r < 0)
log_error("Could not flush devices: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not flush devices: %s", bus_error_message(&error, -r));
return r; return 0;
} }
static int lock_sessions(int argc, char *argv[], void *userdata) { static int lock_sessions(int argc, char *argv[], void *userdata) {
@ -1274,9 +1255,9 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
&error, NULL, &error, NULL,
NULL); NULL);
if (r < 0) if (r < 0)
log_error("Could not lock sessions: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not lock sessions: %s", bus_error_message(&error, -r));
return r; return 0;
} }
static int terminate_seat(int argc, char *argv[], void *userdata) { static int terminate_seat(int argc, char *argv[], void *userdata) {
@ -1299,10 +1280,8 @@ static int terminate_seat(int argc, char *argv[], void *userdata) {
"TerminateSeat", "TerminateSeat",
&error, NULL, &error, NULL,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Could not terminate seat: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate seat: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;

View File

@ -152,10 +152,8 @@ int manager_handle_action(
log_info("%s", message_table[handle]); log_info("%s", message_table[handle]);
r = bus_manager_shutdown_or_sleep_now_or_later(m, target, inhibit_operation, &error); r = bus_manager_shutdown_or_sleep_now_or_later(m, target, inhibit_operation, &error);
if (r < 0) { if (r < 0)
log_error("Failed to execute operation: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r));
return r;
}
return 1; return 1;
} }

View File

@ -522,9 +522,9 @@ int manager_spawn_autovt(Manager *m, unsigned int vtnr) {
NULL, NULL,
"ss", name, "fail"); "ss", name, "fail");
if (r < 0) if (r < 0)
log_error("Failed to start %s: %s", name, bus_error_message(&error, r)); return log_error_errno(r, "Failed to start %s: %s", name, bus_error_message(&error, r));
return r; return 0;
} }
static bool manager_is_docked(Manager *m) { static bool manager_is_docked(Manager *m) {

View File

@ -547,7 +547,8 @@ static int session_start_scope(Session *s, sd_bus_message *properties) {
if (!s->scope) { if (!s->scope) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char *scope, *job = NULL; _cleanup_free_ char *scope = NULL;
char *job = NULL;
const char *description; const char *description;
scope = strjoin("session-", s->id, ".scope"); scope = strjoin("session-", s->id, ".scope");
@ -567,16 +568,12 @@ static int session_start_scope(Session *s, sd_bus_message *properties) {
properties, properties,
&error, &error,
&job); &job);
if (r < 0) { if (r < 0)
log_error_errno(r, "Failed to start session scope %s: %s", scope, bus_error_message(&error, r)); return log_error_errno(r, "Failed to start session scope %s: %s", scope, bus_error_message(&error, r));
free(scope);
return r;
} else {
s->scope = scope;
free(s->scope_job);
s->scope_job = job; s->scope = TAKE_PTR(scope);
} free_and_replace(s->scope_job, job);
} }
if (s->scope) if (s->scope)

View File

@ -391,15 +391,10 @@ static int user_stop_slice(User *u) {
assert(u); assert(u);
r = manager_stop_unit(u->manager, u->slice, &error, &job); r = manager_stop_unit(u->manager, u->slice, &error, &job);
if (r < 0) { if (r < 0)
log_error("Failed to stop user slice: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to stop user slice: %s", bus_error_message(&error, r));
return r;
}
free(u->slice_job); return free_and_replace(u->slice_job, job);
u->slice_job = job;
return r;
} }
static int user_stop_service(User *u) { static int user_stop_service(User *u) {
@ -410,13 +405,10 @@ static int user_stop_service(User *u) {
assert(u); assert(u);
r = manager_stop_unit(u->manager, u->service, &error, &job); r = manager_stop_unit(u->manager, u->service, &error, &job);
if (r < 0) { if (r < 0)
log_error("Failed to stop user service: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to stop user service: %s", bus_error_message(&error, r));
return r;
}
free_and_replace(u->service_job, job); return free_and_replace(u->service_job, job);
return r;
} }
int user_stop(User *u, bool force) { int user_stop(User *u, bool force) {

View File

@ -328,14 +328,13 @@ int machine_load(Machine *m) {
} }
static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_error *error) { static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_error *error) {
int r = 0;
assert(m); assert(m);
assert(m->class != MACHINE_HOST); assert(m->class != MACHINE_HOST);
if (!m->unit) { if (!m->unit) {
_cleanup_free_ char *escaped = NULL; _cleanup_free_ char *escaped = NULL, *scope = NULL;
char *scope, *description, *job = NULL; char *description, *job = NULL;
int r;
escaped = unit_name_escape(m->name); escaped = unit_name_escape(m->name);
if (!escaped) if (!escaped)
@ -348,22 +347,17 @@ static int machine_start_scope(Machine *m, sd_bus_message *properties, sd_bus_er
description = strjoina(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name); description = strjoina(m->class == MACHINE_VM ? "Virtual Machine " : "Container ", m->name);
r = manager_start_scope(m->manager, scope, m->leader, SPECIAL_MACHINE_SLICE, description, properties, error, &job); r = manager_start_scope(m->manager, scope, m->leader, SPECIAL_MACHINE_SLICE, description, properties, error, &job);
if (r < 0) { if (r < 0)
log_error("Failed to start machine scope: %s", bus_error_message(error, r)); return log_error_errno(r, "Failed to start machine scope: %s", bus_error_message(error, r));
free(scope);
return r;
} else {
m->unit = scope;
free(m->scope_job); m->unit = TAKE_PTR(scope);
m->scope_job = job; free_and_replace(m->scope_job, job);
}
} }
if (m->unit) if (m->unit)
hashmap_put(m->manager->machine_units, m->unit, m); hashmap_put(m->manager->machine_units, m->unit, m);
return r; return 0;
} }
int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) { int machine_start(Machine *m, sd_bus_message *properties, sd_bus_error *error) {
@ -417,15 +411,10 @@ static int machine_stop_scope(Machine *m) {
return 0; return 0;
r = manager_stop_unit(m->manager, m->unit, &error, &job); r = manager_stop_unit(m->manager, m->unit, &error, &job);
if (r < 0) { if (r < 0)
log_error("Failed to stop machine scope: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to stop machine scope: %s", bus_error_message(&error, r));
return r;
}
free(m->scope_job); return free_and_replace(m->scope_job, job);
m->scope_job = job;
return 0;
} }
int machine_stop(Machine *m) { int machine_stop(Machine *m) {

View File

@ -773,10 +773,8 @@ static int show_machine(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Could not get path to machine: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get path to machine: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "o", &path); r = sd_bus_message_read(reply, "o", &path);
if (r < 0) if (r < 0)
@ -1118,10 +1116,8 @@ static int show_image(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Could not get path to image: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get path to image: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "o", &path); r = sd_bus_message_read(reply, "o", &path);
if (r < 0) if (r < 0)
@ -1158,10 +1154,8 @@ static int kill_machine(int argc, char *argv[], void *userdata) {
&error, &error,
NULL, NULL,
"ssi", argv[i], arg_kill_who, arg_signal); "ssi", argv[i], arg_kill_who, arg_signal);
if (r < 0) { if (r < 0)
log_error("Could not kill machine: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not kill machine: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1200,10 +1194,8 @@ static int terminate_machine(int argc, char *argv[], void *userdata) {
&error, &error,
NULL, NULL,
"s", argv[i]); "s", argv[i]);
if (r < 0) { if (r < 0)
log_error("Could not terminate machine: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not terminate machine: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;
@ -1285,10 +1277,8 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
argv[3], argv[3],
arg_read_only, arg_read_only,
arg_mkdir); arg_mkdir);
if (r < 0) { if (r < 0)
log_error("Failed to bind mount: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to bind mount: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -1459,10 +1449,8 @@ static int login_machine(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
"s", machine); "s", machine);
if (r < 0) { if (r < 0)
log_error("Failed to get login PTY: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to get login PTY: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "hs", &master, NULL); r = sd_bus_message_read(reply, "hs", &master, NULL);
if (r < 0) if (r < 0)
@ -1613,10 +1601,8 @@ static int rename_image(int argc, char *argv[], void *userdata) {
&error, &error,
NULL, NULL,
"ss", argv[1], argv[2]); "ss", argv[1], argv[2]);
if (r < 0) { if (r < 0)
log_error("Could not rename image: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not rename image: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -1679,10 +1665,8 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
&error, &error,
NULL, NULL,
"sb", argv[1], b); "sb", argv[1], b);
if (r < 0) { if (r < 0)
log_error("Could not mark image read-only: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, -r));
return r;
}
return 0; return 0;
} }
@ -1771,10 +1755,8 @@ static int start_machine(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
"ss", unit, "fail"); "ss", unit, "fail");
if (r < 0) { if (r < 0)
log_error("Failed to start unit: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to start unit: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "o", &object); r = sd_bus_message_read(reply, "o", &object);
if (r < 0) if (r < 0)
@ -1853,10 +1835,8 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
return bus_log_create_error(r); return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to enable or disable unit: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to enable or disable unit: %s", bus_error_message(&error, -r));
return r;
}
if (streq(argv[0], "enable")) { if (streq(argv[0], "enable")) {
r = sd_bus_message_read(reply, "b", NULL); r = sd_bus_message_read(reply, "b", NULL);
@ -1991,10 +1971,8 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
return log_error_errno(r, "Failed to request match: %m"); return log_error_errno(r, "Failed to request match: %m");
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to transfer image: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to transfer image: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "uo", &id, &path); r = sd_bus_message_read(reply, "uo", &id, &path);
if (r < 0) if (r < 0)
@ -2428,10 +2406,8 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
&error, &error,
&reply, &reply,
NULL); NULL);
if (r < 0) { if (r < 0)
log_error("Could not get transfers: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not get transfers: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_enter_container(reply, 'a', "(usssdo)"); r = sd_bus_message_enter_container(reply, 'a', "(usssdo)");
if (r < 0) if (r < 0)
@ -2526,10 +2502,8 @@ static int cancel_transfer(int argc, char *argv[], void *userdata) {
&error, &error,
NULL, NULL,
"u", id); "u", id);
if (r < 0) { if (r < 0)
log_error("Could not cancel transfer: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Could not cancel transfer: %s", bus_error_message(&error, -r));
return r;
}
} }
return 0; return 0;

View File

@ -503,10 +503,8 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (!link->network->dhcp_critical) { if (!link->network->dhcp_critical) {
r = sd_dhcp_lease_get_lifetime(link->dhcp_lease, &lifetime); r = sd_dhcp_lease_get_lifetime(link->dhcp_lease, &lifetime);
if (r < 0) { if (r < 0)
log_link_warning_errno(link, r, "DHCP error: no lifetime: %m"); return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m");
return r;
}
} }
r = dhcp4_update_address(link, &address, &netmask, lifetime); r = dhcp4_update_address(link, &address, &netmask, lifetime);

View File

@ -26,10 +26,8 @@ static int ipv4ll_address_lost(Link *link) {
log_link_debug(link, "IPv4 link-local release %u.%u.%u.%u", ADDRESS_FMT_VAL(addr)); log_link_debug(link, "IPv4 link-local release %u.%u.%u.%u", ADDRESS_FMT_VAL(addr));
r = address_new(&address); r = address_new(&address);
if (r < 0) { if (r < 0)
log_link_error_errno(link, r, "Could not allocate address: %m"); return log_link_error_errno(link, r, "Could not allocate address: %m");
return r;
}
address->family = AF_INET; address->family = AF_INET;
address->in_addr.in = addr; address->in_addr.in = addr;
@ -39,10 +37,8 @@ static int ipv4ll_address_lost(Link *link) {
address_remove(address, link, link_address_remove_handler); address_remove(address, link, link_address_remove_handler);
r = route_new(&route); r = route_new(&route);
if (r < 0) { if (r < 0)
log_link_error_errno(link, r, "Could not allocate route: %m"); return log_link_error_errno(link, r, "Could not allocate route: %m");
return r;
}
route->family = AF_INET; route->family = AF_INET;
route->scope = RT_SCOPE_LINK; route->scope = RT_SCOPE_LINK;

View File

@ -1175,10 +1175,8 @@ static int link_enter_set_addresses(Link *link) {
} }
r = sd_dhcp_server_set_emit_router(link->dhcp_server, link->network->dhcp_server_emit_router); r = sd_dhcp_server_set_emit_router(link->dhcp_server, link->network->dhcp_server_emit_router);
if (r < 0) { if (r < 0)
log_link_warning_errno(link, r, "Failed to set router emission for DHCP server: %m"); return log_link_warning_errno(link, r, "Failed to set router emission for DHCP server: %m");
return r;
}
if (link->network->dhcp_server_emit_timezone) { if (link->network->dhcp_server_emit_timezone) {
_cleanup_free_ char *buffer = NULL; _cleanup_free_ char *buffer = NULL;
@ -3386,10 +3384,8 @@ int link_update(Link *link, sd_netlink_message *m) {
if (link->dhcp_client) { if (link->dhcp_client) {
r = sd_dhcp_client_set_mtu(link->dhcp_client, r = sd_dhcp_client_set_mtu(link->dhcp_client,
link->mtu); link->mtu);
if (r < 0) { if (r < 0)
log_link_warning_errno(link, r, "Could not update MTU in DHCP client: %m"); return log_link_warning_errno(link, r, "Could not update MTU in DHCP client: %m");
return r;
}
} }
if (link->radv) { if (link->radv) {

View File

@ -195,10 +195,8 @@ int register_machine(
r = sd_bus_call(bus, m, 0, &error, NULL); r = sd_bus_call(bus, m, 0, &error, NULL);
} }
if (r < 0) { if (r < 0)
log_error("Failed to register machine: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to register machine: %s", bus_error_message(&error, r));
return r;
}
return 0; return 0;
} }
@ -242,10 +240,8 @@ int terminate_machine(sd_bus *bus, pid_t pid) {
&error, &error,
NULL, NULL,
NULL); NULL);
if (r < 0) { if (r < 0)
log_debug("Failed to terminate machine: %s", bus_error_message(&error, r)); log_debug("Failed to terminate machine: %s", bus_error_message(&error, r));
return 0;
}
return 0; return 0;
} }
@ -336,10 +332,8 @@ int allocate_scope(
return bus_log_create_error(r); return bus_log_create_error(r);
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to allocate scope: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to allocate scope: %s", bus_error_message(&error, r));
return r;
}
r = sd_bus_message_read(reply, "o", &object); r = sd_bus_message_read(reply, "o", &object);
if (r < 0) if (r < 0)

View File

@ -324,10 +324,8 @@ static int resolve_address(sd_bus *bus, int family, const union in_addr_union *a
ts = now(CLOCK_MONOTONIC); ts = now(CLOCK_MONOTONIC);
r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply); r = sd_bus_call(bus, req, SD_RESOLVED_QUERY_TIMEOUT_USEC, &error, &reply);
if (r < 0) { if (r < 0)
log_error("%s: resolve call failed: %s", pretty, bus_error_message(&error, r)); return log_error_errno(r, "%s: resolve call failed: %s", pretty, bus_error_message(&error, r));
return r;
}
ts = now(CLOCK_MONOTONIC) - ts; ts = now(CLOCK_MONOTONIC) - ts;
@ -1370,21 +1368,27 @@ static int status_print_strv_ifindex(int ifindex, const char *ifname, char **p)
return 0; return 0;
} }
struct link_info {
uint64_t scopes_mask;
const char *llmnr;
const char *mdns;
const char *dns_over_tls;
const char *dnssec;
char *current_dns;
char **dns;
char **domains;
char **ntas;
bool dnssec_supported;
};
static void link_info_clear(struct link_info *p) {
free(p->current_dns);
strv_free(p->dns);
strv_free(p->domains);
strv_free(p->ntas);
}
static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode mode, bool *empty_line) { static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode mode, bool *empty_line) {
struct link_info {
uint64_t scopes_mask;
const char *llmnr;
const char *mdns;
const char *dns_over_tls;
const char *dnssec;
char *current_dns;
char **dns;
char **domains;
char **ntas;
bool dnssec_supported;
} link_info = {};
static const struct bus_properties_map property_map[] = { static const struct bus_properties_map property_map[] = {
{ "ScopesMask", "t", NULL, offsetof(struct link_info, scopes_mask) }, { "ScopesMask", "t", NULL, offsetof(struct link_info, scopes_mask) },
{ "DNS", "a(iay)", map_link_dns_servers, offsetof(struct link_info, dns) }, { "DNS", "a(iay)", map_link_dns_servers, offsetof(struct link_info, dns) },
@ -1398,9 +1402,9 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
{ "DNSSECSupported", "b", NULL, offsetof(struct link_info, dnssec_supported) }, { "DNSSECSupported", "b", NULL, offsetof(struct link_info, dnssec_supported) },
{} {}
}; };
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(link_info_clear) struct link_info link_info = {};
_cleanup_free_ char *ifi = NULL, *p = NULL; _cleanup_free_ char *ifi = NULL, *p = NULL;
char ifname[IF_NAMESIZE] = ""; char ifname[IF_NAMESIZE] = "";
char **i; char **i;
@ -1431,35 +1435,26 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
&error, &error,
&m, &m,
&link_info); &link_info);
if (r < 0) { if (r < 0)
log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r)); return log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r));
goto finish;
}
(void) pager_open(arg_no_pager, false); (void) pager_open(arg_no_pager, false);
if (mode == STATUS_DNS) { if (mode == STATUS_DNS)
r = status_print_strv_ifindex(ifindex, name, link_info.dns); return status_print_strv_ifindex(ifindex, name, link_info.dns);
goto finish;
}
if (mode == STATUS_DOMAIN) { if (mode == STATUS_DOMAIN)
r = status_print_strv_ifindex(ifindex, name, link_info.domains); return status_print_strv_ifindex(ifindex, name, link_info.domains);
goto finish;
}
if (mode == STATUS_NTA) { if (mode == STATUS_NTA)
r = status_print_strv_ifindex(ifindex, name, link_info.ntas); return status_print_strv_ifindex(ifindex, name, link_info.ntas);
goto finish;
}
if (mode == STATUS_LLMNR) { if (mode == STATUS_LLMNR) {
printf("%sLink %i (%s)%s: %s\n", printf("%sLink %i (%s)%s: %s\n",
ansi_highlight(), ifindex, name, ansi_normal(), ansi_highlight(), ifindex, name, ansi_normal(),
strna(link_info.llmnr)); strna(link_info.llmnr));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_MDNS) { if (mode == STATUS_MDNS) {
@ -1467,8 +1462,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
ansi_highlight(), ifindex, name, ansi_normal(), ansi_highlight(), ifindex, name, ansi_normal(),
strna(link_info.mdns)); strna(link_info.mdns));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_PRIVATE) { if (mode == STATUS_PRIVATE) {
@ -1476,8 +1470,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
ansi_highlight(), ifindex, name, ansi_normal(), ansi_highlight(), ifindex, name, ansi_normal(),
strna(link_info.dns_over_tls)); strna(link_info.dns_over_tls));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_DNSSEC) { if (mode == STATUS_DNSSEC) {
@ -1485,8 +1478,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
ansi_highlight(), ifindex, name, ansi_normal(), ansi_highlight(), ifindex, name, ansi_normal(),
strna(link_info.dnssec)); strna(link_info.dnssec));
r = 0; return 0;
goto finish;
} }
if (empty_line && *empty_line) if (empty_line && *empty_line)
@ -1540,14 +1532,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
if (empty_line) if (empty_line)
*empty_line = true; *empty_line = true;
r = 0; return 0;
finish:
free(link_info.current_dns);
strv_free(link_info.dns);
strv_free(link_info.domains);
strv_free(link_info.ntas);
return r;
} }
static int map_global_dns_servers(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { static int map_global_dns_servers(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
@ -1644,21 +1629,28 @@ static int status_print_strv_global(char **p) {
return 0; return 0;
} }
struct global_info {
char *current_dns;
char **dns;
char **fallback_dns;
char **domains;
char **ntas;
const char *llmnr;
const char *mdns;
const char *dns_over_tls;
const char *dnssec;
bool dnssec_supported;
};
static void global_info_clear(struct global_info *p) {
free(p->current_dns);
strv_free(p->dns);
strv_free(p->fallback_dns);
strv_free(p->domains);
strv_free(p->ntas);
}
static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) { static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
struct global_info {
char *current_dns;
char **dns;
char **fallback_dns;
char **domains;
char **ntas;
const char *llmnr;
const char *mdns;
const char *dns_over_tls;
const char *dnssec;
bool dnssec_supported;
} global_info = {};
static const struct bus_properties_map property_map[] = { static const struct bus_properties_map property_map[] = {
{ "DNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, dns) }, { "DNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, dns) },
{ "FallbackDNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, fallback_dns) }, { "FallbackDNS", "a(iiay)", map_global_dns_servers, offsetof(struct global_info, fallback_dns) },
@ -1672,9 +1664,9 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
{ "DNSSECSupported", "b", NULL, offsetof(struct global_info, dnssec_supported) }, { "DNSSECSupported", "b", NULL, offsetof(struct global_info, dnssec_supported) },
{} {}
}; };
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(global_info_clear) struct global_info global_info = {};
char **i; char **i;
int r; int r;
@ -1689,58 +1681,46 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
&error, &error,
&m, &m,
&global_info); &global_info);
if (r < 0) { if (r < 0)
log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r));
goto finish;
}
(void) pager_open(arg_no_pager, false); (void) pager_open(arg_no_pager, false);
if (mode == STATUS_DNS) { if (mode == STATUS_DNS)
r = status_print_strv_global(global_info.dns); return status_print_strv_global(global_info.dns);
goto finish;
}
if (mode == STATUS_DOMAIN) { if (mode == STATUS_DOMAIN)
r = status_print_strv_global(global_info.domains); return status_print_strv_global(global_info.domains);
goto finish;
}
if (mode == STATUS_NTA) { if (mode == STATUS_NTA)
r = status_print_strv_global(global_info.ntas); return status_print_strv_global(global_info.ntas);
goto finish;
}
if (mode == STATUS_LLMNR) { if (mode == STATUS_LLMNR) {
printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(), printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(),
strna(global_info.llmnr)); strna(global_info.llmnr));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_MDNS) { if (mode == STATUS_MDNS) {
printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(), printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(),
strna(global_info.mdns)); strna(global_info.mdns));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_PRIVATE) { if (mode == STATUS_PRIVATE) {
printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(), printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(),
strna(global_info.dns_over_tls)); strna(global_info.dns_over_tls));
r = 0; return 0;
goto finish;
} }
if (mode == STATUS_DNSSEC) { if (mode == STATUS_DNSSEC) {
printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(), printf("%sGlobal%s: %s\n", ansi_highlight(), ansi_normal(),
strna(global_info.dnssec)); strna(global_info.dnssec));
r = 0; return 0;
goto finish;
} }
printf("%sGlobal%s\n", ansi_highlight(), ansi_normal()); printf("%sGlobal%s\n", ansi_highlight(), ansi_normal());
@ -1786,16 +1766,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
*empty_line = true; *empty_line = true;
r = 0; return 0;
finish:
free(global_info.current_dns);
strv_free(global_info.dns);
strv_free(global_info.fallback_dns);
strv_free(global_info.domains);
strv_free(global_info.ntas);
return r;
} }
static int status_all(sd_bus *bus, StatusMode mode) { static int status_all(sd_bus *bus, StatusMode mode) {

View File

@ -940,10 +940,8 @@ static int start_transient_service(
&error, &error,
&pty_reply, &pty_reply,
"s", arg_host); "s", arg_host);
if (r < 0) { if (r < 0)
log_error("Failed to get machine PTY: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to get machine PTY: %s", bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(pty_reply, "hs", &master, &s); r = sd_bus_message_read(pty_reply, "hs", &master, &s);
if (r < 0) if (r < 0)
@ -1219,10 +1217,8 @@ static int start_transient_scope(
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to start transient scope unit: %s", bus_error_message(&error, -r)); return log_error_errno(r, "Failed to start transient scope unit: %s", bus_error_message(&error, -r));
return r;
}
if (arg_nice_set) { if (arg_nice_set) {
if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0) if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0)
@ -1437,10 +1433,8 @@ static int start_transient_trigger(
polkit_agent_open_if_enabled(arg_transport, arg_ask_password); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = sd_bus_call(bus, m, 0, &error, &reply); r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) { if (r < 0)
log_error("Failed to start transient %s unit: %s", suffix + 1, bus_error_message(&error, -r)); return log_error_errno(r, "Failed to start transient %s unit: %s", suffix + 1, bus_error_message(&error, -r));
return r;
}
r = sd_bus_message_read(reply, "o", &object); r = sd_bus_message_read(reply, "o", &object);
if (r < 0) if (r < 0)

View File

@ -1101,10 +1101,8 @@ int dissected_image_decrypt_interactively(
return r; return r;
if (r == -EKEYREJECTED) if (r == -EKEYREJECTED)
log_error_errno(r, "Incorrect passphrase, try again!"); log_error_errno(r, "Incorrect passphrase, try again!");
else if (r != -ENOKEY) { else if (r != -ENOKEY)
log_error_errno(r, "Failed to decrypt image: %m"); return log_error_errno(r, "Failed to decrypt image: %m");
return r;
}
if (--n < 0) { if (--n < 0) {
log_error("Too many retries."); log_error("Too many retries.");

View File

@ -59,9 +59,9 @@ static int start_default_target(sd_bus *bus) {
"ss", "default.target", "isolate"); "ss", "default.target", "isolate");
if (r < 0) if (r < 0)
log_error("Failed to start default target: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to start default target: %s", bus_error_message(&error, r));
return r; return 0;
} }
static int fork_wait(const char* const cmdline[]) { static int fork_wait(const char* const cmdline[]) {

View File

@ -204,9 +204,9 @@ static int set_time(int argc, char **argv, void *userdata) {
NULL, NULL,
"xbb", (int64_t) t, relative, interactive); "xbb", (int64_t) t, relative, interactive);
if (r < 0) if (r < 0)
log_error("Failed to set time: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set time: %s", bus_error_message(&error, r));
return r; return 0;
} }
static int set_timezone(int argc, char **argv, void *userdata) { static int set_timezone(int argc, char **argv, void *userdata) {
@ -225,9 +225,9 @@ static int set_timezone(int argc, char **argv, void *userdata) {
NULL, NULL,
"sb", argv[1], arg_ask_password); "sb", argv[1], arg_ask_password);
if (r < 0) if (r < 0)
log_error("Failed to set time zone: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set time zone: %s", bus_error_message(&error, r));
return r; return 0;
} }
static int set_local_rtc(int argc, char **argv, void *userdata) { static int set_local_rtc(int argc, char **argv, void *userdata) {
@ -250,9 +250,9 @@ static int set_local_rtc(int argc, char **argv, void *userdata) {
NULL, NULL,
"bbb", b, arg_adjust_system_clock, arg_ask_password); "bbb", b, arg_adjust_system_clock, arg_ask_password);
if (r < 0) if (r < 0)
log_error("Failed to set local RTC: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set local RTC: %s", bus_error_message(&error, r));
return r; return 0;
} }
static int set_ntp(int argc, char **argv, void *userdata) { static int set_ntp(int argc, char **argv, void *userdata) {
@ -275,9 +275,9 @@ static int set_ntp(int argc, char **argv, void *userdata) {
NULL, NULL,
"bb", b, arg_ask_password); "bb", b, arg_ask_password);
if (r < 0) if (r < 0)
log_error("Failed to set ntp: %s", bus_error_message(&error, r)); return log_error_errno(r, "Failed to set ntp: %s", bus_error_message(&error, r));
return r; return 0;
} }
static int list_timezones(int argc, char **argv, void *userdata) { static int list_timezones(int argc, char **argv, void *userdata) {