diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:50:43 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:56:16 +0100 |
commit | f647962d64e844689f3e2acfce6102fc47e76df2 (patch) | |
tree | dcaf5e38de1d4e31f73f540bc85532ceb72cfa6b | |
parent | e80733be33e52d8ab2f1ae845326d39c600f5612 (diff) |
treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
'local $/;
local $_=<>;
s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
print;'
$f
done
And a couple of manual whitespace fixups.
44 files changed, 476 insertions, 947 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 32e2d33e99..78385538b4 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -653,10 +653,8 @@ static int setup_microhttpd_server(RemoteServer *s, assert(fd >= 0); r = fd_nonblock(fd, true); - if (r < 0) { - log_error_errno(r, "Failed to make fd:%d nonblocking: %m", fd); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to make fd:%d nonblocking: %m", fd); if (key) { assert(cert); diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index dfc54560af..e91c402c5b 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -53,10 +53,8 @@ static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu log_info("Invoked Foobar() on %s", sd_bus_message_get_path(m)); r = sd_bus_reply_method_return(m, NULL); - if (r < 0) { - log_error_errno(r, "Failed to send reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to send reply: %m"); return 1; } diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c index e65811f047..5f807c3b1e 100644 --- a/src/libsystemd/sd-bus/test-bus-server.c +++ b/src/libsystemd/sd-bus/test-bus-server.c @@ -146,10 +146,8 @@ static int client(struct context *c) { "/", "org.freedesktop.systemd.test", "Exit"); - if (r < 0) { - log_error_errno(r, "Failed to allocate method call: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate method call: %m"); r = sd_bus_call(bus, m, 0, &error, &reply); if (r < 0) { diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 211808b03e..cb2920974c 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -234,10 +234,8 @@ static int list_locales(sd_bus *bus, char **args, unsigned n) { assert(args); r = get_locales(&l); - if (r < 0) { - log_error_errno(r, "Failed to read list of locales: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read list of locales: %m"); pager_open_if_enabled(); strv_print(l); @@ -309,10 +307,8 @@ static int nftw_cb( *e = 0; r = set_consume(keymaps, p); - if (r < 0 && r != -EEXIST) { - log_error_errno(r, "Can't add keymap: %m"); - return r; - } + if (r < 0 && r != -EEXIST) + return log_error_errno(r, "Can't add keymap: %m"); return 0; } diff --git a/src/locale/localed.c b/src/locale/localed.c index 119a1da844..654b291928 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -610,10 +610,8 @@ static int vconsole_convert_to_x11(Context *c, sd_bus *bus) { int r; r = x11_write_data(c); - if (r < 0) { - log_error_errno(r, "Failed to set X11 keyboard layout: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set X11 keyboard layout: %m"); log_info("Changed X11 keyboard layout to '%s' model '%s' variant '%s' options '%s'", strempty(c->x11_layout), @@ -1155,28 +1153,20 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) { assert(_bus); r = sd_bus_default_system(&bus); - if (r < 0) { - log_error_errno(r, "Failed to get system bus connection: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get system bus connection: %m"); r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/locale1", "org.freedesktop.locale1", locale_vtable, c); - if (r < 0) { - log_error_errno(r, "Failed to register object: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register object: %m"); r = sd_bus_request_name(bus, "org.freedesktop.locale1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(bus, event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); *_bus = bus; bus = NULL; diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 80e03ebbec..6505eb89c1 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -384,10 +384,8 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li int r; r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &i); - if (r < 0) { - log_error_errno(r, "Could not get properties: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not get properties: %m"); if (*new_line) printf("\n"); @@ -699,10 +697,8 @@ static int show_user(sd_bus *bus, char **args, unsigned n) { uid_t uid; r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Failed to look up user %s: %m", args[i]); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to look up user %s: %m", args[i]); r = sd_bus_call_method( bus, @@ -859,10 +855,8 @@ static int enable_linger(sd_bus *bus, char **args, unsigned n) { uid_t uid; r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Failed to look up user %s: %m", args[i]); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to look up user %s: %m", args[i]); r = sd_bus_call_method ( bus, @@ -892,10 +886,8 @@ static int terminate_user(sd_bus *bus, char **args, unsigned n) { uid_t uid; r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Failed to look up user %s: %m", args[i]); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to look up user %s: %m", args[i]); r = sd_bus_call_method ( bus, @@ -928,10 +920,8 @@ static int kill_user(sd_bus *bus, char **args, unsigned n) { uid_t uid; r = get_user_creds((const char**) (args+i), &uid, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Failed to look up user %s: %m", args[i]); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to look up user %s: %m", args[i]); r = sd_bus_call_method ( bus, diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 20161ede9d..5b30457a88 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -337,10 +337,8 @@ int session_load(Session *s) { "CONTROLLER", &controller, NULL); - if (r < 0) { - log_error_errno(r, "Failed to read %s: %m", s->state_file); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read %s: %m", s->state_file); if (!s->user) { uid_t u; diff --git a/src/login/logind-user.c b/src/login/logind-user.c index d2a4f7e9cb..f865afdb53 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -310,10 +310,8 @@ static int user_mkdir_runtime_path(User *u) { assert(u); r = mkdir_safe_label("/run/user", 0755, 0, 0); - if (r < 0) { - log_error_errno(r, "Failed to create /run/user: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create /run/user: %m"); if (!u->runtime_path) { if (asprintf(&p, "/run/user/" UID_FMT, u->uid) < 0) diff --git a/src/login/logind.c b/src/login/logind.c index d7fb1bf170..78220ff4dd 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -583,52 +583,36 @@ static int manager_connect_bus(Manager *m) { assert(!m->bus); r = sd_bus_default_system(&m->bus); - if (r < 0) { - log_error_errno(r, "Failed to connect to system bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to system bus: %m"); r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/login1", "org.freedesktop.login1.Manager", manager_vtable, m); - if (r < 0) { - log_error_errno(r, "Failed to add manager object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add manager object vtable: %m"); r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/seat", "org.freedesktop.login1.Seat", seat_vtable, seat_object_find, m); - if (r < 0) { - log_error_errno(r, "Failed to add seat object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add seat object vtable: %m"); r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/seat", seat_node_enumerator, m); - if (r < 0) { - log_error_errno(r, "Failed to add seat enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add seat enumerator: %m"); r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/session", "org.freedesktop.login1.Session", session_vtable, session_object_find, m); - if (r < 0) { - log_error_errno(r, "Failed to add session object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add session object vtable: %m"); r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/session", session_node_enumerator, m); - if (r < 0) { - log_error_errno(r, "Failed to add session enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add session enumerator: %m"); r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/login1/user", "org.freedesktop.login1.User", user_vtable, user_object_find, m); - if (r < 0) { - log_error_errno(r, "Failed to add user object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add user object vtable: %m"); r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/login1/user", user_node_enumerator, m); - if (r < 0) { - log_error_errno(r, "Failed to add user enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add user enumerator: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -638,10 +622,8 @@ static int manager_connect_bus(Manager *m) { "member='NameOwnerChanged'," "path='/org/freedesktop/DBus'", match_name_owner_changed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for NameOwnerChanged: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for NameOwnerChanged: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -651,10 +633,8 @@ static int manager_connect_bus(Manager *m) { "member='JobRemoved'," "path='/org/freedesktop/systemd1'", match_job_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for JobRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for JobRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -664,10 +644,8 @@ static int manager_connect_bus(Manager *m) { "member='UnitRemoved'," "path='/org/freedesktop/systemd1'", match_unit_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for UnitRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for UnitRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -676,10 +654,8 @@ static int manager_connect_bus(Manager *m) { "interface='org.freedesktop.DBus.Properties'," "member='PropertiesChanged'", match_properties_changed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -689,10 +665,8 @@ static int manager_connect_bus(Manager *m) { "member='Reloading'," "path='/org/freedesktop/systemd1'", match_reloading, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for Reloading: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for Reloading: %m"); r = sd_bus_call_method( m->bus, @@ -708,16 +682,12 @@ static int manager_connect_bus(Manager *m) { } r = sd_bus_request_name(m->bus, "org.freedesktop.login1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(m->bus, m->event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); return 0; } @@ -806,16 +776,12 @@ static int manager_connect_console(Manager *m) { } r = ignore_signals(SIGRTMIN + 1, -1); - if (r < 0) { - log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot ignore SIGRTMIN + 1: %m"); r = sigprocmask_many(SIG_BLOCK, SIGRTMIN, -1); - if (r < 0) { - log_error_errno(r, "Cannot block SIGRTMIN: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot block SIGRTMIN: %m"); r = sd_event_add_signal(m->event, NULL, SIGRTMIN, manager_vt_switch, m); if (r < 0) @@ -1016,28 +982,20 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us CLOCK_MONOTONIC, elapse, USEC_PER_SEC*30, manager_dispatch_idle_action, m); - if (r < 0) { - log_error_errno(r, "Failed to add idle event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add idle event source: %m"); r = sd_event_source_set_priority(m->idle_action_event_source, SD_EVENT_PRIORITY_IDLE+10); - if (r < 0) { - log_error_errno(r, "Failed to set idle event source priority: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set idle event source priority: %m"); } else { r = sd_event_source_set_time(m->idle_action_event_source, elapse); - if (r < 0) { - log_error_errno(r, "Failed to set idle event timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set idle event timer: %m"); r = sd_event_source_set_enabled(m->idle_action_event_source, SD_EVENT_ONESHOT); - if (r < 0) { - log_error_errno(r, "Failed to enable idle event timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enable idle event timer: %m"); } return 0; @@ -1061,10 +1019,8 @@ int manager_startup(Manager *m) { /* Connect to udev */ r = manager_connect_udev(m); - if (r < 0) { - log_error_errno(r, "Failed to create udev watchers: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create udev watchers: %m"); /* Connect to the bus */ r = manager_connect_bus(m); @@ -1073,10 +1029,8 @@ int manager_startup(Manager *m) { /* Instantiate magic seat 0 */ r = manager_add_seat(m, "seat0", &m->seat0); - if (r < 0) { - log_error_errno(r, "Failed to add seat0: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add seat0: %m"); r = manager_set_lid_switch_ignore(m, 0 + IGNORE_LID_SWITCH_STARTUP_USEC); if (r < 0) diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c index 52cdfda627..6db9e5c91b 100644 --- a/src/machine/machinectl.c +++ b/src/machine/machinectl.c @@ -414,10 +414,8 @@ static int show_info(const char *verb, sd_bus *bus, const char *path, bool *new_ path, map, &info); - if (r < 0) { - log_error_errno(r, "Could not get properties: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not get properties: %m"); if (*new_line) printf("\n"); @@ -681,16 +679,12 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { } r = sd_event_default(&event); - if (r < 0) { - log_error_errno(r, "Failed to get event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get event loop: %m"); r = sd_bus_attach_event(bus, event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); r = sd_bus_call_method( bus, @@ -719,20 +713,16 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { &error, &reply2, "u"); - if (r < 0) { - log_error_errno(r, "Failed to retrieve PID of leader: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve PID of leader: %m"); r = sd_bus_message_read(reply2, "u", &leader); if (r < 0) return bus_log_parse_error(r); master = openpt_in_namespace(leader, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NDELAY); - if (master < 0) { - log_error_errno(master, "Failed to acquire pseudo tty: %m"); - return master; - } + if (master < 0) + return log_error_errno(master, "Failed to acquire pseudo tty: %m"); pty = ptsname(master); if (!pty) { @@ -747,10 +737,8 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { } r = sd_bus_open_system_container(&container_bus, args[1]); - if (r < 0) { - log_error_errno(r, "Failed to get container bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get container bus: %m"); getty = strjoin("container-getty@", p, ".service", NULL); if (!getty) @@ -785,16 +773,12 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) { sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL); r = pty_forward_new(event, master, &forward); - if (r < 0) { - log_error_errno(r, "Failed to create PTY forwarder: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create PTY forwarder: %m"); r = sd_event_loop(event); - if (r < 0) { - log_error_errno(r, "Failed to run event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to run event loop: %m"); forward = pty_forward_free(forward); diff --git a/src/machine/machined.c b/src/machine/machined.c index 2385fead6e..d1c10d2a26 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -137,28 +137,20 @@ static int manager_connect_bus(Manager *m) { assert(!m->bus); r = sd_bus_default_system(&m->bus); - if (r < 0) { - log_error_errno(r, "Failed to connect to system bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to system bus: %m"); r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", manager_vtable, m); - if (r < 0) { - log_error_errno(r, "Failed to add manager object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add manager object vtable: %m"); r = sd_bus_add_fallback_vtable(m->bus, NULL, "/org/freedesktop/machine1/machine", "org.freedesktop.machine1.Machine", machine_vtable, machine_object_find, m); - if (r < 0) { - log_error_errno(r, "Failed to add machine object vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add machine object vtable: %m"); r = sd_bus_add_node_enumerator(m->bus, NULL, "/org/freedesktop/machine1/machine", machine_node_enumerator, m); - if (r < 0) { - log_error_errno(r, "Failed to add machine enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add machine enumerator: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -169,10 +161,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_job_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for JobRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for JobRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -183,10 +173,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_unit_removed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for UnitRemoved: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for UnitRemoved: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -196,10 +184,8 @@ static int manager_connect_bus(Manager *m) { "member='PropertiesChanged'", match_properties_changed, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for PropertiesChanged: %m"); r = sd_bus_add_match(m->bus, NULL, @@ -210,10 +196,8 @@ static int manager_connect_bus(Manager *m) { "path='/org/freedesktop/systemd1'", match_reloading, m); - if (r < 0) { - log_error_errno(r, "Failed to add match for Reloading: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match for Reloading: %m"); r = sd_bus_call_method( m->bus, @@ -229,16 +213,12 @@ static int manager_connect_bus(Manager *m) { } r = sd_bus_request_name(m->bus, "org.freedesktop.machine1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(m->bus, m->event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); return 0; } diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 99aa429ed8..1fd01adbe4 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -81,10 +81,8 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { log_debug("load: %s", m); r = kmod_module_new_from_lookup(ctx, m, &modlist); - if (r < 0) { - log_error_errno(r, "Failed to lookup alias '%s': %m", m); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to lookup alias '%s': %m", m); if (!modlist) { log_error("Failed to find module '%s'", m); diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 2754ed8d3e..035dce162b 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -190,10 +190,8 @@ static int list_links(char **args, unsigned n) { pager_open_if_enabled(); r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); udev = udev_new(); if (!udev) { @@ -210,10 +208,8 @@ static int list_links(char **args, unsigned n) { return rtnl_log_create_error(r); r = sd_rtnl_call(rtnl, req, 0, &reply); - if (r < 0) { - log_error_errno(r, "Failed to enumerate links: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate links: %m"); if (arg_legend) printf("%3s %-16s %-18s %-11s %-10s\n", "IDX", "LINK", "TYPE", "OPERATIONAL", "SETUP"); @@ -322,10 +318,8 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) { return rtnl_log_create_error(r); r = sd_rtnl_call(rtnl, req, 0, &reply); - if (r < 0) { - log_error_errno(r, "Failed to query link: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query link: %m"); r = sd_rtnl_message_link_get_ifindex(reply, &ifindex); if (r < 0) @@ -447,10 +441,8 @@ static int link_status(char **args, unsigned n) { int r; r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); udev = udev_new(); if (!udev) { @@ -513,10 +505,8 @@ static int link_status(char **args, unsigned n) { return rtnl_log_create_error(r); r = sd_rtnl_call(rtnl, req, 0, &reply); - if (r < 0) { - log_error_errno(r, "Failed to enumerate links: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate links: %m"); c = decode_and_sort_links(reply, &links); if (c < 0) diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 3a1d565e7b..a708e905f4 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -355,10 +355,8 @@ int manager_udev_listen(Manager *m) { assert(m->udev_monitor); r = udev_monitor_filter_add_match_subsystem_devtype(m->udev_monitor, "net", NULL); - if (r < 0) { - log_error_errno(r, "Could not add udev monitor filter: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not add udev monitor filter: %m"); r = udev_monitor_enable_receiving(m->udev_monitor); if (r < 0) { diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c index 46f98e0925..251cf92aec 100644 --- a/src/network/networkd-netdev-veth.c +++ b/src/network/networkd-netdev-veth.c @@ -46,10 +46,8 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m if (v->ifname_peer) { r = sd_rtnl_message_append_string(m, IFLA_IFNAME, v->ifname_peer); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface name: %m"); } if (v->mac_peer) { diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 7f717171ca..a08236e7c3 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -743,10 +743,8 @@ int netdev_load(Manager *manager) { netdev_unref(netdev); r = conf_files_list_strv(&files, ".netdev", NULL, network_dirs); - if (r < 0) { - log_error_errno(r, "Failed to enumerate netdev files: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate netdev files: %m"); STRV_FOREACH_BACKWARDS(f, files) { r = netdev_load_one(manager, *f); diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 151aa12cb7..e4bb1b03f0 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -131,10 +131,8 @@ int network_load(Manager *manager) { network_free(network); r = conf_files_list_strv(&files, ".network", NULL, network_dirs); - if (r < 0) { - log_error_errno(r, "Failed to enumerate network files: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate network files: %m"); STRV_FOREACH_BACKWARDS(f, files) { r = network_load_one(manager, *f); diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 058f887ebf..25db676f05 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -113,20 +113,16 @@ int route_drop(Route *route, Link *link, r = sd_rtnl_message_new_route(link->manager->rtnl, &req, RTM_DELROUTE, route->family, route->protocol); - if (r < 0) { - log_error_errno(r, "Could not create RTM_DELROUTE message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not create RTM_DELROUTE message: %m"); if (!in_addr_is_null(route->family, &route->in_addr)) { if (route->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m"); } if (route->dst_prefixlen) { @@ -134,16 +130,12 @@ int route_drop(Route *route, Link *link, r = sd_rtnl_message_append_in_addr(req, RTA_DST, &route->dst_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_DST attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_DST attribute: %m"); r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen); - if (r < 0) { - log_error_errno(r, "Could not set destination prefix length: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not set destination prefix length: %m"); } if (!in_addr_is_null(route->family, &route->prefsrc_addr)) { @@ -151,35 +143,25 @@ int route_drop(Route *route, Link *link, r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m"); } r = sd_rtnl_message_route_set_scope(req, route->scope); - if (r < 0) { - log_error_errno(r, "Could not set scope: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not set scope: %m"); r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics); - if (r < 0) { - log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m"); r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex); - if (r < 0) { - log_error_errno(r, "Could not append RTA_OIF attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_OIF attribute: %m"); r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); - if (r < 0) { - log_error_errno(r, "Could not send rtnetlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not send rtnetlink message: %m"); link_ref(link); @@ -200,20 +182,16 @@ int route_configure(Route *route, Link *link, r = sd_rtnl_message_new_route(link->manager->rtnl, &req, RTM_NEWROUTE, route->family, route->protocol); - if (r < 0) { - log_error_errno(r, "Could not create RTM_NEWROUTE message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not create RTM_NEWROUTE message: %m"); if (!in_addr_is_null(route->family, &route->in_addr)) { if (route->family == AF_INET) r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m"); } if (route->dst_prefixlen) { @@ -221,16 +199,12 @@ int route_configure(Route *route, Link *link, r = sd_rtnl_message_append_in_addr(req, RTA_DST, &route->dst_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_DST attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_DST attribute: %m"); r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen); - if (r < 0) { - log_error_errno(r, "Could not set destination prefix length: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not set destination prefix length: %m"); } if (!in_addr_is_null(route->family, &route->prefsrc_addr)) { @@ -238,35 +212,25 @@ int route_configure(Route *route, Link *link, r = sd_rtnl_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in); else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); - if (r < 0) { - log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m"); } r = sd_rtnl_message_route_set_scope(req, route->scope); - if (r < 0) { - log_error_errno(r, "Could not set scope: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not set scope: %m"); r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics); - if (r < 0) { - log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m"); r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex); - if (r < 0) { - log_error_errno(r, "Could not append RTA_OIF attribute: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not append RTA_OIF attribute: %m"); r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); - if (r < 0) { - log_error_errno(r, "Could not send rtnetlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not send rtnetlink message: %m"); link_ref(link); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 73e98b71ae..3a8450ed7b 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -755,10 +755,8 @@ static int mount_binds(const char *dest, char **l, bool ro) { } } else if (errno == ENOENT) { r = mkdir_parents_label(where, 0755); - if (r < 0) { - log_error_errno(r, "Failed to bind mount %s: %m", *x); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to bind mount %s: %m", *x); } else { log_error("Failed to bind mount %s: %m", *x); return -errno; @@ -768,11 +766,8 @@ static int mount_binds(const char *dest, char **l, bool ro) { * and char devices. */ if (S_ISDIR(source_st.st_mode)) { r = mkdir_label(where, 0755); - if (r < 0 && errno != EEXIST) { - log_error_errno(r, "Failed to create mount point %s: %m", where); - - return r; - } + if (r < 0 && errno != EEXIST) + return log_error_errno(r, "Failed to create mount point %s: %m", where); } else if (S_ISFIFO(source_st.st_mode)) { r = mkfifo(where, 0644); if (r < 0 && errno != EEXIST) { @@ -789,11 +784,8 @@ static int mount_binds(const char *dest, char **l, bool ro) { } } else if (S_ISREG(source_st.st_mode)) { r = touch(where); - if (r < 0) { - log_error_errno(r, "Failed to create mount point %s: %m", where); - - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create mount point %s: %m", where); } else { log_error("Refusing to create mountpoint for file: %s", *x); return -ENOTSUP; @@ -806,10 +798,8 @@ static int mount_binds(const char *dest, char **l, bool ro) { if (ro) { r = bind_remount_recursive(where, true); - if (r < 0) { - log_error_errno(r, "Read-Only bind mount failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Read-Only bind mount failed: %m"); } } @@ -828,11 +818,8 @@ static int mount_tmpfs(const char *dest) { return log_oom(); r = mkdir_label(where, 0755); - if (r < 0 && errno != EEXIST) { - log_error_errno(r, "creating mount point for tmpfs %s failed: %m", where); - - return r; - } + if (r < 0 && errno != EEXIST) + return log_error_errno(r, "creating mount point for tmpfs %s failed: %m", where); if (mount("tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, *o) < 0) { log_error("tmpfs mount to %s failed: %m", where); @@ -961,10 +948,8 @@ static int setup_volatile_state(const char *directory) { with a tmpfs, and the rest read-only. */ r = bind_remount_recursive(directory, true); - if (r < 0) { - log_error_errno(r, "Failed to remount %s read-only: %m", directory); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to remount %s read-only: %m", directory); p = strappenda(directory, "/var"); r = mkdir(p, 0755); @@ -1080,18 +1065,14 @@ static int setup_boot_id(const char *dest) { return log_oom(); r = sd_id128_randomize(&rnd); - if (r < 0) { - log_error_errno(r, "Failed to generate random boot id: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to generate random boot id: %m"); id128_format_as_uuid(rnd, as_uuid); r = write_string_file(from, as_uuid); - if (r < 0) { - log_error_errno(r, "Failed to write boot id: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write boot id: %m"); if (mount(from, to, "bind", MS_BIND, NULL) < 0) { log_error("Failed to bind mount boot id: %m"); @@ -1192,10 +1173,8 @@ static int setup_dev_console(const char *dest, const char *console) { } r = chmod_and_chown(console, 0600, 0, 0); - if (r < 0) { - log_error_errno(r, "Failed to correct access mode for TTY: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to correct access mode for TTY: %m"); /* We need to bind mount the right tty to /dev/console since * ptys can only exist on pts file systems. To have something @@ -1255,10 +1234,8 @@ static int setup_kmsg(const char *dest, int kmsg_socket) { } r = chmod_and_chown(from, 0600, 0, 0); - if (r < 0) { - log_error_errno(r, "Failed to correct access mode for /dev/kmsg: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to correct access mode for /dev/kmsg: %m"); if (mount(from, to, "bind", MS_BIND, NULL) < 0) { log_error("Bind mount for /proc/kmsg failed: %m"); @@ -1318,10 +1295,8 @@ static int setup_journal(const char *directory) { r = read_one_line_file(p, &b); if (r == -ENOENT && arg_link_journal == LINK_AUTO) return 0; - else if (r < 0) { - log_error_errno(r, "Failed to read machine ID from %s: %m", p); - return r; - } + else if (r < 0) + return log_error_errno(r, "Failed to read machine ID from %s: %m", p); id = strstrip(b); if (isempty(id) && arg_link_journal == LINK_AUTO) @@ -1329,16 +1304,12 @@ static int setup_journal(const char *directory) { /* Verify validity */ r = sd_id128_from_string(id, &machine_id); - if (r < 0) { - log_error_errno(r, "Failed to parse machine ID from %s: %m", p); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to parse machine ID from %s: %m", p); r = sd_id128_get_machine(&this_id); - if (r < 0) { - log_error_errno(r, "Failed to retrieve machine ID: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve machine ID: %m"); if (sd_id128_equal(machine_id, this_id)) { log_full(arg_link_journal == LINK_AUTO ? LOG_WARNING : LOG_ERR, @@ -1475,10 +1446,8 @@ static int register_machine(pid_t pid, int local_ifindex) { return 0; r = sd_bus_default_system(&bus); - if (r < 0) { - log_error_errno(r, "Failed to open system bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open system bus: %m"); if (arg_keep_unit) { r = sd_bus_call_method( @@ -1507,10 +1476,8 @@ static int register_machine(pid_t pid, int local_ifindex) { "/org/freedesktop/machine1", "org.freedesktop.machine1.Manager", "CreateMachineWithNetwork"); - if (r < 0) { - log_error_errno(r, "Failed to create message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create message: %m"); r = sd_bus_message_append( m, @@ -1522,30 +1489,22 @@ static int register_machine(pid_t pid, int local_ifindex) { (uint32_t) pid, strempty(arg_directory), local_ifindex > 0 ? 1 : 0, local_ifindex); - if (r < 0) { - log_error_errno(r, "Failed to append message arguments: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append message arguments: %m"); r = sd_bus_message_open_container(m, 'a', "(sv)"); - if (r < 0) { - log_error_errno(r, "Failed to open container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open container: %m"); if (!isempty(arg_slice)) { r = sd_bus_message_append(m, "(sv)", "Slice", "s", arg_slice); - if (r < 0) { - log_error_errno(r, "Failed to append slice: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append slice: %m"); } r = sd_bus_message_append(m, "(sv)", "DevicePolicy", "s", "strict"); - if (r < 0) { - log_error_errno(r, "Failed to add device policy: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add device policy: %m"); r = sd_bus_message_append(m, "(sv)", "DeviceAllow", "a(ss)", 9, /* Allow the container to @@ -1568,16 +1527,12 @@ static int register_machine(pid_t pid, int local_ifindex) { * these device nodes. */ "/dev/pts/ptmx", "rw", "char-pts", "rw"); - if (r < 0) { - log_error_errno(r, "Failed to add device whitelist: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add device whitelist: %m"); r = sd_bus_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close container: %m"); r = sd_bus_call(bus, m, 0, &error, NULL); } @@ -1601,10 +1556,8 @@ static int terminate_machine(pid_t pid) { return 0; r = sd_bus_default_system(&bus); - if (r < 0) { - log_error_errno(r, "Failed to open system bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open system bus: %m"); r = sd_bus_call_method( bus, @@ -1655,10 +1608,8 @@ static int reset_audit_loginuid(void) { r = read_one_line_file("/proc/self/loginuid", &p); if (r == -ENOENT) return 0; - if (r < 0) { - log_error_errno(r, "Failed to read /proc/self/loginuid: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read /proc/self/loginuid: %m"); /* Already reset? */ if (streq(p, "4294967295")) @@ -1745,88 +1696,60 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) { } r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0); - if (r < 0) { - log_error_errno(r, "Failed to allocate netlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate netlink message: %m"); r = sd_rtnl_message_append_string(m, IFLA_IFNAME, iface_name); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface name: %m"); r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, &mac_host); - if (r < 0) { - log_error_errno(r, "Failed to add netlink MAC address: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink MAC address: %m"); r = sd_rtnl_message_open_container(m, IFLA_LINKINFO); - if (r < 0) { - log_error_errno(r, "Failed to open netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open netlink container: %m"); r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "veth"); - if (r < 0) { - log_error_errno(r, "Failed to open netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open netlink container: %m"); r = sd_rtnl_message_open_container(m, VETH_INFO_PEER); - if (r < 0) { - log_error_errno(r, "Failed to open netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open netlink container: %m"); r = sd_rtnl_message_append_string(m, IFLA_IFNAME, "host0"); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface name: %m"); r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, &mac_container); - if (r < 0) { - log_error_errno(r, "Failed to add netlink MAC address: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink MAC address: %m"); r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid); - if (r < 0) { - log_error_errno(r, "Failed to add netlink namespace field: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink namespace field: %m"); r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close netlink container: %m"); r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close netlink container: %m"); r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close netlink container: %m"); r = sd_rtnl_call(rtnl, m, 0, NULL); - if (r < 0) { - log_error_errno(r, "Failed to add new veth interfaces: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add new veth interfaces: %m"); i = (int) if_nametoindex(iface_name); if (i <= 0) { @@ -1862,40 +1785,28 @@ static int setup_bridge(const char veth_name[], int *ifi) { *ifi = bridge; r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, 0); - if (r < 0) { - log_error_errno(r, "Failed to allocate netlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate netlink message: %m"); r = sd_rtnl_message_link_set_flags(m, IFF_UP, IFF_UP); - if (r < 0) { - log_error_errno(r, "Failed to set IFF_UP flag: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set IFF_UP flag: %m"); r = sd_rtnl_message_append_string(m, IFLA_IFNAME, veth_name); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface name field: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface name field: %m"); r = sd_rtnl_message_append_u32(m, IFLA_MASTER, bridge); - if (r < 0) { - log_error_errno(r, "Failed to add netlink master field: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink master field: %m"); r = sd_rtnl_call(rtnl, m, 0, NULL); - if (r < 0) { - log_error_errno(r, "Failed to add veth interface to bridge: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add veth interface to bridge: %m"); return 0; } @@ -1939,10 +1850,8 @@ static int move_network_interfaces(pid_t pid) { return 0; r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); udev = udev_new(); if (!udev) { @@ -1959,22 +1868,16 @@ static int move_network_interfaces(pid_t pid) { return ifi; r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, ifi); - if (r < 0) { - log_error_errno(r, "Failed to allocate netlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate netlink message: %m"); r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid); - if (r < 0) { - log_error_errno(r, "Failed to append namespace PID to netlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append namespace PID to netlink message: %m"); r = sd_rtnl_call(rtnl, m, 0, NULL); - if (r < 0) { - log_error_errno(r, "Failed to move interface %s to namespace: %m", *i); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to move interface %s to namespace: %m", *i); } return 0; @@ -1993,10 +1896,8 @@ static int setup_macvlan(pid_t pid) { return 0; r = sd_rtnl_open(&rtnl, 0); - if (r < 0) { - log_error_errno(r, "Failed to connect to netlink: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to connect to netlink: %m"); udev = udev_new(); if (!udev) { @@ -2014,16 +1915,12 @@ static int setup_macvlan(pid_t pid) { return ifi; r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0); - if (r < 0) { - log_error_errno(r, "Failed to allocate netlink message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate netlink message: %m"); r = sd_rtnl_message_append_u32(m, IFLA_LINK, ifi); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface index: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface index: %m"); n = strappend("mv-", *i); if (!n) @@ -2032,52 +1929,36 @@ static int setup_macvlan(pid_t pid) { strshorten(n, IFNAMSIZ-1); r = sd_rtnl_message_append_string(m, IFLA_IFNAME, n); - if (r < 0) { - log_error_errno(r, "Failed to add netlink interface name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink interface name: %m"); r = sd_rtnl_message_append_u32(m, IFLA_NET_NS_PID, pid); - if (r < 0) { - log_error_errno(r, "Failed to add netlink namespace field: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add netlink namespace field: %m"); r = sd_rtnl_message_open_container(m, IFLA_LINKINFO); - if (r < 0) { - log_error_errno(r, "Failed to open netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open netlink container: %m"); r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "macvlan"); - if (r < 0) { - log_error_errno(r, "Failed to open netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open netlink container: %m"); r = sd_rtnl_message_append_u32(m, IFLA_MACVLAN_MODE, MACVLAN_MODE_BRIDGE); - if (r < 0) { - log_error_errno(r, "Failed to append macvlan mode: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append macvlan mode: %m"); r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close netlink container: %m"); r = sd_rtnl_message_close_container(m); - if (r < 0) { - log_error_errno(r, "Failed to close netlink container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to close netlink container: %m"); r = sd_rtnl_call(rtnl, m, 0, NULL); - if (r < 0) { - log_error_errno(r, "Failed to add new macvlan interfaces: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add new macvlan interfaces: %m"); } return 0; @@ -2349,10 +2230,8 @@ static int dissect_image( return log_oom(); r = udev_enumerate_scan_devices(e); - if (r < 0) { - log_error_errno(r, "Failed to scan for partition devices of %s: %m", arg_image); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to scan for partition devices of %s: %m", arg_image); first = udev_enumerate_get_list_entry(e); udev_list_entry_foreach(item, first) { @@ -2580,26 +2459,20 @@ static int mount_devices( if (root_device) { r = mount_device(root_device, arg_directory, NULL, root_device_rw); - if (r < 0) { - log_error_errno(r, "Failed to mount root directory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to mount root directory: %m"); } if (home_device) { r = mount_device(home_device, arg_directory, "/home", home_device_rw); - if (r < 0) { - log_error_errno(r, "Failed to mount home directory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to mount home directory: %m"); } if (srv_device) { r = mount_device(srv_device, arg_directory, "/srv", srv_device_rw); - if (r < 0) { - log_error_errno(r, "Failed to mount server data directory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to mount server data directory: %m"); } return 0; @@ -2856,16 +2729,12 @@ static int change_uid_gid(char **_home) { } r = mkdir_parents(home, 0775); - if (r < 0) { - log_error_errno(r, "Failed to make home root directory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to make home root directory: %m"); r = mkdir_safe(home, 0755, uid, gid); - if (r < 0 && r != -EEXIST) { - log_error_errno(r, "Failed to make home directory: %m"); - return r; - } + if (r < 0 && r != -EEXIST) + return log_error_errno(r, "Failed to make home directory: %m"); fchown(STDIN_FILENO, uid, gid); fchown(STDOUT_FILENO, uid, gid); @@ -2916,10 +2785,8 @@ static int wait_for_container(pid_t pid, ContainerStatus *container) { int r; r = wait_for_terminate(pid, &status); - if (r < 0) { - log_warning_errno(r, "Failed to wait for container: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "Failed to wait for container: %m"); switch (status.si_code) { @@ -3545,10 +3412,8 @@ int main(int argc, char *argv[]) { } r = sd_event_loop(event); - if (r < 0) { - log_error_errno(r, "Failed to run event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to run event loop: %m"); forward = pty_forward_free(forward); diff --git a/src/path/path.c b/src/path/path.c index 65016cda3e..2f0148f074 100644 --- a/src/path/path.c +++ b/src/path/path.c @@ -108,10 +108,8 @@ static int print_home(const char *n) { _cleanup_free_ char *p = NULL; r = sd_path_home(i, arg_suffix, &p); - if (r < 0) { - log_error_errno(r, "Failed to query %s: %m", n); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query %s: %m", n); printf("%s\n", p); return 0; diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index c6b5915853..ff741cdc67 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -720,31 +720,23 @@ int manager_connect_bus(Manager *m) { log_debug_errno(r, "Failed to connect to bus, trying again in 5s: %m"); r = sd_event_add_time(m->event, &m->bus_retry_event_source, CLOCK_MONOTONIC, now(CLOCK_MONOTONIC) + 5*USEC_PER_SEC, 0, on_bus_retry, m); - if (r < 0) { - log_error_errno(r, "Failed to install bus reconnect time event: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to install bus reconnect time event: %m"); return 0; } r = sd_bus_add_object_vtable(m->bus, NULL, "/org/freedesktop/resolve1", "org.freedesktop.resolve1.Manager", resolve_vtable, m); - if (r < 0) { - log_error_errno(r, "Failed to register object: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register object: %m"); r = sd_bus_request_name(m->bus, "org.freedesktop.resolve1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(m->bus, m->event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); r = sd_bus_add_match(m->bus, &m->prepare_for_sleep_slot, "type='signal'," diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c index a3631f08a8..1ce2bb4366 100644 --- a/src/resolve/resolved-dns-scope.c +++ b/src/resolve/resolved-dns-scope.c @@ -721,10 +721,8 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) { r = ordered_hashmap_put(scope->conflict_queue, rr->key, rr); if (r == -EEXIST || r == 0) return 0; - if (r < 0) { - log_debug_errno(r, "Failed to queue conflicting RR: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "Failed to queue conflicting RR: %m"); dns_resource_record_ref(rr); @@ -740,10 +738,8 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) { now(clock_boottime_or_monotonic()) + jitter, LLMNR_JITTER_INTERVAL_USEC, on_conflict_dispatch, scope); - if (r < 0) { - log_debug_errno(r, "Failed to add conflict dispatch event: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "Failed to add conflict dispatch event: %m"); return 0; } diff --git a/src/run/run.c b/src/run/run.c index 8c7bd5c92d..b96517a99a 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -498,10 +498,8 @@ static int start_transient_scope( gid_t gid; r = get_group_creds(&arg_exec_group, &gid); - if (r < 0) { - log_error_errno(r, "Failed to resolve group %s: %m", arg_exec_group); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to resolve group %s: %m", arg_exec_group); if (setresgid(gid, gid, gid) < 0) { log_error("Failed to change GID to " GID_FMT ": %m", gid); @@ -515,10 +513,8 @@ static int start_transient_scope( gid_t gid; r = get_user_creds(&arg_exec_user, &uid, &gid, &home, &shell); - if (r < 0) { - log_error_errno(r, "Failed to resolve user %s: %m", arg_exec_user); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to resolve user %s: %m", arg_exec_user); r = strv_extendf(&user_env, "HOME=%s", home); if (r < 0) diff --git a/src/shared/capability.c b/src/shared/capability.c index 89e61430b0..b7e055318a 100644 --- a/src/shared/capability.c +++ b/src/shared/capability.c @@ -254,10 +254,8 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) { } r = capability_bounding_set_drop(~keep_capabilities, true); - if (r < 0) { - log_error_errno(r, "Failed to drop capabilities: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to drop capabilities: %m"); d = cap_init(); if (!d) diff --git a/src/shared/generator.c b/src/shared/generator.c index f54bb06f68..2cb4d111f1 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -54,10 +54,8 @@ int generator_write_fsck_deps( /* treat missing check as essentially OK */ log_debug_errno(r, "Checking was requested for %s, but fsck.%s does not exist: %m", what, fstype); return 0; - } else if (r < 0) { - log_warning_errno(r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype); - return r; - } + } else if (r < 0) + return log_warning_errno(r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype); } if (streq(where, "/")) { diff --git a/src/shared/install.c b/src/shared/install.c index 9094662dfc..af35b29df3 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -1553,10 +1553,8 @@ int unit_file_add_dependency( UnitFileState state; state = unit_file_get_state(scope, root_dir, *i); - if (state < 0) { - log_error_errno(state, "Failed to get unit file state for %s: %m", *i); - return state; - } + if (state < 0) + return log_error_errno(state, "Failed to get unit file state for %s: %m", *i); if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) { log_error("Failed to enable unit: Unit %s is masked", *i); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 16ea1bb782..2da4ef3e12 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -295,10 +295,8 @@ static int output_short( if (r < 0) r = sd_journal_get_monotonic_usec(j, &t, &boot_id); - if (r < 0) { - log_error_errno(r, "Failed to get monotonic timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get monotonic timestamp: %m"); fprintf(f, "[%5llu.%06llu]", (unsigned long long) (t / USEC_PER_SEC), @@ -322,10 +320,8 @@ static int output_short( if (r < 0) r = sd_journal_get_realtime_usec(j, &x); - if (r < 0) { - log_error_errno(r, "Failed to get realtime timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get realtime timestamp: %m"); t = (time_t) (x / USEC_PER_SEC); @@ -440,10 +436,8 @@ static int output_verbose( } r = sd_journal_get_cursor(j, &cursor); - if (r < 0) { - log_error_errno(r, "Failed to get cursor: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get cursor: %m"); fprintf(f, "%s [%s]\n", flags & OUTPUT_UTC ? @@ -515,22 +509,16 @@ static int output_export( sd_journal_set_data_threshold(j, 0); r = sd_journal_get_realtime_usec(j, &realtime); - if (r < 0) { - log_error_errno(r, "Failed to get realtime timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get realtime timestamp: %m"); r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id); - if (r < 0) { - log_error_errno(r, "Failed to get monotonic timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get monotonic timestamp: %m"); r = sd_journal_get_cursor(j, &cursor); - if (r < 0) { - log_error_errno(r, "Failed to get cursor: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get cursor: %m"); fprintf(f, "__CURSOR=%s\n" @@ -655,22 +643,16 @@ static int output_json( sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : JSON_THRESHOLD); r = sd_journal_get_realtime_usec(j, &realtime); - if (r < 0) { - log_error_errno(r, "Failed to get realtime timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get realtime timestamp: %m"); r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id); - if (r < 0) { - log_error_errno(r, "Failed to get monotonic timestamp: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get monotonic timestamp: %m"); r = sd_journal_get_cursor(j, &cursor); - if (r < 0) { - log_error_errno(r, "Failed to get cursor: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get cursor: %m"); if (mode == OUTPUT_JSON_PRETTY) fprintf(f, @@ -1224,24 +1206,18 @@ int add_match_this_boot(sd_journal *j, const char *machine) { if (machine) { r = get_boot_id_for_machine(machine, &boot_id); - if (r < 0) { - log_error_errno(r, "Failed to get boot id of container %s: %m", machine); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get boot id of container %s: %m", machine); } else { r = sd_id128_get_boot(&boot_id); - if (r < 0) { - log_error_errno(r, "Failed to get boot id: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get boot id: %m"); } sd_id128_to_string(boot_id, match + 9); r = sd_journal_add_match(j, match, strlen(match)); - if (r < 0) { - log_error_errno(r, "Failed to add match: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match: %m"); r = sd_journal_add_conjunction(j); if (r < 0) diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c index 7a03ac0c51..815b90fdfb 100644 --- a/src/shared/socket-label.c +++ b/src/shared/socket-label.c @@ -161,10 +161,8 @@ int make_socket_fd(int log_level, const char* address, int flags) { _cleanup_free_ char *p = NULL; r = socket_address_print(&a, &p); - if (r < 0) { - log_error_errno(r, "socket_address_print(): %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "socket_address_print(): %m"); if (fd < 0) log_error_errno(fd, "Failed to listen on %s: %m", p); diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 0bb34f7826..6bdcb99205 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -636,10 +636,8 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret) int saved_errno = errno; r = sockaddr_pretty(&sa->sa, salen, true, &ret); - if (r < 0) { - log_error_errno(r, "sockadd_pretty() failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "sockadd_pretty() failed: %m"); log_debug_errno(saved_errno, "getnameinfo(%s) failed: %m", ret); } else { diff --git a/src/shared/util.c b/src/shared/util.c index 646787cd79..74dd4b7f4e 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -3795,10 +3795,8 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) { assert(pid > 1); r = wait_for_terminate(pid, &status); - if (r < 0) { - log_warning_errno(r, "Failed to wait for %s: %m", name); - return r; - } + if (r < 0) + return log_warning_errno(r, "Failed to wait for %s: %m", name); if (status.si_code == CLD_EXITED) { if (status.si_status != 0) { @@ -5506,16 +5504,12 @@ int make_console_stdio(void) { /* Make /dev/console the controlling terminal and stdin/stdout/stderr */ fd = acquire_terminal("/dev/console", false, true, true, USEC_INFINITY); - if (fd < 0) { - log_error_errno(fd, "Failed to acquire terminal: %m"); - return fd; - } + if (fd < 0) + return log_error_errno(fd, "Failed to acquire terminal: %m"); r = make_stdio(fd); - if (r < 0) { - log_error_errno(r, "Failed to duplicate terminal fd: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to duplicate terminal fd: %m"); return 0; } diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c index 5f109f823b..cdad583bcb 100644 --- a/src/shutdownd/shutdownd.c +++ b/src/shutdownd/shutdownd.c @@ -203,20 +203,16 @@ static int update_schedule_file(struct sd_shutdown_command *c) { assert(c); r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0); - if (r < 0) { - log_error_errno(r, "Failed to create shutdown subdirectory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create shutdown subdirectory: %m"); t = cescape(c->wall_message); if (!t) return log_oom(); r = fopen_temporary("/run/systemd/shutdown/scheduled", &f, &temp_path); - if (r < 0) { - log_error_errno(r, "Failed to save information about scheduled shutdowns: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to save information about scheduled shutdowns: %m"); fchmod(fileno(f), 0644); diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index eba285bba6..ca59311662 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -265,10 +265,8 @@ static int connection_enable_event_sources(Connection *c) { else r = 0; - if (r < 0) { - log_error_errno(r, "Failed to set up server event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set up server event source: %m"); if (c->client_event_source) r = sd_event_source_set_io_events(c->client_event_source, b); @@ -277,10 +275,8 @@ static int connection_enable_event_sources(Connection *c) { else r = 0; - if (r < 0) { - log_error_errno(r, "Failed to set up client event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set up client event source: %m"); return 0; } @@ -550,26 +546,20 @@ static int add_listen_socket(Context *context, int fd) { } r = sd_is_socket(fd, 0, SOCK_STREAM, 1); - if (r < 0) { - log_error_errno(r, "Failed to determine socket type: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to determine socket type: %m"); if (r == 0) { log_error("Passed in socket is not a stream socket."); return -EINVAL; } r = fd_nonblock(fd, true); - if (r < 0) { - log_error_errno(r, "Failed to mark file descriptor non-blocking: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to mark file descriptor non-blocking: %m"); r = sd_event_add_io(context->event, &source, fd, EPOLLIN, accept_cb, context); - if (r < 0) { - log_error_errno(r, "Failed to add event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add event source: %m"); r = set_put(context->listen, source); if (r < 0) { @@ -581,10 +571,8 @@ static int add_listen_socket(Context *context, int fd) { /* Set the watcher to oneshot in case other processes are also * watching to accept(). */ r = sd_event_source_set_enabled(source, SD_EVENT_ONESHOT); - if (r < 0) { - log_error_errno(r, "Failed to enable oneshot mode: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enable oneshot mode: %m"); return 0; } diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 4299429fbd..35d14bd267 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -1906,10 +1906,8 @@ static int get_default(sd_bus *bus, char **args) { if (!bus || avoid_bus()) { r = unit_file_get_default(arg_scope, arg_root, &_path); - if (r < 0) { - log_error_errno(r, "Failed to get default target: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get default target: %m"); path = _path; } else { @@ -1989,10 +1987,8 @@ static int set_default(sd_bus *bus, char **args) { if (!bus || avoid_bus()) { r = unit_file_set_default(arg_scope, arg_root, unit, true, &changes, &n_changes); - if (r < 0) { - log_error_errno(r, "Failed to set default target: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set default target: %m"); if (!arg_quiet) dump_unit_file_changes(changes, n_changes); @@ -2200,10 +2196,8 @@ static int cancel_job(sd_bus *bus, char **args) { int q; q = safe_atou32(*name, &id); - if (q < 0) { - log_error_errno(q, "Failed to parse job id \"%s\": %m", *name); - return q; - } + if (q < 0) + return log_error_errno(q, "Failed to parse job id \"%s\": %m", *name); q = sd_bus_message_new_method_call( bus, @@ -2431,10 +2425,8 @@ static int wait_for_jobs(sd_bus *bus, Set *s) { while (!set_isempty(s)) { q = bus_process_wait(bus); - if (q < 0) { - log_error_errno(q, "Failed to wait for response: %m"); - return q; - } + if (q < 0) + return log_error_errno(q, "Failed to wait for response: %m"); if (d.result) { q = check_wait_response(&d); @@ -2560,10 +2552,8 @@ static int check_triggering_units( STRV_FOREACH(i, triggered_by) { r = check_one_unit(bus, *i, "active\0reloading\0", true); - if (r < 0) { - log_error_errno(r, "Failed to check unit: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to check unit: %m"); if (r == 0) continue; @@ -2812,10 +2802,8 @@ static int start_unit(sd_bus *bus, char **args) { if (!arg_no_block) { r = enable_wait_for_jobs(bus); - if (r < 0) { - log_error_errno(r, "Could not watch jobs: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Could not watch jobs: %m"); s = set_new(&string_hash_ops); if (!s) @@ -3074,10 +3062,8 @@ static int check_unit_generic(sd_bus *bus, int code, const char *good_states, ch assert(args); r = expand_names(bus, args, NULL, &names); - if (r < 0) { - log_error_errno(r, "Failed to expand names: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to expand names: %m"); STRV_FOREACH(name, names) { int state; @@ -4438,10 +4424,8 @@ static int show_system_status(sd_bus *bus) { return log_oom(); r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, &mi); - if (r < 0) { - log_error_errno(r, "Failed to read server status: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read server status: %m"); if (streq_ptr(mi.state, "degraded")) { on = ansi_highlight_red(); @@ -5509,10 +5493,8 @@ static int add_dependency(sd_bus *bus, char **args) { r = unit_file_add_dependency(arg_scope, arg_runtime, arg_root, names, target, dep, arg_force, &changes, &n_changes); - if (r < 0) { - log_error_errno(r, "Can't add dependency: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Can't add dependency: %m"); if (!arg_quiet) dump_unit_file_changes(changes, n_changes); @@ -5655,10 +5637,8 @@ static int unit_is_enabled(sd_bus *bus, char **args) { UnitFileState state; state = unit_file_get_state(arg_scope, arg_root, *name); - if (state < 0) { - log_error_errno(state, "Failed to get unit file state for %s: %m", *name); - return state; - } + if (state < 0) + return log_error_errno(state, "Failed to get unit file state for %s: %m", *name); if (state == UNIT_FILE_ENABLED || state == UNIT_FILE_ENABLED_RUNTIME || diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 8811102906..3a56b6b482 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -919,10 +919,8 @@ static int add_user(Item *i) { /* Try to use the suggested numeric uid */ if (i->uid_set) { r = uid_is_ok(i->uid, i->name); - if (r < 0) { - log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); if (r == 0) { log_debug("Suggested user ID " UID_FMT " for %s already used.", i->uid, i->name); i->uid_set = false; @@ -939,10 +937,9 @@ static int add_user(Item *i) { log_debug("User ID " UID_FMT " of file not suitable for %s.", c, i->name); else { r = uid_is_ok(c, i->name); - if (r < 0) { - log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); - return r; - } else if (r > 0) { + if (r < 0) + return log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); + else if (r > 0) { i->uid = c; i->uid_set = true; } else @@ -954,10 +951,8 @@ static int add_user(Item *i) { /* Otherwise try to reuse the group ID */ if (!i->uid_set && i->gid_set) { r = uid_is_ok((uid_t) i->gid, i->name); - if (r < 0) { - log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); if (r > 0) { i->uid = (uid_t) i->gid; i->uid_set = true; @@ -974,10 +969,9 @@ static int add_user(Item *i) { } r = uid_is_ok(search_uid, i->name); - if (r < 0) { - log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); - return r; - } else if (r > 0) + if (r < 0) + return log_error_errno(r, "Failed to verify uid " UID_FMT ": %m", i->uid); + else if (r > 0) break; } @@ -1071,10 +1065,8 @@ static int add_group(Item *i) { /* Try to use the suggested numeric gid */ if (i->gid_set) { r = gid_is_ok(i->gid); - if (r < 0) { - log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); if (r == 0) { log_debug("Suggested group ID " GID_FMT " for %s already used.", i->gid, i->name); i->gid_set = false; @@ -1084,10 +1076,8 @@ static int add_group(Item *i) { /* Try to reuse the numeric uid, if there's one */ if (!i->gid_set && i->uid_set) { r = gid_is_ok((gid_t) i->uid); - if (r < 0) { - log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); if (r > 0) { i->gid = (gid_t) i->uid; i->gid_set = true; @@ -1104,10 +1094,9 @@ static int add_group(Item *i) { log_debug("Group ID " GID_FMT " of file not suitable for %s.", c, i->name); else { r = gid_is_ok(c); - if (r < 0) { - log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); - return r; - } else if (r > 0) { + if (r < 0) + return log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); + else if (r > 0) { i->gid = c; i->gid_set = true; } else @@ -1127,10 +1116,9 @@ static int add_group(Item *i) { } r = gid_is_ok(search_uid); - if (r < 0) { - log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); - return r; - } else if (r > 0) + if (r < 0) + return log_error_errno(r, "Failed to verify gid " GID_FMT ": %m", i->gid); + else if (r > 0) break; } diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index 65cae0bd69..49196ca793 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -363,10 +363,8 @@ static int list_timezones(sd_bus *bus, char **args, unsigned n) { assert(n == 1); r = get_timezones(&zones); - if (r < 0) { - log_error_errno(r, "Failed to read list of time zones: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read list of time zones: %m"); pager_open_if_enabled(); strv_print(zones); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 867b29412c..56df59f9b7 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -649,28 +649,20 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) { assert(_bus); r = sd_bus_default_system(&bus); - if (r < 0) { - log_error_errno(r, "Failed to get system bus connection: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get system bus connection: %m"); r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/timedate1", "org.freedesktop.timedate1", timedate_vtable, c); - if (r < 0) { - log_error_errno(r, "Failed to register object: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register object: %m"); r = sd_bus_request_name(bus, "org.freedesktop.timedate1", 0); - if (r < 0) { - log_error_errno(r, "Failed to register name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register name: %m"); r = sd_bus_attach_event(bus, event, 0); - if (r < 0) { - log_error_errno(r, "Failed to attach bus to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to attach bus to event loop: %m"); *_bus = bus; bus = NULL; diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 8559438157..670b122836 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -187,10 +187,8 @@ static int manager_send_request(Manager *m) { if (m->server_socket < 0) { r = manager_listen_setup(m); - if (r < 0) { - log_warning_errno(r, "Failed to setup connection socket: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "Failed to setup connection socket: %m"); } /* @@ -225,10 +223,8 @@ static int manager_send_request(Manager *m) { m->retry_interval = NTP_POLL_INTERVAL_MIN_SEC * USEC_PER_SEC; r = manager_arm_timer(m, m->retry_interval); - if (r < 0) { - log_error_errno(r, "Failed to rearm timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to rearm timer: %m"); m->missed_replies++; if (m->missed_replies > NTP_MAX_MISSED_REPLIES) { @@ -238,10 +234,8 @@ static int manager_send_request(Manager *m) { clock_boottime_or_monotonic(), now(clock_boottime_or_monotonic()) + TIMEOUT_USEC, 0, manager_timeout, m); - if (r < 0) { - log_error_errno(r, "Failed to arm timeout timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to arm timeout timer: %m"); } return 0; @@ -328,10 +322,8 @@ static int manager_clock_watch_setup(Manager *m) { } r = sd_event_add_io(m->event, &m->event_clock_watch, m->clock_watch_fd, EPOLLIN, manager_clock_watch, m); - if (r < 0) { - log_error_errno(r, "Failed to create clock watch event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create clock watch event source: %m"); return 0; } @@ -698,10 +690,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re spike ? " (ignored)" : ""); r = manager_arm_timer(m, m->poll_interval_usec); - if (r < 0) { - log_error_errno(r, "Failed to rearm timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to rearm timer: %m"); return 0; } @@ -826,10 +816,8 @@ static int manager_resolve_handler(sd_resolve_query *q, int ret, const struct ad } r = server_address_new(m->current_server_name, &a, (const union sockaddr_union*) ai->ai_addr, ai->ai_addrlen); - if (r < 0) { - log_error_errno(r, "Failed to add server address: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add server address: %m"); server_address_pretty(a, &pretty); log_debug("Resolved address %s for %s.", pretty, m->current_server_name->string); @@ -867,10 +855,8 @@ int manager_connect(Manager *m) { log_debug("Slowing down attempts to contact servers."); r = sd_event_add_time(m->event, &m->event_retry, clock_boottime_or_monotonic(), now(clock_boottime_or_monotonic()) + RETRY_USEC, 0, manager_retry_connect, m); - if (r < 0) { - log_error_errno(r, "Failed to create retry timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create retry timer: %m"); return 0; } @@ -923,10 +909,8 @@ int manager_connect(Manager *m) { if (restart && !m->exhausted_servers && m->poll_interval_usec) { log_debug("Waiting after exhausting servers."); r = sd_event_add_time(m->event, &m->event_retry, clock_boottime_or_monotonic(), now(clock_boottime_or_monotonic()) + m->poll_interval_usec, 0, manager_retry_connect, m); - if (r < 0) { - log_error_errno(r, "Failed to create retry timer: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create retry timer: %m"); m->exhausted_servers = true; @@ -952,10 +936,8 @@ int manager_connect(Manager *m) { log_debug("Resolving %s...", m->current_server_name->string); r = sd_resolve_getaddrinfo(m->resolve, &m->resolve_query, m->current_server_name->string, "123", &hints, manager_resolve_handler, m); - if (r < 0) { - log_error_errno(r, "Failed to create resolver: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create resolver: %m"); return 1; } diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 34a644b26b..1a4f02db33 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -710,10 +710,8 @@ static int create_item(Item *i) { } if (r < 0) { - if (r != -EEXIST) { - log_error_errno(r, "Failed to create directory %s: %m", i->path); - return r; - } + if (r != -EEXIST) + return log_error_errno(r, "Failed to create directory %s: %m", i->path); if (stat(i->path, &st) < 0) { log_error("stat(%s) failed: %m", i->path); @@ -761,10 +759,8 @@ static int create_item(Item *i) { mac_selinux_create_file_clear(); } - if (r < 0) { - log_error_errno(r, "Failed to create fifo %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create fifo %s: %m", i->path); } else { log_debug("%s is not a fifo.", i->path); return 0; @@ -800,10 +796,8 @@ static int create_item(Item *i) { r = symlink_atomic(i->argument, i->path); mac_selinux_create_file_clear(); - if (r < 0) { - log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path); } else { log_debug("%s is not a symlink or does not point to the correct path.", i->path); return 0; @@ -862,10 +856,8 @@ static int create_item(Item *i) { mac_selinux_create_file_clear(); } - if (r < 0) { - log_error_errno(r, "Failed to create device node %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create device node %s: %m", i->path); } else { log_debug("%s is not a device node.", i->path); return 0; @@ -938,10 +930,8 @@ static int remove_item_instance(Item *i, const char *instance) { /* FIXME: we probably should use dir_cleanup() here * instead of rm_rf() so that 'x' is honoured. */ r = rm_rf_dangerous(instance, false, i->type == RECURSIVE_REMOVE_PATH, false); - if (r < 0 && r != -ENOENT) { - log_error_errno(r, "rm_rf(%s): %m", instance); - return r; - } + if (r < 0 && r != -ENOENT) + return log_error_errno(r, "rm_rf(%s): %m", instance); break; } @@ -1397,10 +1387,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } r = hashmap_put(h, i->path, i); - if (r < 0) { - log_error_errno(r, "Failed to insert item %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to insert item %s: %m", i->path); i = NULL; /* avoid cleanup */ diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 12b88fbff0..44da9a8c25 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -338,10 +338,8 @@ static int parse_password(const char *filename, char **wall) { /* If the query went away, that's OK */ return 0; - if (r < 0) { - log_error_errno(r, "Failed to query password: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query password: %m"); socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0); if (socket_fd < 0) { diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c index 4608a6c982..ec67126b21 100644 --- a/src/udev/net/ethtool-util.c +++ b/src/udev/net/ethtool-util.c @@ -75,10 +75,8 @@ int ethtool_get_driver(int *fd, const char *ifname, char **ret) { if (*fd < 0) { r = ethtool_connect(fd); - if (r < 0) { - log_warning_errno(r, "link_config: could not connect to ethtool: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "link_config: could not connect to ethtool: %m"); } strscpy(ifr.ifr_name, IFNAMSIZ, ifname); @@ -111,10 +109,8 @@ int ethtool_set_speed(int *fd, const char *ifname, unsigned int speed, Duplex du if (*fd < 0) { r = ethtool_connect(fd); - if (r < 0) { - log_warning_errno(r, "link_config: could not connect to ethtool: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "link_config: could not connect to ethtool: %m"); } strscpy(ifr.ifr_name, IFNAMSIZ, ifname); @@ -171,10 +167,8 @@ int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) { if (*fd < 0) { r = ethtool_connect(fd); - if (r < 0) { - log_warning_errno(r, "link_config: could not connect to ethtool: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "link_config: could not connect to ethtool: %m"); } strscpy(ifr.ifr_name, IFNAMSIZ, ifname); diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index 5aac5bca49..739bb185e9 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -202,10 +202,8 @@ int link_config_load(link_config_ctx *ctx) { paths_check_timestamp(link_dirs, &ctx->link_dirs_ts_usec, true); r = conf_files_list_strv(&files, ".link", NULL, link_dirs); - if (r < 0) { - log_error_errno(r, "failed to enumerate link files: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "failed to enumerate link files: %m"); STRV_FOREACH_BACKWARDS(f, files) { r = load_link(ctx, *f); @@ -421,10 +419,8 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, r = rtnl_set_link_properties(&ctx->rtnl, ifindex, config->alias, mac, config->mtu); - if (r < 0) { - log_warning_errno(r, "Could not set Alias, MACAddress or MTU on %s: %m", old_name); - return r; - } + if (r < 0) + return log_warning_errno(r, "Could not set Alias, MACAddress or MTU on %s: %m", old_name); *name = new_name; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 2917c32413..5a7b65aff3 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -775,10 +775,8 @@ static int rename_netif(struct udev_event *event) { strscpy(name, IFNAMSIZ, event->name); r = rtnl_set_link_name(&event->rtnl, udev_device_get_ifindex(dev), name); - if (r < 0) { - log_error_errno(r, "Error changing net interface name '%s' to '%s': %m", oldname, name); - return r; - } + if (r < 0) + return log_error_errno(r, "Error changing net interface name '%s' to '%s': %m", oldname, name); log_debug("renamed network interface '%s' to '%s'", oldname, name); diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 55587fd5a8..beb5dc6ef1 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -2652,10 +2652,8 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) { strscpyl(tags_dir, sizeof(tags_dir), "/run/udev/static_node-tags/", *t, "/", NULL); r = mkdir_p(tags_dir, 0755); - if (r < 0) { - log_error_errno(r, "failed to create %s: %m", tags_dir); - return r; - } + if (r < 0) + return log_error_errno(r, "failed to create %s: %m", tags_dir); unescaped_filename = xescape(rules_str(rules, cur->key.value_off), "/."); diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c index 1d7bebeb41..93c14d82fe 100644 --- a/src/update-utmp/update-utmp.c +++ b/src/update-utmp/update-utmp.c @@ -189,10 +189,8 @@ static int on_runlevel(Context *c) { q = utmp_get_runlevel(&previous, NULL); if (q < 0) { - if (q != -ESRCH && q != -ENOENT) { - log_error_errno(q, "Failed to get current runlevel: %m"); - return q; - } + if (q != -ESRCH && q != -ENOENT) + return log_error_errno(q, "Failed to get current runlevel: %m"); previous = 0; } |