diff options
43 files changed, 331 insertions, 658 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c index a17babe076..909ea24cc0 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -100,8 +100,7 @@ static int open_sockets(int *epoll_fd, bool accept) { fd = make_socket_fd(LOG_DEBUG, *address, SOCK_STREAM | (arg_accept*SOCK_CLOEXEC)); if (fd < 0) { log_open(); - log_error_errno(fd, "Failed to open '%s': %m", *address); - return fd; + return log_error_errno(fd, "Failed to open '%s': %m", *address); } assert(fd == SD_LISTEN_FDS_START + count); diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c index 3458d804b1..f569109268 100644 --- a/src/analyze/analyze-verify.c +++ b/src/analyze/analyze-verify.c @@ -221,18 +221,14 @@ int verify_units(char **filenames, SystemdRunningAs running_as, bool check_man) /* set the path */ r = generate_path(&var, filenames); - if (r < 0) { - log_error_errno(r, "Failed to generate unit load path: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to generate unit load path: %m"); assert_se(set_unit_path(var) >= 0); r = manager_new(running_as, true, &m); - if (r < 0) { - log_error_errno(r, "Failed to initalize manager: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to initalize manager: %m"); log_debug("Starting manager..."); diff --git a/src/binfmt/binfmt.c b/src/binfmt/binfmt.c index 7fb0664988..cbba42f6dc 100644 --- a/src/binfmt/binfmt.c +++ b/src/binfmt/binfmt.c @@ -64,10 +64,8 @@ static int apply_rule(const char *rule) { delete_rule(rule); r = write_string_file("/proc/sys/fs/binfmt_misc/register", rule); - if (r < 0) { - log_error_errno(r, "Failed to add binary format: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add binary format: %m"); return 0; } @@ -83,8 +81,7 @@ static int apply_file(const char *path, bool ignore_enoent) { if (ignore_enoent && r == -ENOENT) return 0; - log_error_errno(r, "Failed to open file '%s', ignoring: %m", path); - return r; + return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path); } log_debug("apply: %s", path); diff --git a/src/bus-proxyd/bus-policy.c b/src/bus-proxyd/bus-policy.c index 15acae2a38..13322ea514 100644 --- a/src/bus-proxyd/bus-policy.c +++ b/src/bus-proxyd/bus-policy.c @@ -95,8 +95,7 @@ static int file_load(Policy *p, const char *path) { if (r == -EISDIR) return r; - log_error_errno(r, "Failed to load %s: %m", path); - return r; + return log_error_errno(r, "Failed to load %s: %m", path); } q = c; @@ -105,10 +104,8 @@ static int file_load(Policy *p, const char *path) { int t; t = xml_tokenize(&q, &name, &xml_state, &line); - if (t < 0) { - log_error_errno(t, "XML parse failure in %s: %m", path); - return t; - } + if (t < 0) + return log_error_errno(t, "XML parse failure in %s: %m", path); switch (state) { @@ -894,10 +891,8 @@ int policy_load(Policy *p, char **files) { char **j; r = conf_files_list(&l, ".conf", NULL, *i, NULL); - if (r < 0) { - log_error_errno(r, "Failed to get configuration file list: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get configuration file list: %m"); STRV_FOREACH(j, l) file_load(p, *j); diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index d2acb788d3..4f3adf72d1 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -1155,34 +1155,24 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell return 0; r = sd_bus_message_new_method_return(m, &n); - if (r < 0) { - log_error_errno(r, "Failed to generate HELLO reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to generate HELLO reply: %m"); r = sd_bus_message_append(n, "s", a->unique_name); - if (r < 0) { - log_error_errno(r, "Failed to append unique name to HELLO reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append unique name to HELLO reply: %m"); r = bus_message_append_sender(n, "org.freedesktop.DBus"); - if (r < 0) { - log_error_errno(r, "Failed to append sender to HELLO reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append sender to HELLO reply: %m"); r = bus_seal_synthetic_message(b, n); - if (r < 0) { - log_error_errno(r, "Failed to seal HELLO reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to seal HELLO reply: %m"); r = sd_bus_send(b, n, NULL); - if (r < 0) { - log_error_errno(r, "Failed to send HELLO reply: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to send HELLO reply: %m"); n = sd_bus_message_unref(n); r = sd_bus_message_new_signal( @@ -1191,34 +1181,24 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell "/org/freedesktop/DBus", "org.freedesktop.DBus", "NameAcquired"); - if (r < 0) { - log_error_errno(r, "Failed to allocate initial NameAcquired message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate initial NameAcquired message: %m"); r = sd_bus_message_append(n, "s", a->unique_name); - if (r < 0) { - log_error_errno(r, "Failed to append unique name to NameAcquired message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append unique name to NameAcquired message: %m"); r = bus_message_append_sender(n, "org.freedesktop.DBus"); - if (r < 0) { - log_error_errno(r, "Failed to append sender to NameAcquired message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to append sender to NameAcquired message: %m"); r = bus_seal_synthetic_message(b, n); - if (r < 0) { - log_error_errno(r, "Failed to seal NameAcquired message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to seal NameAcquired message: %m"); r = sd_bus_send(b, n, NULL); - if (r < 0) { - log_error_errno(r, "Failed to send NameAcquired message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to send NameAcquired message: %m"); return 1; } diff --git a/src/core/busname.c b/src/core/busname.c index 7e7f7b384c..99641ec418 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -303,10 +303,8 @@ static int busname_open_fd(BusName *n) { mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user"; n->starter_fd = bus_kernel_open_bus_fd(mode, &path); - if (n->starter_fd < 0) { - log_unit_warning_errno(UNIT(n)->id, n->starter_fd, "Failed to open %s: %m", path ?: "kdbus"); - return n->starter_fd; - } + if (n->starter_fd < 0) + return log_unit_warning_errno(UNIT(n)->id, n->starter_fd, "Failed to open %s: %m", path ?: "kdbus"); return 0; } diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 02c4e0a419..c24bfc8d33 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -630,10 +630,8 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) { /* First, create our own group */ r = cg_create_everywhere(u->manager->cgroup_supported, mask, u->cgroup_path); - if (r < 0) { - log_error_errno(r, "Failed to create cgroup %s: %m", u->cgroup_path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create cgroup %s: %m", u->cgroup_path); /* Keep track that this is now realized */ u->cgroup_realized = true; @@ -857,10 +855,8 @@ int manager_setup_cgroup(Manager *m) { m->cgroup_root = NULL; r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 0, &m->cgroup_root); - if (r < 0) { - log_error_errno(r, "Cannot determine cgroup we are running in: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot determine cgroup we are running in: %m"); /* LEGACY: Already in /system.slice? If so, let's cut this * off. This is to support live upgrades from older systemd @@ -883,10 +879,8 @@ int manager_setup_cgroup(Manager *m) { /* 2. Show data */ r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, NULL, &path); - if (r < 0) { - log_error_errno(r, "Cannot find cgroup mount point: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot find cgroup mount point: %m"); log_debug("Using cgroup controller " SYSTEMD_CGROUP_CONTROLLER ". File system hierarchy is at %s.", path); if (!m->test_run) { @@ -904,10 +898,8 @@ int manager_setup_cgroup(Manager *m) { /* 4. Make sure we are in the root cgroup */ r = cg_create_and_attach(SYSTEMD_CGROUP_CONTROLLER, m->cgroup_root, 0); - if (r < 0) { - log_error_errno(r, "Failed to create root cgroup hierarchy: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create root cgroup hierarchy: %m"); /* 5. And pin it, so that it cannot be unmounted */ safe_close(m->pin_cgroupfs_fd); diff --git a/src/core/dbus.c b/src/core/dbus.c index b843fe09f3..7291bdc3f3 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -202,10 +202,8 @@ failed: } r = sd_bus_send_to(bus, reply, "org.freedesktop.DBus", NULL); - if (r < 0) { - log_error_errno(r, "Failed to respond with to bus activation request: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to respond with to bus activation request: %m"); return 0; } @@ -537,77 +535,55 @@ static int bus_setup_api_vtables(Manager *m, sd_bus *bus) { #ifdef HAVE_SELINUX r = sd_bus_add_filter(bus, NULL, mac_selinux_filter, m); - if (r < 0) { - log_error_errno(r, "Failed to add SELinux access filter: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add SELinux access filter: %m"); #endif r = sd_bus_add_object_vtable(bus, NULL, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", bus_manager_vtable, m); - if (r < 0) { - log_error_errno(r, "Failed to register Manager vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register Manager vtable: %m"); r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/job", "org.freedesktop.systemd1.Job", bus_job_vtable, bus_job_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register Job vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register Job vtable: %m"); r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/job", bus_job_enumerate, m); - if (r < 0) { - log_error_errno(r, "Failed to add job enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add job enumerator: %m"); r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", "org.freedesktop.systemd1.Unit", bus_unit_vtable, bus_unit_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register Unit vtable: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register Unit vtable: %m"); r = sd_bus_add_node_enumerator(bus, NULL, "/org/freedesktop/systemd1/unit", bus_unit_enumerate, m); - if (r < 0) { - log_error_errno(r, "Failed to add job enumerator: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add job enumerator: %m"); for (t = 0; t < _UNIT_TYPE_MAX; t++) { r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, unit_vtable[t]->bus_vtable, bus_unit_interface_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register type specific vtable for %s: %m", unit_vtable[t]->bus_interface); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register type specific vtable for %s: %m", unit_vtable[t]->bus_interface); if (unit_vtable[t]->cgroup_context_offset > 0) { r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_unit_cgroup_vtable, bus_unit_cgroup_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register control group unit vtable for %s: %m", unit_vtable[t]->bus_interface); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register control group unit vtable for %s: %m", unit_vtable[t]->bus_interface); r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_cgroup_vtable, bus_cgroup_context_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register control group vtable for %s: %m", unit_vtable[t]->bus_interface); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register control group vtable for %s: %m", unit_vtable[t]->bus_interface); } if (unit_vtable[t]->exec_context_offset > 0) { r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_exec_vtable, bus_exec_context_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register execute vtable for %s: %m", unit_vtable[t]->bus_interface); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register execute vtable for %s: %m", unit_vtable[t]->bus_interface); } if (unit_vtable[t]->kill_context_offset > 0) { r = sd_bus_add_fallback_vtable(bus, NULL, "/org/freedesktop/systemd1/unit", unit_vtable[t]->bus_interface, bus_kill_vtable, bus_kill_context_find, m); - if (r < 0) { - log_error_errno(r, "Failed to register kill vtable for %s: %m", unit_vtable[t]->bus_interface); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register kill vtable for %s: %m", unit_vtable[t]->bus_interface); } } @@ -630,10 +606,8 @@ static int bus_setup_disconnected_match(Manager *m, sd_bus *bus) { "member='Disconnected'", signal_disconnected, m); - if (r < 0) { - log_error_errno(r, "Failed to register match for Disconnected message: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register match for Disconnected message: %m"); return 0; } @@ -756,10 +730,8 @@ static int bus_list_names(Manager *m, sd_bus *bus) { assert(bus); r = sd_bus_list_names(bus, &names, NULL); - if (r < 0) { - log_error_errno(r, "Failed to get initial list of names: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get initial list of names: %m"); /* This is a bit hacky, we say the owner of the name is the * name itself, because we don't want the extra traffic to @@ -818,10 +790,8 @@ static int bus_setup_api(Manager *m, sd_bus *bus) { * to allow clients to synchronously wait for reexecution to * finish */ r = sd_bus_request_name(bus,"org.freedesktop.systemd1", SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_ALLOW_REPLACEMENT); - 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"); bus_list_names(m, bus); @@ -1006,10 +976,8 @@ static int bus_init_private(Manager *m) { } r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m); - if (r < 0) { - log_error_errno(r, "Failed to allocate event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate event source: %m"); m->private_listen_fd = fd; m->private_listen_event_source = s; diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c index 8da4adc9a2..7a17baaf89 100644 --- a/src/core/load-dropin.c +++ b/src/core/load-dropin.c @@ -65,15 +65,11 @@ static int iterate_dir( for (;;) { struct dirent *de; _cleanup_free_ char *f = NULL; - int k; errno = 0; de = readdir(d); - if (!de && errno != 0) { - k = errno; - log_error_errno(k, "Failed to read directory %s: %m", path); - return -k; - } + if (!de && errno != 0) + return log_error_errno(errno, "Failed to read directory %s: %m", path); if (!de) break; diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index ca8ac4ea61..98fc04dd2e 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -92,14 +92,10 @@ int loopback_setup(void) { r = start_loopback(rtnl); if (r == -EPERM) { - if (check_loopback() < 0) { - log_warning_errno(EPERM, "Failed to configure loopback device: %m"); - return -EPERM; - } - } else if (r < 0) { - log_warning_errno(r, "Failed to configure loopback device: %m"); - return r; - } + if (check_loopback() < 0) + return log_warning_errno(EPERM, "Failed to configure loopback device: %m"); + } else if (r < 0) + return log_warning_errno(r, "Failed to configure loopback device: %m"); return 0; diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c index 9ec93c2559..10965df623 100644 --- a/src/core/machine-id-setup.c +++ b/src/core/machine-id-setup.c @@ -141,10 +141,8 @@ static int generate(char id[34], const char *root) { /* If that didn't work, generate a random machine id */ r = sd_id128_randomize(&buf); - if (r < 0) { - log_error_errno(r, "Failed to open /dev/urandom: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open /dev/urandom: %m"); for (p = buf.bytes, q = id; p < buf.bytes + sizeof(buf); p++, q += 2) { q[0] = hexchar(*p >> 4); diff --git a/src/core/main.c b/src/core/main.c index 6224a7ae6b..4acf3f1882 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -231,18 +231,14 @@ static int console_setup(void) { int r; tty_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); - if (tty_fd < 0) { - log_error_errno(tty_fd, "Failed to open /dev/console: %m"); - return tty_fd; - } + if (tty_fd < 0) + return log_error_errno(tty_fd, "Failed to open /dev/console: %m"); /* We don't want to force text mode. plymouth may be showing * pictures already from initrd. */ r = reset_terminal_fd(tty_fd, false); - if (r < 0) { - log_error_errno(r, "Failed to reset /dev/console: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to reset /dev/console: %m"); return 0; } @@ -806,10 +802,8 @@ static int parse_argv(int argc, char *argv[]) { case ARG_UNIT: r = set_default_unit(optarg); - if (r < 0) { - log_error_errno(r, "Failed to set default unit %s: %m", optarg); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set default unit %s: %m", optarg); break; @@ -1070,10 +1064,8 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) { /* Bump up the resource limit for ourselves substantially */ nl.rlim_cur = nl.rlim_max = 64*1024; r = setrlimit_closest(RLIMIT_NOFILE, &nl); - if (r < 0) { - log_error_errno(r, "Setting RLIMIT_NOFILE failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Setting RLIMIT_NOFILE failed: %m"); return 0; } diff --git a/src/core/manager.c b/src/core/manager.c index f934594480..7b6172896d 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -302,10 +302,8 @@ static int manager_watch_idle_pipe(Manager *m) { return 0; r = sd_event_add_io(m->event, &m->idle_pipe_event_source, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m); - if (r < 0) { - log_error_errno(r, "Failed to watch idle pipe: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to watch idle pipe: %m"); return 0; } @@ -348,10 +346,8 @@ static int manager_setup_time_change(Manager *m) { } r = sd_event_add_io(m->event, &m->time_change_event_source, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m); - if (r < 0) { - log_error_errno(r, "Failed to create time change event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create time change event source: %m"); log_debug("Set up TFD_TIMER_CANCEL_ON_SET timerfd."); @@ -704,10 +700,8 @@ static int manager_setup_notify(Manager *m) { /* Process signals a bit earlier than SIGCHLD, so that we can * still identify to which service an exit message belongs */ r = sd_event_source_set_priority(m->notify_event_source, -7); - if (r < 0) { - log_error_errno(r, "Failed to set priority of notify event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to set priority of notify event source: %m"); } return 0; @@ -1986,10 +1980,8 @@ int manager_loop(Manager *m) { wait_usec = USEC_INFINITY; r = sd_event_run(m->event, wait_usec); - 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"); } return m->exit_code; diff --git a/src/core/scope.c b/src/core/scope.c index 19b274a267..d33b891956 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -289,10 +289,8 @@ static int scope_start(Unit *u) { return -ENOENT; r = unit_realize_cgroup(u); - if (r < 0) { - log_error_errno(r, "Failed to realize cgroup: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to realize cgroup: %m"); r = cg_attach_many_everywhere(u->manager->cgroup_supported, u->cgroup_path, UNIT(s)->pids); if (r < 0) diff --git a/src/core/timer.c b/src/core/timer.c index fc474f78ea..fa134b13ad 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -147,10 +147,8 @@ static int timer_setup_persistent(Timer *t) { _cleanup_free_ char *h = NULL; r = get_home_dir(&h); - if (r < 0) { - log_error_errno(r, "Failed to determine home directory: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to determine home directory: %m"); t->stamp_path = strjoin(h, "/.local/share/systemd/timers/stamp-", UNIT(t)->id, NULL); } diff --git a/src/core/transaction.c b/src/core/transaction.c index d378389999..66ee90b7b2 100644 --- a/src/core/transaction.c +++ b/src/core/transaction.c @@ -722,10 +722,8 @@ int transaction_activate(Transaction *tr, Manager *m, JobMode mode, sd_bus_error /* Tenth step: apply changes */ r = transaction_apply(tr, m, mode); - if (r < 0) { - log_warning_errno(r, "Failed to apply transaction: %m"); - return r; - } + if (r < 0) + return log_warning_errno(r, "Failed to apply transaction: %m"); assert(hashmap_isempty(tr->jobs)); diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c index 1b408ea447..c281001e74 100644 --- a/src/cryptsetup/cryptsetup-generator.c +++ b/src/cryptsetup/cryptsetup-generator.c @@ -254,10 +254,8 @@ static int create_disk( r = write_drop_in(arg_dest, dmname, 90, "device-timeout", "# Automatically generated by systemd-cryptsetup-generator \n\n" "[Unit]\nJobTimeoutSec=0"); - if (r < 0) { - log_error_errno(r, "Failed to write device drop-in: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write device drop-in: %m"); } return 0; diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 487eb111a8..21b1260f1b 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -280,10 +280,8 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char id = strappenda("cryptsetup:", escaped_name); r = ask_password_auto(text, "drive-harddisk", id, until, accept_cached, passwords); - 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"); if (arg_verify) { _cleanup_strv_free_ char **passwords2 = NULL; @@ -296,10 +294,8 @@ static int get_password(const char *name, usec_t until, bool accept_cached, char id = strappenda("cryptsetup-verification:", escaped_name); r = ask_password_auto(text, "drive-harddisk", id, until, false, &passwords2); - if (r < 0) { - log_error_errno(r, "Failed to query verification password: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query verification password: %m"); assert(strv_length(passwords2) == 1); @@ -438,10 +434,8 @@ static int attach_luks_or_plain(struct crypt_device *cd, pass_volume_key = (params.hash == NULL); } - if (r < 0) { - log_error_errno(r, "Loading of cryptographic parameters failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Loading of cryptographic parameters failed: %m"); log_info("Set cipher %s, mode %s, key size %i bits for device %s.", crypt_get_cipher(cd), diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c index 5d3b1a856a..21e9e9ca73 100644 --- a/src/dbus1-generator/dbus1-generator.c +++ b/src/dbus1-generator/dbus1-generator.c @@ -102,10 +102,8 @@ static int create_dbus_files( } r = fflush_and_check(f); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", a); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", a); fclose(f); f = NULL; @@ -139,10 +137,8 @@ static int create_dbus_files( service); r = fflush_and_check(f); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", b); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", b); lnk = strjoin(arg_dest_late, "/" SPECIAL_BUSNAMES_TARGET ".wants/", name, ".busname", NULL); if (!lnk) @@ -331,10 +327,8 @@ int main(int argc, char *argv[]) { path = "/usr/share/dbus-1/system-services"; type = "system"; units = SYSTEM_DATA_UNIT_PATH; - } else { - log_error_errno(r, "Failed to determine whether we are running as user or system instance: %m"); - return r; - } + } else + return log_error_errno(r, "Failed to determine whether we are running as user or system instance: %m"); r = parse_dbus_fragments(path, type); diff --git a/src/delta/delta.c b/src/delta/delta.c index 1dc81175b5..4753fb38c4 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -226,10 +226,8 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const *c = 0; r = get_files_in_directory(path, &list); - if (r < 0){ - log_error_errno(r, "Failed to enumerate %s: %m", path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate %s: %m", path); STRV_FOREACH(file, list) { Hashmap *h; diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index ac90bc2631..343f3e100e 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -166,10 +166,8 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char * unsigned u; r = ask_string(&p, "%s %s (empty to skip): ", draw_special_char(DRAW_TRIANGULAR_BULLET), text); - if (r < 0) { - log_error_errno(r, "Failed to query user: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query user: %m"); if (isempty(p)) { log_warning("No data entered, skipping."); @@ -219,10 +217,8 @@ static int prompt_locale(void) { return 0; r = get_locales(&locales); - if (r < 0) { - log_error_errno(r, "Cannot query locales list: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot query locales list: %m"); print_welcome(); @@ -262,10 +258,8 @@ static int process_locale(void) { mkdir_parents(etc_localeconf, 0755); r = copy_file("/etc/locale.conf", etc_localeconf, 0, 0644); if (r != -ENOENT) { - if (r < 0) { - log_error_errno(r, "Failed to copy %s: %m", etc_localeconf); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to copy %s: %m", etc_localeconf); log_info("%s copied.", etc_localeconf); return 0; @@ -288,10 +282,8 @@ static int process_locale(void) { mkdir_parents(etc_localeconf, 0755); r = write_env_file(etc_localeconf, locales); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", etc_localeconf); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", etc_localeconf); log_info("%s written.", etc_localeconf); return 0; @@ -308,10 +300,8 @@ static int prompt_timezone(void) { return 0; r = get_timezones(&zones); - if (r < 0) { - log_error_errno(r, "Cannot query timezone list: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot query timezone list: %m"); print_welcome(); @@ -342,10 +332,8 @@ static int process_timezone(void) { r = readlink_malloc("/etc/localtime", &p); if (r != -ENOENT) { - if (r < 0) { - log_error_errno(r, "Failed to read host timezone: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read host timezone: %m"); mkdir_parents(etc_localtime, 0755); if (symlink(p, etc_localtime) < 0) { @@ -393,10 +381,8 @@ static int prompt_hostname(void) { _cleanup_free_ char *h = NULL; r = ask_string(&h, "%s Please enter hostname for new system (empty to skip): ", draw_special_char(DRAW_TRIANGULAR_BULLET)); - if (r < 0) { - log_error_errno(r, "Failed to query hostname: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query hostname: %m"); if (isempty(h)) { log_warning("No hostname entered, skipping."); @@ -433,10 +419,8 @@ static int process_hostname(void) { mkdir_parents(etc_hostname, 0755); r = write_string_file(etc_hostname, arg_hostname); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", etc_hostname); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", etc_hostname); log_info("%s written.", etc_hostname); return 0; @@ -456,10 +440,8 @@ static int process_machine_id(void) { mkdir_parents(etc_machine_id, 0755); r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id)); - if (r < 0) { - log_error_errno(r, "Failed to write machine id: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write machine id: %m"); log_info("%s written.", etc_machine_id); return 0; @@ -489,10 +471,8 @@ static int prompt_root_password(void) { _cleanup_free_ char *a = NULL, *b = NULL; r = ask_password_tty(msg1, 0, false, NULL, &a); - if (r < 0) { - log_error_errno(r, "Failed to query root password: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to query root password: %m"); if (isempty(a)) { log_warning("No password entered, skipping."); @@ -591,10 +571,8 @@ static int process_root_password(void) { } r = write_root_shadow(etc_shadow, p); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", etc_shadow); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", etc_shadow); log_info("%s copied.", etc_shadow); return 0; @@ -609,10 +587,8 @@ static int process_root_password(void) { return 0; r = dev_urandom(raw, 16); - if (r < 0) { - log_error_errno(r, "Failed to get salt: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get salt: %m"); /* We only bother with SHA512 hashed passwords, the rest is legacy, and we don't do legacy. */ assert_cc(sizeof(table) == 64 + 1); @@ -635,10 +611,8 @@ static int process_root_password(void) { item.sp_lstchg = (long) (now(CLOCK_REALTIME) / USEC_PER_DAY); r = write_root_shadow(etc_shadow, &item); - if (r < 0) { - log_error_errno(r, "Failed to write %s: %m", etc_shadow); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write %s: %m", etc_shadow); log_info("%s written.", etc_shadow); return 0; @@ -803,10 +777,8 @@ static int parse_argv(int argc, char *argv[]) { arg_root_password = NULL; r = read_one_line_file(optarg, &arg_root_password); - if (r < 0) { - log_error_errno(r, "Failed to read %s: %m", optarg); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read %s: %m", optarg); break; @@ -870,10 +842,8 @@ static int parse_argv(int argc, char *argv[]) { case ARG_SETUP_MACHINE_ID: r = sd_id128_randomize(&arg_machine_id); - if (r < 0) { - log_error_errno(r, "Failed to generate randomized machine ID: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to generate randomized machine ID: %m"); break; diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index 177ecfa3dc..4e50151ecd 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -133,10 +133,8 @@ static int add_swap( fprintf(f, "Options=%s\n", me->mnt_opts); r = fflush_and_check(f); - if (r < 0) { - log_error_errno(r, "Failed to write unit file %s: %m", unit); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write unit file %s: %m", unit); /* use what as where, to have a nicer error message */ r = generator_write_timeouts(arg_dest, what, what, me->mnt_opts, NULL); diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 9803fca420..0e935b30b9 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -204,10 +204,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi "# Automatically generated by systemd-gpt-auto-generator\n\n" "[Unit]\n" "JobTimeoutSec=0\n"); /* the binary handles timeouts anyway */ - if (r < 0) { - log_error_errno(r, "Failed to write device drop-in: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to write device drop-in: %m"); ret = strappend("/dev/mapper/", id); if (!ret) @@ -487,10 +485,8 @@ static int enumerate_partitions(dev_t devnum) { return log_oom(); r = udev_enumerate_scan_devices(e); - if (r < 0) { - log_error_errno(r, "Failed to enumerate partitions on %s: %m", node); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate partitions on %s: %m", node); first = udev_enumerate_get_list_entry(e); udev_list_entry_foreach(item, first) { @@ -712,10 +708,8 @@ static int add_root_mount(void) { if (r == -ENOENT) { log_debug("EFI loader partition unknown, exiting."); return 0; - } else if (r < 0) { - log_error_errno(r, "Failed to read ESP partition UUID: %m"); - return r; - } + } else if (r < 0) + return log_error_errno(r, "Failed to read ESP partition UUID: %m"); /* OK, we have an ESP partition, this is fantastic, so let's * wait for a root device to show up. A udev rule will create @@ -739,10 +733,9 @@ static int add_mounts(void) { int r; r = get_block_device("/", &devno); - if (r < 0) { - log_error_errno(r, "Failed to determine block device of root file system: %m"); - return r; - } else if (r == 0) { + if (r < 0) + return log_error_errno(r, "Failed to determine block device of root file system: %m"); + else if (r == 0) { log_debug("Root file system not on a (single) block device."); return 0; } diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c index f04925288a..0b38cde169 100644 --- a/src/hostname/hostnamed.c +++ b/src/hostname/hostnamed.c @@ -645,28 +645,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/hostname1", "org.freedesktop.hostname1", hostname_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.hostname1", 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/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 723b057c1d..d39a2cc67e 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -909,10 +909,8 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } r = read_full_file(optarg, &key_pem, NULL); - if (r < 0) { - log_error_errno(r, "Failed to read key file: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read key file: %m"); assert(key_pem); break; @@ -922,10 +920,8 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } r = read_full_file(optarg, &cert_pem, NULL); - if (r < 0) { - log_error_errno(r, "Failed to read certificate file: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read certificate file: %m"); assert(cert_pem); break; @@ -936,10 +932,8 @@ static int parse_argv(int argc, char *argv[]) { return -EINVAL; } r = read_full_file(optarg, &trust_pem, NULL); - if (r < 0) { - log_error_errno(r, "Failed to read CA certificate file: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read CA certificate file: %m"); assert(trust_pem); break; #else diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c index 21309743fe..32e2d33e99 100644 --- a/src/journal-remote/journal-remote.c +++ b/src/journal-remote/journal-remote.c @@ -150,16 +150,12 @@ static int spawn_getter(const char *getter, const char *url) { assert(getter); r = strv_split_quoted(&words, getter, false); - if (r < 0) { - log_error_errno(r, "Failed to split getter option: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to split getter option: %m"); r = strv_extend(&words, url); - if (r < 0) { - log_error_errno(r, "Failed to create command line: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create command line: %m"); r = spawn_child(words[0], words); if (r < 0) @@ -836,10 +832,8 @@ static int remoteserver_init(RemoteServer *s, } r = sd_event_default(&s->events); - if (r < 0) { - log_error_errno(r, "Failed to allocate event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to allocate event loop: %m"); setup_signals(s); @@ -875,10 +869,8 @@ static int remoteserver_init(RemoteServer *s, char *hostname; r = getnameinfo_pretty(fd, &hostname); - if (r < 0) { - log_error_errno(r, "Failed to retrieve remote name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve remote name: %m"); log_info("Received a connection socket (fd:%d) from %s", fd, hostname); @@ -889,11 +881,9 @@ static int remoteserver_init(RemoteServer *s, return -EINVAL; } - if(r < 0) { - log_error_errno(r, "Failed to register socket (fd:%d): %m", - fd); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to register socket (fd:%d): %m", + fd); } if (arg_url) { diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c index 03a594cffb..277e125403 100644 --- a/src/journal-remote/microhttpd-util.c +++ b/src/journal-remote/microhttpd-util.c @@ -170,17 +170,13 @@ static int verify_cert_authorized(gnutls_session_t session) { int r; r = gnutls_certificate_verify_peers2(session, &status); - if (r < 0) { - log_error_errno(r, "gnutls_certificate_verify_peers2 failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "gnutls_certificate_verify_peers2 failed: %m"); type = gnutls_certificate_type_get(session); r = gnutls_certificate_verification_status_print(status, type, &out, 0); - if (r < 0) { - log_error_errno(r, "gnutls_certificate_verification_status_print failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "gnutls_certificate_verification_status_print failed: %m"); log_info("Certificate status: %s", out.data); diff --git a/src/journal/coredump.c b/src/journal/coredump.c index 32fa7be0aa..c22d0b0471 100644 --- a/src/journal/coredump.c +++ b/src/journal/coredump.c @@ -312,10 +312,8 @@ static int save_external_coredump( assert(ret_size); r = make_filename(info, &fn); - if (r < 0) { - log_error_errno(r, "Failed to determine coredump file name: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to determine coredump file name: %m"); tmp = tempfn_random(fn); if (!tmp) @@ -445,10 +443,8 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s memcpy(field, "COREDUMP=", 9); n = read(fd, field + 9, size); - if (n < 0) { - log_error_errno(n, "Failed to read core data: %m"); - return (int) n; - } + if (n < 0) + return log_error_errno((int) n, "Failed to read core data: %m"); if ((size_t) n < size) { log_error("Core data too short."); return -EIO; diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index edc12fead6..7e87f5f21d 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -116,8 +116,7 @@ static int add_match(Set *set, const char *match) { return 0; fail: - log_error_errno(r, "Failed to add match: %m"); - return r; + return log_error_errno(r, "Failed to add match: %m"); } static void help(void) { @@ -326,10 +325,8 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) { } r = sd_journal_get_realtime_usec(j, &t); - 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"); format_timestamp(buf, sizeof(buf), t); present = filename && access(filename, F_OK) == 0; @@ -521,10 +518,8 @@ static int focus(sd_journal *j) { r = sd_journal_seek_tail(j); if (r == 0) r = sd_journal_previous(j); - if (r < 0) { - log_error_errno(r, "Failed to search journal: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to search journal: %m"); if (r == 0) { log_error("No match found."); return -ESRCH; @@ -704,10 +699,8 @@ static int dump_core(sd_journal* j) { } r = save_core(j, output ? fileno(output) : STDOUT_FILENO, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Coredump retrieval failed: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Coredump retrieval failed: %m"); r = sd_journal_previous(j); if (r >= 0) @@ -735,10 +728,8 @@ static int run_gdb(sd_journal *j) { fputs("\n", stdout); r = sd_journal_get_data(j, "COREDUMP_EXE", (const void**) &data, &len); - if (r < 0) { - log_error_errno(r, "Failed to retrieve COREDUMP_EXE field: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve COREDUMP_EXE field: %m"); assert(len > strlen("COREDUMP_EXE=")); data += strlen("COREDUMP_EXE="); @@ -759,10 +750,8 @@ static int run_gdb(sd_journal *j) { } r = save_core(j, -1, &path, &unlink_path); - if (r < 0) { - log_error_errno(r, "Failed to retrieve core: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to retrieve core: %m"); pid = fork(); if (pid < 0) { diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 96b0ddd80f..d6e6332915 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -501,10 +501,8 @@ static int parse_argv(int argc, char *argv[]) { case ARG_FILE: r = glob_extend(&arg_file, optarg); - if (r < 0) { - log_error_errno(r, "Failed to add paths: %m"); - return r; - }; + if (r < 0) + return log_error_errno(r, "Failed to add paths: %m"); break; case ARG_ROOT: @@ -749,10 +747,8 @@ static int generate_new_id128(void) { unsigned i; r = sd_id128_randomize(&id); - if (r < 0) { - log_error_errno(r, "Failed to generate ID: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to generate ID: %m"); printf("As string:\n" SD_ID128_FORMAT_STR "\n\n" @@ -851,10 +847,8 @@ static int add_matches(sd_journal *j, char **args) { have_term = true; } - if (r < 0) { - log_error_errno(r, "Failed to add match '%s': %m", *i); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add match '%s': %m", *i); } if (!strv_isempty(args) && !have_term) { @@ -1040,10 +1034,8 @@ static int add_boot(sd_journal *j) { sd_id128_to_string(arg_boot_id, match + 9); r = sd_journal_add_match(j, match, sizeof(match) - 1); - 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) @@ -1060,10 +1052,8 @@ static int add_dmesg(sd_journal *j) { return 0; r = sd_journal_add_match(j, "_TRANSPORT=kernel", strlen("_TRANSPORT=kernel")); - 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) @@ -1263,10 +1253,8 @@ static int add_priorities(sd_journal *j) { match[sizeof(match)-2] = '0' + i; 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); @@ -1327,16 +1315,12 @@ static int setup_keys(void) { } r = sd_id128_get_machine(&machine); - if (r < 0) { - log_error_errno(r, "Failed to get machine ID: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get machine ID: %m"); r = sd_id128_get_boot(&boot); - 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"); if (asprintf(&p, "/var/log/journal/" SD_ID128_FORMAT_STR "/fss", SD_ID128_FORMAT_VAL(machine)) < 0) @@ -1681,10 +1665,8 @@ static int flush_to_var(void) { /* OK, let's actually do the full logic, send SIGUSR1 to the * daemon and set up inotify to wait for the flushed file to appear */ r = bus_open_system_systemd(&bus); - if (r < 0) { - log_error_errno(r, "Failed to get D-Bus connection: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get D-Bus connection: %m"); r = sd_bus_call_method( bus, @@ -1724,16 +1706,12 @@ static int flush_to_var(void) { } r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY); - if (r < 0) { - log_error_errno(r, "Failed to wait for event: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to wait for event: %m"); r = flush_fd(watch_fd); - if (r < 0) { - log_error_errno(r, "Failed to flush inotify events: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to flush inotify events: %m"); } return 0; diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c index bd985f0e9d..18235d9308 100644 --- a/src/journal/journald-audit.c +++ b/src/journal/journald-audit.c @@ -308,10 +308,8 @@ static int map_all_fields( continue; r = m->map(m->journal_field, &v, iov, n_iov_allocated, n_iov); - if (r < 0) { - log_debug_errno(r, "Failed to parse audit array: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "Failed to parse audit array: %m"); if (r > 0) { mapped = true; @@ -322,10 +320,8 @@ static int map_all_fields( if (!mapped) { r = map_generic_field(prefix, &p, iov, n_iov_allocated, n_iov); - if (r < 0) { - log_debug_errno(r, "Failed to parse audit array: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "Failed to parse audit array: %m"); if (r == 0) { /* Couldn't process as generic field, let's just skip over it */ @@ -547,10 +543,8 @@ int server_open_audit(Server *s) { } r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, process_datagram, s); - if (r < 0) { - log_error_errno(r, "Failed to add audit fd to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add audit fd to event loop: %m"); /* We are listening now, try to enable audit */ r = enable_audit(s->audit_fd, true); diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 3b3908fb3e..6b2edc191d 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -462,10 +462,8 @@ int server_open_native_socket(Server*s) { } r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s); - if (r < 0) { - log_error_errno(r, "Failed to add native server fd to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add native server fd to event loop: %m"); return 0; } diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 4f5d002d21..3d1947f25f 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -927,10 +927,8 @@ static int system_journal_open(Server *s, bool flush_requested) { char ids[33]; r = sd_id128_get_machine(&machine); - if (r < 0) { - log_error_errno(r, "Failed to get machine id: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get machine id: %m"); sd_id128_to_string(machine, ids); @@ -999,10 +997,8 @@ static int system_journal_open(Server *s, bool flush_requested) { r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal); free(fn); - if (r < 0) { - log_error_errno(r, "Failed to open runtime journal: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to open runtime journal: %m"); } if (s->runtime_journal) @@ -1045,10 +1041,8 @@ int server_flush_to_var(Server *s) { return r; r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY); - if (r < 0) { - log_error_errno(r, "Failed to read runtime journal: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to read runtime journal: %m"); sd_journal_set_data_threshold(j, 0); @@ -1453,15 +1447,12 @@ static int server_open_hostname(Server *s) { return 0; } - log_error_errno(r, "Failed to register hostname fd in event loop: %m"); - return r; + return log_error_errno(r, "Failed to register hostname fd in event loop: %m"); } r = sd_event_source_set_priority(s->hostname_event_source, SD_EVENT_PRIORITY_IMPORTANT-10); - if (r < 0) { - log_error_errno(r, "Failed to adjust priority of host name event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to adjust priority of host name event source: %m"); return 0; } @@ -1514,18 +1505,14 @@ int server_init(Server *s) { return log_oom(); r = sd_event_default(&s->event); - if (r < 0) { - log_error_errno(r, "Failed to create event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create event loop: %m"); sd_event_set_watchdog(s->event, true); n = sd_listen_fds(true); - if (n < 0) { - log_error_errno(n, "Failed to read listening file descriptors from environment: %m"); - return n; - } + if (n < 0) + return log_error_errno(n, "Failed to read listening file descriptors from environment: %m"); for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd++) { diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 293006dc97..ee309d16b9 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -464,16 +464,12 @@ int server_open_stdout_socket(Server *s) { fd_nonblock(s->stdout_fd, 1); r = sd_event_add_io(s->event, &s->stdout_event_source, s->stdout_fd, EPOLLIN, stdout_stream_new, s); - if (r < 0) { - log_error_errno(r, "Failed to add stdout server fd to event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add stdout server fd to event source: %m"); r = sd_event_source_set_priority(s->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+10); - if (r < 0) { - log_error_errno(r, "Failed to adjust priority of stdout server event source: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to adjust priority of stdout server event source: %m"); return 0; } diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index d7fa245721..45483eff36 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -466,10 +466,8 @@ int server_open_syslog_socket(Server *s) { } r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, process_datagram, s); - if (r < 0) { - log_error_errno(r, "Failed to add syslog server fd to event loop: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add syslog server fd to event loop: %m"); return 0; } diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c index 9e24b6ab71..22a4af6837 100644 --- a/src/libsystemd-network/sd-dhcp-lease.c +++ b/src/libsystemd-network/sd-dhcp-lease.c @@ -725,8 +725,7 @@ int sd_dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) { if (r == -ENOENT) return 0; - log_error_errno(r, "Failed to read %s: %m", lease_file); - return r; + return log_error_errno(r, "Failed to read %s: %m", lease_file); } r = inet_pton(AF_INET, address, &addr); diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c index b0b1a197ed..b77f4b0f51 100644 --- a/src/libsystemd-terminal/evcat.c +++ b/src/libsystemd-terminal/evcat.c @@ -137,16 +137,12 @@ static int evcat_new(Evcat **out) { return log_oom(); r = sd_pid_get_session(getpid(), &e->session); - if (r < 0) { - log_error_errno(r, "Cannot retrieve logind session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot retrieve logind session: %m"); r = sd_session_get_seat(e->session, &e->seat); - if (r < 0) { - log_error_errno(r, "Cannot retrieve seat of logind session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot retrieve seat of logind session: %m"); e->managed = is_managed(e->session); @@ -318,17 +314,13 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e name, evcat_idev_fn, e); - if (r < 0) { - log_error_errno(r, "Cannot create idev session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot create idev session: %m"); if (e->managed) { r = sysview_session_take_control(ev->session_add.session); - if (r < 0) { - log_error_errno(r, "Cannot request session control: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot request session control: %m"); } idev_session_enable(e->idev_session); @@ -345,10 +337,8 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e type = sysview_device_get_type(d); if (type == SYSVIEW_DEVICE_EVDEV) { r = idev_session_add_evdev(e->idev_session, sysview_device_get_ud(d)); - if (r < 0) { - log_error_errno(r, "Cannot add evdev device to idev: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot add evdev device to idev: %m"); } break; @@ -357,19 +347,15 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e type = sysview_device_get_type(d); if (type == SYSVIEW_DEVICE_EVDEV) { r = idev_session_remove_evdev(e->idev_session, sysview_device_get_ud(d)); - if (r < 0) { - log_error_errno(r, "Cannot remove evdev device from idev: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot remove evdev device from idev: %m"); } break; case SYSVIEW_EVENT_SESSION_CONTROL: r = ev->session_control.error; - if (r < 0) { - log_error_errno(r, "Cannot acquire session control: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot acquire session control: %m"); r = ioctl(1, KDSKBMODE, K_UNICODE); if (r < 0) { diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c index bcb2a4b1e2..def8ea5ebe 100644 --- a/src/libsystemd-terminal/idev-keyboard.c +++ b/src/libsystemd-terminal/idev-keyboard.c @@ -445,8 +445,7 @@ static int kbdctx_query_locale(kbdctx *kc) { return 0; error: - log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m"); - return r; + return log_debug_errno(r, "idev-keyboard: cannot send GetAll to locale1: %m"); } static int kbdctx_locale_props_changed_fn(sd_bus *bus, @@ -477,8 +476,7 @@ static int kbdctx_locale_props_changed_fn(sd_bus *bus, return 0; error: - log_debug_errno(r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m"); - return r; + return log_debug_errno(r, "idev-keyboard: cannot handle PropertiesChanged from locale1: %m"); } static int kbdctx_setup_bus(kbdctx *kc) { @@ -493,10 +491,8 @@ static int kbdctx_setup_bus(kbdctx *kc) { "path='/org/freedesktop/locale1'", kbdctx_locale_props_changed_fn, kc); - if (r < 0) { - log_debug_errno(r, "idev-keyboard: cannot setup locale1 link: %m"); - return r; - } + if (r < 0) + return log_debug_errno(r, "idev-keyboard: cannot setup locale1 link: %m"); return kbdctx_query_locale(kc); } @@ -1125,9 +1121,8 @@ static int keyboard_update_kbdmap(idev_keyboard *k) { return 0; error: - log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m", - d->session->name, d->name); - return r; + return log_debug_errno(r, "idev-keyboard: %s/%s: cannot adopt new keymap: %m", + d->session->name, d->name); } static int keyboard_update_kbdtbl(idev_keyboard *k) { diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c index 54faec8fee..0b6499b18f 100644 --- a/src/libsystemd-terminal/modeset.c +++ b/src/libsystemd-terminal/modeset.c @@ -146,16 +146,12 @@ static int modeset_new(Modeset **out) { return log_oom(); r = sd_pid_get_session(getpid(), &m->session); - if (r < 0) { - log_error_errno(r, "Cannot retrieve logind session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot retrieve logind session: %m"); r = sd_session_get_seat(m->session, &m->seat); - if (r < 0) { - log_error_errno(r, "Cannot retrieve seat of logind session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot retrieve seat of logind session: %m"); m->my_tty = is_my_tty(m->session); m->managed = m->my_tty && geteuid() > 0; @@ -309,17 +305,13 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event name, modeset_grdev_fn, m); - if (r < 0) { - log_error_errno(r, "Cannot create grdev session: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot create grdev session: %m"); if (m->managed) { r = sysview_session_take_control(ev->session_add.session); - if (r < 0) { - log_error_errno(r, "Cannot request session control: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot request session control: %m"); } grdev_session_enable(m->grdev_session); @@ -358,10 +350,8 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event break; case SYSVIEW_EVENT_SESSION_CONTROL: r = ev->session_control.error; - if (r < 0) { - log_error_errno(r, "Cannot acquire session control: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Cannot acquire session control: %m"); r = ioctl(1, KDSKBMODE, K_UNICODE); if (r < 0) { diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c index 97a98a9843..920b661af4 100644 --- a/src/libsystemd-terminal/subterm.c +++ b/src/libsystemd-terminal/subterm.c @@ -125,10 +125,8 @@ static int output_flush(Output *o) { return 0; len = loop_write(o->fd, o->obuf, o->n_obuf, false); - if (len < 0) { - log_error_errno(len, "error: cannot write to TTY (%zd): %m", len); - return len; - } + if (len < 0) + return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len); o->n_obuf = 0; @@ -156,10 +154,8 @@ static int output_write(Output *o, const void *buf, size_t size) { return r; len = loop_write(o->fd, buf, size, false); - if (len < 0) { - log_error_errno(len, "error: cannot write to TTY (%zd): %m", len); - return len; - } + if (len < 0) + return log_error_errno(len, "error: cannot write to TTY (%zd): %m", len); return 0; } @@ -656,10 +652,8 @@ static int terminal_write_tmp(Terminal *t) { if (t->pty) { for (i = 0; i < num; ++i) { r = pty_write(t->pty, vec[i].iov_base, vec[i].iov_len); - if (r < 0) { - log_error_errno(r, "error: cannot write to PTY (%d): %m", r); - return r; - } + if (r < 0) + return log_error_errno(r, "error: cannot write to PTY (%d): %m", r); } } @@ -725,10 +719,8 @@ static int terminal_io_fn(sd_event_source *source, int fd, uint32_t revents, voi n_str = term_utf8_decode(&t->utf8, &str, buf[i]); for (j = 0; j < n_str; ++j) { type = term_parser_feed(t->parser, &seq, str[j]); - if (type < 0) { - log_error_errno(type, "error: term_parser_feed() (%d): %m", type); - return type; - } + if (type < 0) + return log_error_errno(type, "error: term_parser_feed() (%d): %m", type); if (!t->is_menu) { r = terminal_push_tmp(t, str[j]); @@ -777,10 +769,8 @@ static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const v break; case PTY_DATA: r = term_screen_feed_text(t->screen, ptr, size); - if (r < 0) { - log_error_errno(r, "error: term_screen_feed_text() (%d): %m", r); - return r; - } + if (r < 0) + return log_error_errno(r, "error: term_screen_feed_text() (%d): %m", r); terminal_dirty(t); break; @@ -951,10 +941,9 @@ static int terminal_run(Terminal *t) { assert_return(t, -EINVAL); pid = pty_fork(&t->pty, t->event, terminal_pty_fn, t, t->output->in_width, t->output->in_height); - if (pid < 0) { - log_error_errno(pid, "error: cannot fork PTY (%d): %m", pid); - return pid; - } else if (pid == 0) { + if (pid < 0) + return log_error_errno(pid, "error: cannot fork PTY (%d): %m", pid); + else if (pid == 0) { /* child */ char **argv = (char*[]){ diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index b57ac41e05..722a65448d 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -125,10 +125,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)); - if (r < 0) { - log_error_errno(r, "Failed to rewind: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to rewind: %m"); if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY)) fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature)); @@ -151,20 +149,16 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } basic; r = sd_bus_message_peek_type(m, &type, &contents); - if (r < 0) { - log_error_errno(r, "Failed to peek type: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to peek type: %m"); if (r == 0) { if (level <= 1) break; r = sd_bus_message_exit_container(m); - if (r < 0) { - log_error_errno(r, "Failed to exit container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to exit container: %m"); level--; @@ -182,10 +176,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { if (bus_type_is_container(type) > 0) { r = sd_bus_message_enter_container(m, type, contents); - if (r < 0) { - log_error_errno(r, "Failed to enter container: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to enter container: %m"); if (type == SD_BUS_TYPE_ARRAY) fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents); @@ -202,10 +194,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { } r = sd_bus_message_read_basic(m, type, &basic); - if (r < 0) { - log_error_errno(r, "Failed to get basic: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get basic: %m"); assert(r > 0); diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 9fcbfccc02..bdaa4494a1 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -1263,13 +1263,11 @@ int bus_property_get_ulong( #endif int bus_log_parse_error(int r) { - log_error_errno(r, "Failed to parse bus message: %m"); - return r; + return log_error_errno(r, "Failed to parse bus message: %m"); } int bus_log_create_error(int r) { - log_error_errno(r, "Failed to create bus message: %m"); - return r; + return log_error_errno(r, "Failed to create bus message: %m"); } int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) { diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index febfc98a59..229a1cf9a2 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -89,10 +89,8 @@ static int list_bus_names(sd_bus *bus, char **argv) { arg_unique = arg_acquired = arg_activatable = true; r = sd_bus_list_names(bus, (arg_acquired || arg_unique) ? &acquired : NULL, arg_activatable ? &activatable : NULL); - if (r < 0) { - log_error_errno(r, "Failed to list names: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to list names: %m"); pager_open_if_enabled(); @@ -104,20 +102,16 @@ static int list_bus_names(sd_bus *bus, char **argv) { max_i = MAX(max_i, strlen(*i)); r = hashmap_put(names, *i, NAME_IS_ACQUIRED); - if (r < 0) { - log_error_errno(r, "Failed to add to hashmap: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to add to hashmap: %m"); } STRV_FOREACH(i, activatable) { max_i = MAX(max_i, strlen(*i)); r = hashmap_put(names, *i, NAME_IS_ACTIVATABLE); - if (r < 0 && r != -EEXIST) { - log_error_errno(r, "Failed to add to hashmap: %m"); - return r; - } + if (r < 0 && r != -EEXIST) + return log_error_errno(r, "Failed to add to hashmap: %m"); } merged = new(char*, hashmap_size(names) + 1); @@ -438,10 +432,8 @@ static int tree(sd_bus *bus, char **argv) { bool not_first = false; r = sd_bus_list_names(bus, &names, NULL); - if (r < 0) { - log_error_errno(r, "Failed to get name list: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get name list: %m"); pager_open_if_enabled(); @@ -1095,40 +1087,32 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL return log_oom(); r = sd_bus_add_match(bus, NULL, m, NULL, NULL); - 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"); added_something = true; } STRV_FOREACH(i, arg_matches) { r = sd_bus_add_match(bus, NULL, *i, NULL, NULL); - 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"); added_something = true; } if (!added_something) { r = sd_bus_add_match(bus, NULL, "", NULL, NULL); - 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"); } for (;;) { _cleanup_bus_message_unref_ sd_bus_message *m = NULL; r = sd_bus_process(bus, &m); - if (r < 0) { - log_error_errno(r, "Failed to process bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to process bus: %m"); if (m) { dump(m, stdout); @@ -1139,10 +1123,8 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL continue; r = sd_bus_wait(bus, (uint64_t) -1); - if (r < 0) { - log_error_errno(r, "Failed to wait for bus: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to wait for bus: %m"); } } @@ -1206,10 +1188,8 @@ static int status(sd_bus *bus, char *argv[]) { &creds); } - if (r < 0) { - log_error_errno(r, "Failed to get credentials: %m"); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to get credentials: %m"); bus_creds_dump(creds, NULL, false); return 0; |