diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/busname.c | 6 | ||||
-rw-r--r-- | src/core/cgroup.c | 24 | ||||
-rw-r--r-- | src/core/dbus.c | 96 | ||||
-rw-r--r-- | src/core/load-dropin.c | 8 | ||||
-rw-r--r-- | src/core/loopback-setup.c | 12 | ||||
-rw-r--r-- | src/core/machine-id-setup.c | 6 | ||||
-rw-r--r-- | src/core/main.c | 24 | ||||
-rw-r--r-- | src/core/manager.c | 24 | ||||
-rw-r--r-- | src/core/scope.c | 6 | ||||
-rw-r--r-- | src/core/timer.c | 6 | ||||
-rw-r--r-- | src/core/transaction.c | 6 |
11 files changed, 72 insertions, 146 deletions
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)); |