summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
commit4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f (patch)
treec7a6228e7151aa74bc8e331694a1e795226550cd
parent56f64d95763a799ba4475daf44d8e9f72a1bd474 (diff)
downloadsystemd-4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f.tar.gz
treewide: another round of simplifications
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
-rw-r--r--src/activate/activate.c18
-rw-r--r--src/core/automount.c6
-rw-r--r--src/core/cgroup.c18
-rw-r--r--src/core/dbus.c18
-rw-r--r--src/core/hostname-setup.c6
-rw-r--r--src/core/machine-id-setup.c6
-rw-r--r--src/core/main.c12
-rw-r--r--src/core/manager.c30
-rw-r--r--src/core/mount-setup.c6
-rw-r--r--src/core/namespace.c6
-rw-r--r--src/core/path.c12
-rw-r--r--src/core/selinux-access.c6
-rw-r--r--src/core/shutdown.c12
-rw-r--r--src/cryptsetup/cryptsetup-generator.c30
-rw-r--r--src/dbus1-generator/dbus1-generator.c42
-rw-r--r--src/delta/delta.c7
-rw-r--r--src/firstboot/firstboot.c12
-rw-r--r--src/fstab-generator/fstab-generator.c36
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c66
-rw-r--r--src/hibernate-resume/hibernate-resume-generator.c6
-rw-r--r--src/journal-remote/journal-remote.c18
-rw-r--r--src/journal-remote/journal-upload.c6
-rw-r--r--src/journal/catalog.c6
-rw-r--r--src/journal/coredump-vacuum.c6
-rw-r--r--src/journal/coredump.c42
-rw-r--r--src/journal/coredumpctl.c12
-rw-r--r--src/journal/journalctl.c30
-rw-r--r--src/journal/journald-audit.c12
-rw-r--r--src/journal/journald-native.c24
-rw-r--r--src/journal/journald-server.c6
-rw-r--r--src/journal/journald-stream.c18
-rw-r--r--src/journal/journald-syslog.c24
-rw-r--r--src/libsystemd-terminal/evcat.c12
-rw-r--r--src/libsystemd-terminal/modeset.c6
-rw-r--r--src/libsystemd-terminal/subterm.c18
-rw-r--r--src/libudev/libudev-device-private.c6
-rw-r--r--src/libudev/libudev-device.c6
-rw-r--r--src/locale/localectl.c6
-rw-r--r--src/login/logind-button.c6
-rw-r--r--src/login/logind-session.c6
-rw-r--r--src/machine/machinectl.c12
-rw-r--r--src/network/networkctl.c12
-rw-r--r--src/nspawn/nspawn.c249
-rw-r--r--src/reply-password/reply-password.c6
-rw-r--r--src/resolve-host/resolve-host.c6
-rw-r--r--src/run/run.c24
-rw-r--r--src/shared/ask-password-api.c6
-rw-r--r--src/shared/base-filesystem.c18
-rw-r--r--src/shared/capability.c36
-rw-r--r--src/shared/generator.c6
-rw-r--r--src/shared/pager.c18
-rw-r--r--src/shared/socket-util.c6
-rw-r--r--src/shared/switch-root.c30
-rw-r--r--src/shared/watchdog.c30
-rw-r--r--src/sleep/sleep.c12
-rw-r--r--src/socket-proxy/socket-proxyd.c24
-rw-r--r--src/system-update-generator/system-update-generator.c6
-rw-r--r--src/systemctl/systemctl.c13
-rw-r--r--src/sysusers/sysusers.c18
-rw-r--r--src/sysv-generator/sysv-generator.c6
-rw-r--r--src/timesync/timesyncd-manager.c12
-rw-r--r--src/tmpfiles/tmpfiles.c78
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c12
-rw-r--r--src/udev/udev-rules.c8
-rw-r--r--src/vconsole/vconsole-setup.c14
65 files changed, 433 insertions, 854 deletions
diff --git a/src/activate/activate.c b/src/activate/activate.c
index 3b4cb1e7f5..2689934c40 100644
--- a/src/activate/activate.c
+++ b/src/activate/activate.c
@@ -51,10 +51,8 @@ static int add_epoll(int epoll_fd, int fd) {
ev.data.fd = fd;
r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fd, &ev);
- if (r < 0) {
- log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to add event on epoll fd:%d for fd:%d: %m", epoll_fd, fd);
return 0;
}
@@ -111,10 +109,8 @@ static int open_sockets(int *epoll_fd, bool accept) {
log_open();
*epoll_fd = epoll_create1(EPOLL_CLOEXEC);
- if (*epoll_fd < 0) {
- log_error_errno(errno, "Failed to create epoll object: %m");
- return -errno;
- }
+ if (*epoll_fd < 0)
+ return log_error_errno(errno, "Failed to create epoll object: %m");
for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + count; fd++) {
_cleanup_free_ char *name = NULL;
@@ -192,10 +188,8 @@ static int launch1(const char* child, char** argv, char **env, int fd) {
parent_pid = getpid();
child_pid = fork();
- if (child_pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- return -errno;
- }
+ if (child_pid < 0)
+ return log_error_errno(errno, "Failed to fork: %m");
/* In the child */
if (child_pid == 0) {
diff --git a/src/core/automount.c b/src/core/automount.c
index 8814d4c4fe..f795487131 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -300,10 +300,8 @@ static int open_dev_autofs(Manager *m) {
label_fix("/dev/autofs", false, false);
m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
- if (m->dev_autofs_fd < 0) {
- log_error_errno(errno, "Failed to open /dev/autofs: %m");
- return -errno;
- }
+ if (m->dev_autofs_fd < 0)
+ return log_error_errno(errno, "Failed to open /dev/autofs: %m");
init_autofs_dev_ioctl(&param);
if (ioctl(m->dev_autofs_fd, AUTOFS_DEV_IOCTL_VERSION, &param) < 0) {
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 382e6a6ccc..70fc925b4d 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -153,10 +153,8 @@ static int lookup_blkio_device(const char *p, dev_t *dev) {
assert(dev);
r = stat(p, &st);
- if (r < 0) {
- log_warning_errno(errno, "Couldn't stat device %s: %m", p);
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Couldn't stat device %s: %m", p);
if (S_ISBLK(st.st_mode))
*dev = st.st_rdev;
@@ -218,10 +216,8 @@ static int whitelist_major(const char *path, const char *name, char type, const
assert(type == 'b' || type == 'c');
f = fopen("/proc/devices", "re");
- if (!f) {
- log_warning_errno(errno, "Cannot open /proc/devices to resolve %s (%c): %m", name, type);
- return -errno;
- }
+ if (!f)
+ return log_warning_errno(errno, "Cannot open /proc/devices to resolve %s (%c): %m", name, type);
FOREACH_LINE(line, f, goto fail) {
char buf[2+DECIMAL_STR_MAX(unsigned)+3+4], *p, *w;
@@ -905,10 +901,8 @@ int manager_setup_cgroup(Manager *m) {
safe_close(m->pin_cgroupfs_fd);
m->pin_cgroupfs_fd = open(path, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY|O_NONBLOCK);
- if (m->pin_cgroupfs_fd < 0) {
- log_error_errno(errno, "Failed to open pin file: %m");
- return -errno;
- }
+ if (m->pin_cgroupfs_fd < 0)
+ return log_error_errno(errno, "Failed to open pin file: %m");
/* 6. Always enable hierarchial support if it exists... */
cg_set_attribute("memory", "/", "memory.use_hierarchy", "1");
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 925fac96b4..79cf414eee 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -958,22 +958,16 @@ static int bus_init_private(Manager *m) {
(void) unlink(sa.un.sun_path);
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (fd < 0) {
- log_error_errno(errno, "Failed to allocate private socket: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to allocate private socket: %m");
r = bind(fd, &sa.sa, salen);
- if (r < 0) {
- log_error_errno(errno, "Failed to bind private socket: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to bind private socket: %m");
r = listen(fd, SOMAXCONN);
- if (r < 0) {
- log_error_errno(errno, "Failed to make private socket listening: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to make private socket listening: %m");
r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m);
if (r < 0)
diff --git a/src/core/hostname-setup.c b/src/core/hostname-setup.c
index 72e4c539ef..6664e8952c 100644
--- a/src/core/hostname-setup.c
+++ b/src/core/hostname-setup.c
@@ -82,10 +82,8 @@ int hostname_setup(void) {
hn = "localhost";
}
- if (sethostname_idempotent(hn) < 0) {
- log_warning_errno(errno, "Failed to set hostname to <%s>: %m", hn);
- return -errno;
- }
+ if (sethostname_idempotent(hn) < 0)
+ return log_warning_errno(errno, "Failed to set hostname to <%s>: %m", hn);
log_info("Set hostname to <%s>.", hn);
return 0;
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
index f31e357f15..671003820b 100644
--- a/src/core/machine-id-setup.c
+++ b/src/core/machine-id-setup.c
@@ -204,10 +204,8 @@ int machine_id_setup(const char *root) {
}
}
- if (fstat(fd, &st) < 0) {
- log_error_errno(errno, "fstat() failed: %m");
- return -errno;
- }
+ if (fstat(fd, &st) < 0)
+ return log_error_errno(errno, "fstat() failed: %m");
if (S_ISREG(st.st_mode))
if (loop_read(fd, id, 33, false) == 33 && id[32] == '\n') {
diff --git a/src/core/main.c b/src/core/main.c
index d8a1ab9d43..c9fd56232c 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -884,10 +884,8 @@ static int parse_argv(int argc, char *argv[]) {
fd_cloexec(fd, true);
f = fdopen(fd, "r");
- if (!f) {
- log_error_errno(errno, "Failed to open serialization fd: %m");
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open serialization fd: %m");
if (arg_serialization)
fclose(arg_serialization);
@@ -1045,10 +1043,8 @@ static int bump_rlimit_nofile(struct rlimit *saved_rlimit) {
/* Save the original RLIMIT_NOFILE so that we can reset it
* later when transitioning from the initrd to the main
* systemd or suchlike. */
- if (getrlimit(RLIMIT_NOFILE, saved_rlimit) < 0) {
- log_error_errno(errno, "Reading RLIMIT_NOFILE failed: %m");
- return -errno;
- }
+ if (getrlimit(RLIMIT_NOFILE, saved_rlimit) < 0)
+ return log_error_errno(errno, "Reading RLIMIT_NOFILE failed: %m");
/* Make sure forked processes get the default kernel setting */
if (!arg_default_rlimit[RLIMIT_NOFILE]) {
diff --git a/src/core/manager.c b/src/core/manager.c
index 3798ab2d57..3e1728f925 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -262,10 +262,8 @@ static int manager_check_ask_password(Manager *m) {
mkdir_p_label("/run/systemd/ask-password", 0755);
m->ask_password_inotify_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
- if (m->ask_password_inotify_fd < 0) {
- log_error_errno(errno, "inotify_init1() failed: %m");
- return -errno;
- }
+ if (m->ask_password_inotify_fd < 0)
+ return log_error_errno(errno, "inotify_init1() failed: %m");
if (inotify_add_watch(m->ask_password_inotify_fd, "/run/systemd/ask-password", IN_CREATE|IN_DELETE|IN_MOVE) < 0) {
log_error_errno(errno, "Failed to add watch on /run/systemd/ask-password: %m");
@@ -334,10 +332,8 @@ static int manager_setup_time_change(Manager *m) {
* CLOCK_REALTIME makes a jump relative to CLOCK_MONOTONIC */
m->time_change_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK|TFD_CLOEXEC);
- if (m->time_change_fd < 0) {
- log_error_errno(errno, "Failed to create timerfd: %m");
- return -errno;
- }
+ if (m->time_change_fd < 0)
+ return log_error_errno(errno, "Failed to create timerfd: %m");
if (timerfd_settime(m->time_change_fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) {
log_debug_errno(errno, "Failed to set up TFD_TIMER_CANCEL_ON_SET, ignoring: %m");
@@ -647,10 +643,8 @@ static int manager_setup_notify(Manager *m) {
m->notify_event_source = sd_event_source_unref(m->notify_event_source);
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (fd < 0) {
- log_error_errno(errno, "Failed to allocate notification socket: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to allocate notification socket: %m");
if (m->running_as == SYSTEMD_SYSTEM)
m->notify_socket = strdup("/run/systemd/notify");
@@ -673,16 +667,12 @@ static int manager_setup_notify(Manager *m) {
strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_PASSCRED failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_PASSCRED failed: %m");
m->notify_fd = fd;
fd = -1;
diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c
index d319a15187..342f5520c9 100644
--- a/src/core/mount-setup.c
+++ b/src/core/mount-setup.c
@@ -340,10 +340,8 @@ int mount_cgroup_controllers(char ***join_controllers) {
return log_oom();
r = symlink(options, t);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "Failed to create symlink %s: %m", t);
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", t);
}
}
}
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 32338cdc60..4c411096a1 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -276,10 +276,8 @@ static int mount_kdbus(BindMount *m) {
u = umask(0000);
- if (!mkdtemp(temporary_mount)) {
- log_error_errno(errno, "Failed create temp dir: %m");
- return -errno;
- }
+ if (!mkdtemp(temporary_mount))
+ return log_error_errno(errno, "Failed create temp dir: %m");
root = strappenda(temporary_mount, "/kdbus");
(void)mkdir(root, 0755);
diff --git a/src/core/path.c b/src/core/path.c
index ed03635a46..3624bfcac7 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -168,10 +168,8 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
return -EINVAL;
}
- if (ioctl(s->inotify_fd, FIONREAD, &l) < 0) {
- log_error_errno(errno, "FIONREAD failed: %m");
- return -errno;
- }
+ if (ioctl(s->inotify_fd, FIONREAD, &l) < 0)
+ return log_error_errno(errno, "FIONREAD failed: %m");
assert(l > 0);
@@ -180,10 +178,8 @@ int path_spec_fd_event(PathSpec *s, uint32_t revents) {
return log_oom();
k = read(s->inotify_fd, buf, l);
- if (k < 0) {
- log_error_errno(errno, "Failed to read inotify event: %m");
- return -errno;
- }
+ if (k < 0)
+ return log_error_errno(errno, "Failed to read inotify event: %m");
e = (struct inotify_event*) buf;
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index 0ec80a1b33..b45a4513e2 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -126,10 +126,8 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
static int access_init(void) {
int r = 0;
- if (avc_open(NULL, 0)) {
- log_error_errno(errno, "avc_open() failed: %m");
- return -errno;
- }
+ if (avc_open(NULL, 0))
+ return log_error_errno(errno, "avc_open() failed: %m");
selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback) audit_callback);
selinux_set_callback(SELINUX_CB_LOG, (union selinux_callback) log_callback);
diff --git a/src/core/shutdown.c b/src/core/shutdown.c
index 10455fa309..2cd0bce2f3 100644
--- a/src/core/shutdown.c
+++ b/src/core/shutdown.c
@@ -138,15 +138,11 @@ static int parse_argv(int argc, char *argv[]) {
}
static int switch_root_initramfs(void) {
- if (mount("/run/initramfs", "/run/initramfs", NULL, MS_BIND, NULL) < 0) {
- log_error_errno(errno, "Failed to mount bind /run/initramfs on /run/initramfs: %m");
- return -errno;
- }
+ if (mount("/run/initramfs", "/run/initramfs", NULL, MS_BIND, NULL) < 0)
+ return log_error_errno(errno, "Failed to mount bind /run/initramfs on /run/initramfs: %m");
- if (mount(NULL, "/run/initramfs", NULL, MS_PRIVATE, NULL) < 0) {
- log_error_errno(errno, "Failed to make /run/initramfs private mount: %m");
- return -errno;
- }
+ if (mount(NULL, "/run/initramfs", NULL, MS_PRIVATE, NULL) < 0)
+ return log_error_errno(errno, "Failed to make /run/initramfs private mount: %m");
/* switch_root with MS_BIND, because there might still be processes lurking around, which have open file desriptors.
* /run/initramfs/shutdown will take care of these.
diff --git a/src/cryptsetup/cryptsetup-generator.c b/src/cryptsetup/cryptsetup-generator.c
index b27223cd6c..45c23bb323 100644
--- a/src/cryptsetup/cryptsetup-generator.c
+++ b/src/cryptsetup/cryptsetup-generator.c
@@ -116,10 +116,8 @@ static int create_disk(
return log_oom();
f = fopen(p, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", p);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", p);
fputs(
"# Automatically generated by systemd-cryptsetup-generator\n\n"
@@ -200,10 +198,8 @@ static int create_disk(
name);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write file %s: %m", p);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write file %s: %m", p);
from = strappenda("../", n);
@@ -214,10 +210,8 @@ static int create_disk(
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
if (!nofail)
@@ -228,10 +222,8 @@ static int create_disk(
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
}
free(to);
@@ -240,10 +232,8 @@ static int create_disk(
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
if (!noauto && !nofail) {
_cleanup_free_ char *dmname;
diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 5a26f38869..10a33efee5 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -58,10 +58,8 @@ static int create_dbus_files(
return log_oom();
f = fopen(a, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create %s: %m", a);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create %s: %m", a);
fprintf(f,
"# Automatically generated by systemd-dbus1-generator\n\n"
@@ -116,10 +114,8 @@ static int create_dbus_files(
return log_oom();
f = fopen(b, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create %s: %m", b);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create %s: %m", b);
fprintf(f,
"# Automatically generated by systemd-dbus1-generator\n\n"
@@ -145,10 +141,8 @@ static int create_dbus_files(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(b, lnk)) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(b, lnk))
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return 0;
}
@@ -259,10 +253,8 @@ static int link_busnames_target(const char *units) {
t = strappenda(arg_dest, "/" SPECIAL_BASIC_TARGET ".wants/" SPECIAL_BUSNAMES_TARGET);
mkdir_parents_label(t, 0755);
- if (symlink(f, t) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", t);
- return -errno;
- }
+ if (symlink(f, t) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", t);
return 0;
}
@@ -273,24 +265,18 @@ static int link_compatibility(const char *units) {
f = strappenda(units, "/systemd-bus-proxyd.socket");
t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
mkdir_parents_label(t, 0755);
- if (symlink(f, t) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", t);
- return -errno;
- }
+ if (symlink(f, t) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", t);
f = strappenda(units, "/systemd-bus-proxyd.socket");
t = strappenda(arg_dest, "/" SPECIAL_SOCKETS_TARGET ".wants/systemd-bus-proxyd.socket");
mkdir_parents_label(t, 0755);
- if (symlink(f, t) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", t);
- return -errno;
- }
+ if (symlink(f, t) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", t);
t = strappenda(arg_dest, "/" SPECIAL_DBUS_SERVICE);
- if (symlink("/dev/null", t) < 0) {
- log_error_errno(errno, "Failed to mask %s: %m", t);
- return -errno;
- }
+ if (symlink("/dev/null", t) < 0)
+ return log_error_errno(errno, "Failed to mask %s: %m", t);
return 0;
}
diff --git a/src/delta/delta.c b/src/delta/delta.c
index 8c4af3665a..438091c727 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -185,10 +185,9 @@ static int found_override(const char *top, const char *bottom) {
fflush(stdout);
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork off diff: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork off diff: %m");
+ else if (pid == 0) {
execlp("diff", "diff", "-us", "--", bottom, top, NULL);
log_error_errno(errno, "Failed to execute diff: %m");
_exit(1);
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index d8fbd5945f..d087ef35e9 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -336,10 +336,8 @@ static int process_timezone(void) {
return log_error_errno(r, "Failed to read host timezone: %m");
mkdir_parents(etc_localtime, 0755);
- if (symlink(p, etc_localtime) < 0) {
- log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
- return -errno;
- }
+ if (symlink(p, etc_localtime) < 0)
+ return log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
log_info("%s copied.", etc_localtime);
return 0;
@@ -356,10 +354,8 @@ static int process_timezone(void) {
e = strappenda("../usr/share/zoneinfo/", arg_timezone);
mkdir_parents(etc_localtime, 0755);
- if (symlink(e, etc_localtime) < 0) {
- log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
- return -errno;
- }
+ if (symlink(e, etc_localtime) < 0)
+ return log_error_errno(errno, "Failed to create %s symlink: %m", etc_localtime);
log_info("%s written", etc_localtime);
return 0;
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
index 1c85a729b8..e8a21f7fff 100644
--- a/src/fstab-generator/fstab-generator.c
+++ b/src/fstab-generator/fstab-generator.c
@@ -148,10 +148,8 @@ static int add_swap(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(unit, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(unit, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
}
return 0;
@@ -268,10 +266,8 @@ static int add_mount(
fprintf(f, "Options=%s\n", filtered);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", unit);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
if (!noauto && post) {
lnk = strjoin(arg_dest, "/", post, nofail || automount ? ".wants/" : ".requires/", name, NULL);
@@ -279,10 +275,8 @@ static int add_mount(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(unit, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(unit, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
}
if (automount) {
@@ -296,10 +290,8 @@ static int add_mount(
fclose(f);
f = fopen(automount_unit, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", automount_unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", automount_unit);
fprintf(f,
"# Automatically generated by systemd-fstab-generator\n\n"
@@ -319,10 +311,8 @@ static int add_mount(
where);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", automount_unit);
free(lnk);
lnk = strjoin(arg_dest, "/", post, nofail ? ".wants/" : ".requires/", automount_name, NULL);
@@ -330,10 +320,8 @@ static int add_mount(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(automount_unit, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(automount_unit, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
}
return 0;
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 5a78087a1f..32e9b78a1d 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -68,10 +68,8 @@ static int add_swap(const char *path) {
return log_oom();
f = fopen(unit, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -83,20 +81,16 @@ static int add_swap(const char *path) {
path);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", unit);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", unit);
lnk = strjoin(arg_dest, "/" SPECIAL_SWAP_TARGET ".wants/", name, NULL);
if (!lnk)
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(unit, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(unit, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return 0;
}
@@ -128,10 +122,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
f = fopen(p, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", p);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", p);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -155,10 +147,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
id);
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write file %s: %m", p);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write file %s: %m", p);
from = strappenda("../", n);
@@ -167,10 +157,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
@@ -178,10 +166,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(to);
to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
@@ -189,10 +175,8 @@ static int add_cryptsetup(const char *id, const char *what, bool rw, char **devi
return log_oom();
mkdir_parents_label(to, 0755);
- if (symlink(from, to) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", to);
- return -errno;
- }
+ if (symlink(from, to) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", to);
free(p);
p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf", NULL);
@@ -254,10 +238,8 @@ static int add_mount(
return log_oom();
f = fopen(p, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
fprintf(f,
"# Automatically generated by systemd-gpt-auto-generator\n\n"
@@ -286,10 +268,8 @@ static int add_mount(
fprintf(f, "Options=%s\n", rw ? "rw" : "ro");
fflush(f);
- if (ferror(f)) {
- log_error_errno(errno, "Failed to write unit file %s: %m", p);
- return -errno;
- }
+ if (ferror(f))
+ return log_error_errno(errno, "Failed to write unit file %s: %m", p);
if (post) {
lnk = strjoin(arg_dest, "/", post, ".requires/", unit, NULL);
@@ -297,10 +277,8 @@ static int add_mount(
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(p, lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(p, lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
}
return 0;
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c
index 25cefc2b24..0207346b28 100644
--- a/src/hibernate-resume/hibernate-resume-generator.c
+++ b/src/hibernate-resume/hibernate-resume-generator.c
@@ -57,10 +57,8 @@ static int process_resume(void) {
return log_oom();
mkdir_parents_label(lnk, 0755);
- if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-hibernate-resume@.service", lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
return 0;
}
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 06a39920e4..a5d40cb718 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -84,10 +84,8 @@ static int spawn_child(const char* child, char** argv) {
pid_t parent_pid, child_pid;
int r;
- if (pipe(fd) < 0) {
- log_error_errno(errno, "Failed to create pager pipe: %m");
- return -errno;
- }
+ if (pipe(fd) < 0)
+ return log_error_errno(errno, "Failed to create pager pipe: %m");
parent_pid = getpid();
@@ -940,10 +938,8 @@ static int remoteserver_init(RemoteServer *s,
log_info("Reading file %s...", *file);
fd = open(*file, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
- if (fd < 0) {
- log_error_errno(errno, "Failed to open %s: %m", *file);
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to open %s: %m", *file);
output_name = *file;
}
@@ -1053,10 +1049,8 @@ static int accept_connection(const char* type, int fd,
log_debug("Accepting new %s connection on fd:%d", type, fd);
fd2 = accept4(fd, &addr->sockaddr.sa, &addr->size, SOCK_NONBLOCK|SOCK_CLOEXEC);
- if (fd2 < 0) {
- log_error_errno(errno, "accept() on fd:%d failed: %m", fd);
- return -errno;
- }
+ if (fd2 < 0)
+ return log_error_errno(errno, "accept() on fd:%d failed: %m", fd);
switch(socket_address_family(addr)) {
case AF_INET:
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 826e41a1c4..8be0f93b7c 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -357,10 +357,8 @@ static int open_file_for_upload(Uploader *u, const char *filename) {
fd = STDIN_FILENO;
else {
fd = open(filename, O_RDONLY|O_CLOEXEC|O_NOCTTY);
- if (fd < 0) {
- log_error_errno(errno, "Failed to open %s: %m", filename);
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to open %s: %m", filename);
}
u->input = fd;
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 41cdb0dade..81a2e946e4 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -209,10 +209,8 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
assert(path);
f = fopen(path, "re");
- if (!f) {
- log_error_errno(errno, "Failed to open file %s: %m", path);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open file %s: %m", path);
r = catalog_file_lang(path, &deflang);
if (r < 0)
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index 5f2ff2a025..9b73795e5b 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -139,10 +139,8 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
return 0;
if (exclude_fd >= 0) {
- if (fstat(exclude_fd, &exclude_st) < 0) {
- log_error_errno(errno, "Failed to fstat(): %m");
- return -errno;
- }
+ if (fstat(exclude_fd, &exclude_st) < 0)
+ return log_error_errno(errno, "Failed to fstat(): %m");
}
/* This algorithm will keep deleting the oldest file of the
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index a871c570ca..26953cc5b0 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -142,10 +142,8 @@ static int fix_acl(int fd, uid_t uid) {
* their own coredumps */
acl = acl_get_fd(fd);
- if (!acl) {
- log_error_errno(errno, "Failed to get ACL: %m");
- return -errno;
- }
+ if (!acl)
+ return log_error_errno(errno, "Failed to get ACL: %m");
if (acl_create_entry(&acl, &entry) < 0 ||
acl_set_tag_type(entry, ACL_USER) < 0 ||
@@ -161,10 +159,8 @@ static int fix_acl(int fd, uid_t uid) {
return -errno;
}
- if (acl_set_fd(fd, acl) < 0) {
- log_error_errno(errno, "Failed to apply ACL: %m");
- return -errno;
- }
+ if (acl_set_fd(fd, acl) < 0)
+ return log_error_errno(errno, "Failed to apply ACL: %m");
#endif
return 0;
@@ -223,15 +219,11 @@ static int fix_permissions(
fix_acl(fd, uid);
fix_xattr(fd, info);
- if (fsync(fd) < 0) {
- log_error_errno(errno, "Failed to sync coredump %s: %m", filename);
- return -errno;
- }
+ if (fsync(fd) < 0)
+ return log_error_errno(errno, "Failed to sync coredump %s: %m", filename);
- if (rename(filename, target) < 0) {
- log_error_errno(errno, "Failed to rename coredump %s -> %s: %m", filename, target);
- return -errno;
- }
+ if (rename(filename, target) < 0)
+ return log_error_errno(errno, "Failed to rename coredump %s -> %s: %m", filename, target);
return 0;
}
@@ -247,10 +239,8 @@ static int maybe_remove_external_coredump(const char *filename, off_t size) {
if (!filename)
return 1;
- if (unlink(filename) < 0 && errno != ENOENT) {
- log_error_errno(errno, "Failed to unlink %s: %m", filename);
- return -errno;
- }
+ if (unlink(filename) < 0 && errno != ENOENT)
+ return log_error_errno(errno, "Failed to unlink %s: %m", filename);
return 1;
}
@@ -322,10 +312,8 @@ static int save_external_coredump(
mkdir_p_label("/var/lib/systemd/coredump", 0755);
fd = open(tmp, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0640);
- if (fd < 0) {
- log_error_errno(errno, "Failed to create coredump file %s: %m", tmp);
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to create coredump file %s: %m", tmp);
r = copy_bytes(STDIN_FILENO, fd, arg_process_size_max);
if (r == -EFBIG) {
@@ -429,10 +417,8 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
assert(ret);
assert(ret_size);
- if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
- log_warning_errno(errno, "Failed to seek: %m");
- return -errno;
- }
+ if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
+ return log_warning_errno(errno, "Failed to seek: %m");
field = malloc(9 + size);
if (!field) {
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 2163ef9989..a6551ac44b 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -190,10 +190,8 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
}
output = fopen(optarg, "we");
- if (!output) {
- log_error_errno(errno, "writing to '%s': %m", optarg);
- return -errno;
- }
+ if (!output)
+ return log_error_errno(errno, "writing to '%s': %m", optarg);
break;
@@ -609,10 +607,8 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
return log_oom();
fdt = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
- if (fdt < 0) {
- log_error_errno(errno, "Failed to create temporary file: %m");
- return -errno;
- }
+ if (fdt < 0)
+ return log_error_errno(errno, "Failed to create temporary file: %m");
log_debug("Created temporary file %s", temp);
fd = fdt;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 317b662ca6..5c2a56d575 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -794,10 +794,8 @@ static int add_matches(sd_journal *j, char **args) {
p = canonicalize_file_name(*i);
path = p ? p : *i;
- if (stat(path, &st) < 0) {
- log_error_errno(errno, "Couldn't stat file: %m");
- return -errno;
- }
+ if (stat(path, &st) < 0)
+ return log_error_errno(errno, "Couldn't stat file: %m");
if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
if (executable_is_script(path, &interpreter) > 0) {
@@ -1303,10 +1301,8 @@ static int setup_keys(void) {
struct stat st;
r = stat("/var/log/journal", &st);
- if (r < 0 && errno != ENOENT && errno != ENOTDIR) {
- log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
- return -errno;
- }
+ if (r < 0 && errno != ENOENT && errno != ENOTDIR)
+ return log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
if (r < 0 || !S_ISDIR(st.st_mode)) {
log_error("%s is not a directory, must be using persistent logging for FSS.",
@@ -1685,25 +1681,19 @@ static int flush_to_var(void) {
mkdir_p("/run/systemd/journal", 0755);
watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
- if (watch_fd < 0) {
- log_error_errno(errno, "Failed to create inotify watch: %m");
- return -errno;
- }
+ if (watch_fd < 0)
+ return log_error_errno(errno, "Failed to create inotify watch: %m");
r = inotify_add_watch(watch_fd, "/run/systemd/journal", IN_CREATE|IN_DONT_FOLLOW|IN_ONLYDIR);
- if (r < 0) {
- log_error_errno(errno, "Failed to watch journal directory: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to watch journal directory: %m");
for (;;) {
if (access("/run/systemd/journal/flushed", F_OK) >= 0)
break;
- if (errno != ENOENT) {
- log_error_errno(errno, "Failed to check for existance of /run/systemd/journal/flushed: %m");
- return -errno;
- }
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Failed to check for existance of /run/systemd/journal/flushed: %m");
r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
if (r < 0)
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index ef4ad28833..69742fa59c 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -529,18 +529,14 @@ int server_open_audit(Server *s) {
}
r = bind(s->audit_fd, &sa.sa, sizeof(sa.nl));
- if (r < 0) {
- log_error_errno(errno, "Failed to join audit multicast group: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to join audit multicast group: %m");
} else
fd_nonblock(s->audit_fd, 1);
r = setsockopt(s->audit_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, process_datagram, s);
if (r < 0)
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index a19f85d182..f982696255 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -424,28 +424,22 @@ int server_open_native_socket(Server*s) {
};
s->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->native_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->native_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->native_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
} else
fd_nonblock(s->native_fd, 1);
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_PASSCRED failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_PASSCRED failed: %m");
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
@@ -456,10 +450,8 @@ int server_open_native_socket(Server*s) {
#endif
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_TIMESTAMP failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s);
if (r < 0)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 081ae7c08d..9ec425d2d4 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1431,10 +1431,8 @@ static int server_open_hostname(Server *s) {
assert(s);
s->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
- if (s->hostname_fd < 0) {
- log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
- return -errno;
- }
+ if (s->hostname_fd < 0)
+ return log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s);
if (r < 0) {
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 751b2f49b5..be498d4919 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -441,25 +441,19 @@ int server_open_stdout_socket(Server *s) {
};
s->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->stdout_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->stdout_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->stdout_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
- if (listen(s->stdout_fd, SOMAXCONN) < 0) {
- log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (listen(s->stdout_fd, SOMAXCONN) < 0)
+ return log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
} else
fd_nonblock(s->stdout_fd, 1);
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 51ebd8192d..cc44d45949 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -428,28 +428,22 @@ int server_open_syslog_socket(Server *s) {
};
s->syslog_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->syslog_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->syslog_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->syslog_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
} else
fd_nonblock(s->syslog_fd, 1);
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_PASSCRED failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_PASSCRED failed: %m");
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
@@ -460,10 +454,8 @@ int server_open_syslog_socket(Server *s) {
#endif
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_TIMESTAMP failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, process_datagram, s);
if (r < 0)
diff --git a/src/libsystemd-terminal/evcat.c b/src/libsystemd-terminal/evcat.c
index afb61c71a4..f4c25b5556 100644
--- a/src/libsystemd-terminal/evcat.c
+++ b/src/libsystemd-terminal/evcat.c
@@ -358,16 +358,12 @@ static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *e
return log_error_errno(r, "Cannot acquire session control: %m");
r = ioctl(1, KDSKBMODE, K_UNICODE);
- if (r < 0) {
- log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
r = ioctl(1, KDSETMODE, KD_TEXT);
- if (r < 0) {
- log_error_errno(errno, "Cannot set KD_TEXT on stdout: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Cannot set KD_TEXT on stdout: %m");
printf("\n");
diff --git a/src/libsystemd-terminal/modeset.c b/src/libsystemd-terminal/modeset.c
index f7bcbb2914..6e13432d68 100644
--- a/src/libsystemd-terminal/modeset.c
+++ b/src/libsystemd-terminal/modeset.c
@@ -354,10 +354,8 @@ static int modeset_sysview_fn(sysview_context *c, void *userdata, sysview_event
return log_error_errno(r, "Cannot acquire session control: %m");
r = ioctl(1, KDSKBMODE, K_UNICODE);
- if (r < 0) {
- log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
break;
}
diff --git a/src/libsystemd-terminal/subterm.c b/src/libsystemd-terminal/subterm.c
index f2651b24ac..75a25e5590 100644
--- a/src/libsystemd-terminal/subterm.c
+++ b/src/libsystemd-terminal/subterm.c
@@ -102,10 +102,8 @@ static int output_winch(Output *o) {
assert_return(o, -EINVAL);
r = ioctl(o->fd, TIOCGWINSZ, &wsz);
- if (r < 0) {
- log_error_errno(errno, "error: cannot read window-size: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "error: cannot read window-size: %m");
if (wsz.ws_col != o->width || wsz.ws_row != o->height) {
o->width = wsz.ws_col;
@@ -822,16 +820,12 @@ static int terminal_new(Terminal **out, int in_fd, int out_fd) {
assert_return(out, -EINVAL);
r = tcgetattr(in_fd, &in_attr);
- if (r < 0) {
- log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
r = tcgetattr(out_fd, &out_attr);
- if (r < 0) {
- log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "error: tcgetattr() (%d): %m", -errno);
t = new0(Terminal, 1);
if (!t)
diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c
index be3f17fd47..fb4c6e2940 100644
--- a/src/libudev/libudev-device-private.c
+++ b/src/libudev/libudev-device-private.c
@@ -128,10 +128,8 @@ int udev_device_update_db(struct udev_device *udev_device)
strscpyl(filename_tmp, sizeof(filename_tmp), filename, ".tmp", NULL);
mkdir_parents(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
- if (f == NULL) {
- log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
- return -errno;
- }
+ if (f == NULL)
+ return log_debug_errno(errno, "unable to create temporary db file '%s': %m", filename_tmp);
/*
* set 'sticky' bit to indicate that we should not clean the
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index 400fb74d83..5f196bd9b8 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -534,10 +534,8 @@ int udev_device_read_db(struct udev_device *udev_device, const char *dbfile)
}
f = fopen(dbfile, "re");
- if (f == NULL) {
- log_debug_errno(errno, "no db file to read %s: %m", dbfile);
- return -errno;
- }
+ if (f == NULL)
+ return log_debug_errno(errno, "no db file to read %s: %m", dbfile);
/* devices with a database entry are initialized */
udev_device->is_initialized = true;
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index a0df78ed6b..58b8984bc8 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -401,10 +401,8 @@ static int list_x11_keymaps(sd_bus *bus, char **args, unsigned n) {
}
f = fopen("/usr/share/X11/xkb/rules/base.lst", "re");
- if (!f) {
- log_error_errno(errno, "Failed to open keyboard mapping list. %m");
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open keyboard mapping list. %m");
if (streq(args[0], "list-x11-keymap-models"))
look_for = MODELS;
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 1afb01fc68..e22b106b3c 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -250,10 +250,8 @@ int button_open(Button *b) {
p = strappenda("/dev/input/", b->name);
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
- if (b->fd < 0) {
- log_warning_errno(errno, "Failed to open %s: %m", b->name);
- return -errno;
- }
+ if (b->fd < 0)
+ return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
log_error_errno(errno, "Failed to get input name: %m");
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index c1800e0854..ea1831dac6 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -967,10 +967,8 @@ static int session_open_vt(Session *s) {
sprintf(path, "/dev/tty%u", s->vtnr);
s->vtfd = open(path, O_RDWR | O_CLOEXEC | O_NONBLOCK | O_NOCTTY);
- if (s->vtfd < 0) {
- log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id);
- return -errno;
- }
+ if (s->vtfd < 0)
+ return log_error_errno(errno, "cannot open VT %s of session %s: %m", path, s->id);
return s->vtfd;
}
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 5ea4f4b0d9..f604263d8f 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -725,10 +725,8 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
return log_error_errno(master, "Failed to acquire pseudo tty: %m");
pty = ptsname(master);
- if (!pty) {
- log_error_errno(errno, "Failed to get pty name: %m");
- return -errno;
- }
+ if (!pty)
+ return log_error_errno(errno, "Failed to get pty name: %m");
p = startswith(pty, "/dev/pts/");
if (!p) {
@@ -744,10 +742,8 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
if (!getty)
return log_oom();
- if (unlockpt(master) < 0) {
- log_error_errno(errno, "Failed to unlock tty: %m");
- return -errno;
- }
+ if (unlockpt(master) < 0)
+ return log_error_errno(errno, "Failed to unlock tty: %m");
r = sd_bus_call_method(container_bus,
"org.freedesktop.systemd1",
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index c0cbbe0647..53516638dc 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -194,10 +194,8 @@ static int list_links(char **args, unsigned n) {
return log_error_errno(r, "Failed to connect to netlink: %m");
udev = udev_new();
- if (!udev) {
- log_error_errno(errno, "Failed to connect to udev: %m");
- return -errno;
- }
+ if (!udev)
+ return log_error_errno(errno, "Failed to connect to udev: %m");
r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, 0);
if (r < 0)
@@ -445,10 +443,8 @@ static int link_status(char **args, unsigned n) {
return log_error_errno(r, "Failed to connect to netlink: %m");
udev = udev_new();
- if (!udev) {
- log_error_errno(errno, "Failed to connect to udev: %m");
- return -errno;
- }
+ if (!udev)
+ return log_error_errno(errno, "Failed to connect to udev: %m");
if (n <= 1 && !arg_all) {
_cleanup_free_ char *operational_state = NULL;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index e3e3dfe20e..25f835c230 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -738,10 +738,8 @@ static int mount_binds(const char *dest, char **l, bool ro) {
struct stat source_st, dest_st;
int r;
- if (stat(*x, &source_st) < 0) {
- log_error_errno(errno, "Failed to stat %s: %m", *x);
- return -errno;
- }
+ if (stat(*x, &source_st) < 0)
+ return log_error_errno(errno, "Failed to stat %s: %m", *x);
where = strappend(dest, *y);
if (!where)
@@ -770,18 +768,12 @@ static int mount_binds(const char *dest, char **l, bool ro) {
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) {
- log_error_errno(errno, "Failed to create mount point %s: %m", where);
-
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create mount point %s: %m", where);
} else if (S_ISSOCK(source_st.st_mode)) {
r = mknod(where, 0644 | S_IFSOCK, 0);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "Failed to create mount point %s: %m", where);
-
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create mount point %s: %m", where);
} else if (S_ISREG(source_st.st_mode)) {
r = touch(where);
if (r < 0)
@@ -791,10 +783,8 @@ static int mount_binds(const char *dest, char **l, bool ro) {
return -ENOTSUP;
}
- if (mount(*x, where, "bind", MS_BIND, NULL) < 0) {
- log_error_errno(errno, "mount(%s) failed: %m", where);
- return -errno;
- }
+ if (mount(*x, where, "bind", MS_BIND, NULL) < 0)
+ return log_error_errno(errno, "mount(%s) failed: %m", where);
if (ro) {
r = bind_remount_recursive(where, true);
@@ -821,10 +811,8 @@ static int mount_tmpfs(const char *dest) {
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_errno(errno, "tmpfs mount to %s failed: %m", where);
- return -errno;
- }
+ if (mount("tmpfs", where, "tmpfs", MS_NODEV|MS_STRICTATIME, *o) < 0)
+ return log_error_errno(errno, "tmpfs mount to %s failed: %m", where);
}
return 0;
@@ -953,15 +941,11 @@ static int setup_volatile_state(const char *directory) {
p = strappenda(directory, "/var");
r = mkdir(p, 0755);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "Failed to create %s: %m", directory);
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create %s: %m", directory);
- if (mount("tmpfs", p, "tmpfs", MS_STRICTATIME, "mode=755") < 0) {
- log_error_errno(errno, "Failed to mount tmpfs to /var: %m");
- return -errno;
- }
+ if (mount("tmpfs", p, "tmpfs", MS_STRICTATIME, "mode=755") < 0)
+ return log_error_errno(errno, "Failed to mount tmpfs to /var: %m");
return 0;
}
@@ -980,10 +964,8 @@ static int setup_volatile(const char *directory) {
/* --volatile=yes means we mount a tmpfs to the root dir, and
the original /usr to use inside it, and that read-only. */
- if (!mkdtemp(template)) {
- log_error_errno(errno, "Failed to create temporary directory: %m");
- return -errno;
- }
+ if (!mkdtemp(template))
+ return log_error_errno(errno, "Failed to create temporary directory: %m");
if (mount("tmpfs", template, "tmpfs", MS_STRICTATIME, "mode=755") < 0) {
log_error_errno(errno, "Failed to mount tmpfs for root directory: %m");
@@ -1114,10 +1096,8 @@ static int copy_devnodes(const char *dest) {
if (stat(from, &st) < 0) {
- if (errno != ENOENT) {
- log_error_errno(errno, "Failed to stat %s: %m", from);
- return -errno;
- }
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Failed to stat %s: %m", from);
} else if (!S_ISCHR(st.st_mode) && !S_ISBLK(st.st_mode)) {
@@ -1131,10 +1111,8 @@ static int copy_devnodes(const char *dest) {
return -r;
}
- if (mknod(to, st.st_mode, st.st_rdev) < 0) {
- log_error_errno(errno, "mknod(%s) failed: %m", dest);
- return -errno;
- }
+ if (mknod(to, st.st_mode, st.st_rdev) < 0)
+ return log_error_errno(errno, "mknod(%s) failed: %m", dest);
}
}
@@ -1148,10 +1126,8 @@ static int setup_ptmx(const char *dest) {
if (!p)
return log_oom();
- if (symlink("pts/ptmx", p) < 0) {
- log_error_errno(errno, "Failed to create /dev/ptmx symlink: %m");
- return -errno;
- }
+ if (symlink("pts/ptmx", p) < 0)
+ return log_error_errno(errno, "Failed to create /dev/ptmx symlink: %m");
return 0;
}
@@ -1167,10 +1143,8 @@ static int setup_dev_console(const char *dest, const char *console) {
u = umask(0000);
- if (stat("/dev/null", &st) < 0) {
- log_error_errno(errno, "Failed to stat /dev/null: %m");
- return -errno;
- }
+ if (stat("/dev/null", &st) < 0)
+ return log_error_errno(errno, "Failed to stat /dev/null: %m");
r = chmod_and_chown(console, 0600, 0, 0);
if (r < 0)
@@ -1185,15 +1159,11 @@ static int setup_dev_console(const char *dest, const char *console) {
* matter here, since we mount it over anyway). */
to = strappenda(dest, "/dev/console");
- if (mknod(to, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0) {
- log_error_errno(errno, "mknod() for /dev/console failed: %m");
- return -errno;
- }
+ if (mknod(to, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0)
+ return log_error_errno(errno, "mknod() for /dev/console failed: %m");
- if (mount(console, to, "bind", MS_BIND, NULL) < 0) {
- log_error_errno(errno, "Bind mount for /dev/console failed: %m");
- return -errno;
- }
+ if (mount(console, to, "bind", MS_BIND, NULL) < 0)
+ return log_error_errno(errno, "Bind mount for /dev/console failed: %m");
return 0;
}
@@ -1228,25 +1198,19 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
asprintf(&to, "%s/proc/kmsg", dest) < 0)
return log_oom();
- if (mkfifo(from, 0600) < 0) {
- log_error_errno(errno, "mkfifo() for /dev/kmsg failed: %m");
- return -errno;
- }
+ if (mkfifo(from, 0600) < 0)
+ return log_error_errno(errno, "mkfifo() for /dev/kmsg failed: %m");
r = chmod_and_chown(from, 0600, 0, 0);
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_errno(errno, "Bind mount for /proc/kmsg failed: %m");
- return -errno;
- }
+ if (mount(from, to, "bind", MS_BIND, NULL) < 0)
+ return log_error_errno(errno, "Bind mount for /proc/kmsg failed: %m");
fd = open(from, O_RDWR|O_NDELAY|O_CLOEXEC);
- if (fd < 0) {
- log_error_errno(errno, "Failed to open fifo: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to open fifo: %m");
cmsg = CMSG_FIRSTHDR(&mh);
cmsg->cmsg_level = SOL_SOCKET;
@@ -1261,10 +1225,8 @@ static int setup_kmsg(const char *dest, int kmsg_socket) {
k = sendmsg(kmsg_socket, &mh, MSG_DONTWAIT|MSG_NOSIGNAL);
safe_close(fd);
- if (k < 0) {
- log_error_errno(errno, "Failed to send FIFO fd: %m");
- return -errno;
- }
+ if (k < 0)
+ return log_error_errno(errno, "Failed to send FIFO fd: %m");
/* And now make the FIFO unavailable as /dev/kmsg... */
unlink(from);
@@ -1359,10 +1321,8 @@ static int setup_journal(const char *directory) {
return 0;
}
- if (unlink(p) < 0) {
- log_error_errno(errno, "Failed to remove symlink %s: %m", p);
- return -errno;
- }
+ if (unlink(p) < 0)
+ return log_error_errno(errno, "Failed to remove symlink %s: %m", p);
} else if (r == -EINVAL) {
if (arg_link_journal == LINK_GUEST &&
@@ -1425,10 +1385,8 @@ static int setup_journal(const char *directory) {
return r;
}
- if (mount(p, q, "bind", MS_BIND, NULL) < 0) {
- log_error_errno(errno, "Failed to bind mount journal from host into guest: %m");
- return -errno;
- }
+ if (mount(p, q, "bind", MS_BIND, NULL) < 0)
+ return log_error_errno(errno, "Failed to bind mount journal from host into guest: %m");
return 0;
}
@@ -1752,10 +1710,8 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ], int *ifi) {
return log_error_errno(r, "Failed to add new veth interfaces: %m");
i = (int) if_nametoindex(iface_name);
- if (i <= 0) {
- log_error_errno(errno, "Failed to resolve interface %s: %m", iface_name);
- return -errno;
- }
+ if (i <= 0)
+ return log_error_errno(errno, "Failed to resolve interface %s: %m", iface_name);
*ifi = i;
@@ -1777,10 +1733,8 @@ static int setup_bridge(const char veth_name[], int *ifi) {
return 0;
bridge = (int) if_nametoindex(arg_network_bridge);
- if (bridge <= 0) {
- log_error_errno(errno, "Failed to resolve interface %s: %m", arg_network_bridge);
- return -errno;
- }
+ if (bridge <= 0)
+ return log_error_errno(errno, "Failed to resolve interface %s: %m", arg_network_bridge);
*ifi = bridge;
@@ -1817,17 +1771,13 @@ static int parse_interface(struct udev *udev, const char *name) {
int ifi;
ifi = (int) if_nametoindex(name);
- if (ifi <= 0) {
- log_error_errno(errno, "Failed to resolve interface %s: %m", name);
- return -errno;
- }
+ if (ifi <= 0)
+ return log_error_errno(errno, "Failed to resolve interface %s: %m", name);
sprintf(ifi_str, "n%i", ifi);
d = udev_device_new_from_device_id(udev, ifi_str);
- if (!d) {
- log_error_errno(errno, "Failed to get udev device for interface %s: %m", name);
- return -errno;
- }
+ if (!d)
+ return log_error_errno(errno, "Failed to get udev device for interface %s: %m", name);
if (udev_device_get_is_initialized(d) <= 0) {
log_error("Network interface %s is not initialized yet.", name);
@@ -2057,15 +2007,11 @@ static int setup_image(char **device_path, int *loop_nr) {
assert(loop_nr);
fd = open(arg_image, O_CLOEXEC|(arg_read_only ? O_RDONLY : O_RDWR)|O_NONBLOCK|O_NOCTTY);
- if (fd < 0) {
- log_error_errno(errno, "Failed to open %s: %m", arg_image);
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to open %s: %m", arg_image);
- if (fstat(fd, &st) < 0) {
- log_error_errno(errno, "Failed to stat %s: %m", arg_image);
- return -errno;
- }
+ if (fstat(fd, &st) < 0)
+ return log_error_errno(errno, "Failed to stat %s: %m", arg_image);
if (S_ISBLK(st.st_mode)) {
char *p;
@@ -2090,38 +2036,28 @@ static int setup_image(char **device_path, int *loop_nr) {
}
control = open("/dev/loop-control", O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
- if (control < 0) {
- log_error_errno(errno, "Failed to open /dev/loop-control: %m");
- return -errno;
- }
+ if (control < 0)
+ return log_error_errno(errno, "Failed to open /dev/loop-control: %m");
nr = ioctl(control, LOOP_CTL_GET_FREE);
- if (nr < 0) {
- log_error_errno(errno, "Failed to allocate loop device: %m");
- return -errno;
- }
+ if (nr < 0)
+ return log_error_errno(errno, "Failed to allocate loop device: %m");
if (asprintf(&loopdev, "/dev/loop%i", nr) < 0)
return log_oom();
loop = open(loopdev, O_CLOEXEC|(arg_read_only ? O_RDONLY : O_RDWR)|O_NONBLOCK|O_NOCTTY);
- if (loop < 0) {
- log_error_errno(errno, "Failed to open loop device %s: %m", loopdev);
- return -errno;
- }
+ if (loop < 0)
+ return log_error_errno(errno, "Failed to open loop device %s: %m", loopdev);
- if (ioctl(loop, LOOP_SET_FD, fd) < 0) {
- log_error_errno(errno, "Failed to set loopback file descriptor on %s: %m", loopdev);
- return -errno;
- }
+ if (ioctl(loop, LOOP_SET_FD, fd) < 0)
+ return log_error_errno(errno, "Failed to set loopback file descriptor on %s: %m", loopdev);
if (arg_read_only)
info.lo_flags |= LO_FLAGS_READ_ONLY;
- if (ioctl(loop, LOOP_SET_STATUS64, &info) < 0) {
- log_error_errno(errno, "Failed to set loopback settings on %s: %m", loopdev);
- return -errno;
- }
+ if (ioctl(loop, LOOP_SET_STATUS64, &info) < 0)
+ return log_error_errno(errno, "Failed to set loopback settings on %s: %m", loopdev);
*device_path = loopdev;
loopdev = NULL;
@@ -2212,10 +2148,8 @@ static int dissect_image(
if (!udev)
return log_oom();
- if (fstat(fd, &st) < 0) {
- log_error_errno(errno, "Failed to stat block device: %m");
- return -errno;
- }
+ if (fstat(fd, &st) < 0)
+ return log_error_errno(errno, "Failed to stat block device: %m");
d = udev_device_new_from_devnum(udev, 'b', st.st_rdev);
if (!d)
@@ -2436,10 +2370,8 @@ static int mount_device(const char *what, const char *where, const char *directo
return -ENOTSUP;
}
- if (mount(what, p, fstype, MS_NODEV|(rw ? 0 : MS_RDONLY), NULL) < 0) {
- log_error_errno(errno, "Failed to mount %s: %m", what);
- return -errno;
- }
+ if (mount(what, p, fstype, MS_NODEV|(rw ? 0 : MS_RDONLY), NULL) < 0)
+ return log_error_errno(errno, "Failed to mount %s: %m", what);
return 0;
#else
@@ -2511,16 +2443,13 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
assert(key);
assert(rpid);
- if (pipe2(pipe_fds, O_CLOEXEC) < 0) {
- log_error_errno(errno, "Failed to allocate pipe: %m");
- return -errno;
- }
+ if (pipe2(pipe_fds, O_CLOEXEC) < 0)
+ return log_error_errno(errno, "Failed to allocate pipe: %m");
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork getent child: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork getent child: %m");
+ else if (pid == 0) {
int nullfd;
char *empty_env = NULL;
@@ -2579,20 +2508,14 @@ static int change_uid_gid(char **_home) {
if (!arg_user || streq(arg_user, "root") || streq(arg_user, "0")) {
/* Reset everything fully to 0, just in case */
- if (setgroups(0, NULL) < 0) {
- log_error_errno(errno, "setgroups() failed: %m");
- return -errno;
- }
+ if (setgroups(0, NULL) < 0)
+ return log_error_errno(errno, "setgroups() failed: %m");
- if (setresgid(0, 0, 0) < 0) {
- log_error_errno(errno, "setregid() failed: %m");
- return -errno;
- }
+ if (setresgid(0, 0, 0) < 0)
+ return log_error_errno(errno, "setregid() failed: %m");
- if (setresuid(0, 0, 0) < 0) {
- log_error_errno(errno, "setreuid() failed: %m");
- return -errno;
- }
+ if (setresuid(0, 0, 0) < 0)
+ return log_error_errno(errno, "setreuid() failed: %m");
*_home = NULL;
return 0;
@@ -2740,20 +2663,14 @@ static int change_uid_gid(char **_home) {
fchown(STDOUT_FILENO, uid, gid);
fchown(STDERR_FILENO, uid, gid);
- if (setgroups(n_uids, uids) < 0) {
- log_error_errno(errno, "Failed to set auxiliary groups: %m");
- return -errno;
- }
+ if (setgroups(n_uids, uids) < 0)
+ return log_error_errno(errno, "Failed to set auxiliary groups: %m");
- if (setresgid(gid, gid, gid) < 0) {
- log_error_errno(errno, "setregid() failed: %m");
- return -errno;
- }
+ if (setresgid(gid, gid, gid) < 0)
+ return log_error_errno(errno, "setregid() failed: %m");
- if (setresuid(uid, uid, uid) < 0) {
- log_error_errno(errno, "setreuid() failed: %m");
- return -errno;
- }
+ if (setresuid(uid, uid, uid) < 0)
+ return log_error_errno(errno, "setreuid() failed: %m");
if (_home) {
*_home = home;
diff --git a/src/reply-password/reply-password.c b/src/reply-password/reply-password.c
index 54528d67ab..54683b6f4a 100644
--- a/src/reply-password/reply-password.c
+++ b/src/reply-password/reply-password.c
@@ -51,10 +51,8 @@ static int send_on_socket(int fd, const char *socket_name, const void *packet, s
strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
- if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0) {
- log_error_errno(errno, "Failed to send: %m");
- return -errno;
- }
+ if (sendto(fd, packet, size, MSG_NOSIGNAL, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(socket_name)) < 0)
+ return log_error_errno(errno, "Failed to send: %m");
return 0;
}
diff --git a/src/resolve-host/resolve-host.c b/src/resolve-host/resolve-host.c
index a3c7f96c9e..4950ca1497 100644
--- a/src/resolve-host/resolve-host.c
+++ b/src/resolve-host/resolve-host.c
@@ -513,10 +513,8 @@ static int parse_argv(int argc, char *argv[]) {
case 'i':
arg_ifindex = if_nametoindex(optarg);
- if (arg_ifindex <= 0) {
- log_error_errno(errno, "Unknown interfaces %s: %m", optarg);
- return -errno;
- }
+ if (arg_ifindex <= 0)
+ return log_error_errno(errno, "Unknown interfaces %s: %m", optarg);
break;
case 't':
diff --git a/src/run/run.c b/src/run/run.c
index d61f8db350..85eb052343 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -488,10 +488,8 @@ static int start_transient_scope(
return bus_log_create_error(r);
if (arg_nice_set) {
- if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0) {
- log_error_errno(errno, "Failed to set nice level: %m");
- return -errno;
- }
+ if (setpriority(PRIO_PROCESS, 0, arg_nice) < 0)
+ return log_error_errno(errno, "Failed to set nice level: %m");
}
if (arg_exec_group) {
@@ -501,10 +499,8 @@ static int start_transient_scope(
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_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
- return -errno;
- }
+ if (setresgid(gid, gid, gid) < 0)
+ return log_error_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
}
if (arg_exec_user) {
@@ -533,16 +529,12 @@ static int start_transient_scope(
return log_oom();
if (!arg_exec_group) {
- if (setresgid(gid, gid, gid) < 0) {
- log_error_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
- return -errno;
- }
+ if (setresgid(gid, gid, gid) < 0)
+ return log_error_errno(errno, "Failed to change GID to " GID_FMT ": %m", gid);
}
- if (setresuid(uid, uid, uid) < 0) {
- log_error_errno(errno, "Failed to change UID to " UID_FMT ": %m", uid);
- return -errno;
- }
+ if (setresuid(uid, uid, uid) < 0)
+ return log_error_errno(errno, "Failed to change UID to " UID_FMT ": %m", uid);
}
env = strv_env_merge(3, environ, user_env, arg_environment);
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 41049d79bd..d6589a67f6 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -258,10 +258,8 @@ static int create_socket(char **name) {
assert(name);
fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
snprintf(sa.un.sun_path, sizeof(sa.un.sun_path)-1, "/run/systemd/ask-password/sck.%" PRIx64, random_u64());
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index b1f1f4190e..73907c6354 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -58,10 +58,8 @@ int base_filesystem_create(const char *root) {
int r;
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
- if (fd < 0) {
- log_error_errno(errno, "Failed to open root file system: %m");
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to open root file system: %m");
for (i = 0; i < ELEMENTSOF(table); i ++) {
if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
@@ -95,19 +93,15 @@ int base_filesystem_create(const char *root) {
continue;
r = symlinkat(target, fd, table[i].dir);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "Failed to create symlink at %s/%s: %m", root, table[i].dir);
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create symlink at %s/%s: %m", root, table[i].dir);
continue;
}
RUN_WITH_UMASK(0000)
r = mkdirat(fd, table[i].dir, table[i].mode);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "Failed to create directory at %s/%s: %m", root, table[i].dir);
- return -errno;
- }
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "Failed to create directory at %s/%s: %m", root, table[i].dir);
}
return 0;
diff --git a/src/shared/capability.c b/src/shared/capability.c
index e2e0dd1a33..5d156ab3cd 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -227,31 +227,21 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
* binary has the capability configured in the file system,
* which we want to avoid. */
- if (setresgid(gid, gid, gid) < 0) {
- log_error_errno(errno, "Failed to change group ID: %m");
- return -errno;
- }
+ if (setresgid(gid, gid, gid) < 0)
+ return log_error_errno(errno, "Failed to change group ID: %m");
- if (setgroups(0, NULL) < 0) {
- log_error_errno(errno, "Failed to drop auxiliary groups list: %m");
- return -errno;
- }
+ if (setgroups(0, NULL) < 0)
+ return log_error_errno(errno, "Failed to drop auxiliary groups list: %m");
- if (prctl(PR_SET_KEEPCAPS, 1) < 0) {
- log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
- return -errno;
- }
+ if (prctl(PR_SET_KEEPCAPS, 1) < 0)
+ return log_error_errno(errno, "Failed to enable keep capabilities flag: %m");
r = setresuid(uid, uid, uid);
- if (r < 0) {
- log_error_errno(errno, "Failed to change user ID: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to change user ID: %m");
- if (prctl(PR_SET_KEEPCAPS, 0) < 0) {
- log_error_errno(errno, "Failed to disable keep capabilities flag: %m");
- return -errno;
- }
+ if (prctl(PR_SET_KEEPCAPS, 0) < 0)
+ return log_error_errno(errno, "Failed to disable keep capabilities flag: %m");
r = capability_bounding_set_drop(~keep_capabilities, true);
if (r < 0)
@@ -276,10 +266,8 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
}
}
- if (cap_set_proc(d) < 0) {
- log_error_errno(errno, "Failed to increase capabilities: %m");
- return -errno;
- }
+ if (cap_set_proc(d) < 0)
+ return log_error_errno(errno, "Failed to increase capabilities: %m");
return 0;
}
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 01229d8d71..465e5f6cc8 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -64,10 +64,8 @@ int generator_write_fsck_deps(
lnk = strappenda(dest, "/" SPECIAL_LOCAL_FS_TARGET ".wants/systemd-fsck-root.service");
mkdir_parents(lnk, 0755);
- if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
- return -errno;
- }
+ if (symlink(SYSTEM_DATA_UNIT_PATH "/systemd-fsck-root.service", lnk) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", lnk);
} else {
_cleanup_free_ char *fsck = NULL;
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 2863940725..a9f2b7e4f4 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -67,10 +67,8 @@ int pager_open(bool jump_to_end) {
* pager so that we get the value from the actual tty */
columns();
- if (pipe(fd) < 0) {
- log_error_errno(errno, "Failed to create pager pipe: %m");
- return -errno;
- }
+ if (pipe(fd) < 0)
+ return log_error_errno(errno, "Failed to create pager pipe: %m");
parent_pid = getpid();
@@ -126,10 +124,8 @@ int pager_open(bool jump_to_end) {
}
/* Return in the parent */
- if (dup2(fd[1], STDOUT_FILENO) < 0) {
- log_error_errno(errno, "Failed to duplicate pager pipe: %m");
- return -errno;
- }
+ if (dup2(fd[1], STDOUT_FILENO) < 0)
+ return log_error_errno(errno, "Failed to duplicate pager pipe: %m");
safe_close_pair(fd);
return 1;
@@ -176,10 +172,8 @@ int show_man_page(const char *desc, bool null_stdio) {
args[1] = desc;
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- return -errno;
- }
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork: %m");
if (pid == 0) {
/* Child */
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index b5b001a6f2..c6f64876be 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -657,10 +657,8 @@ int getnameinfo_pretty(int fd, char **ret) {
assert(fd >= 0);
assert(ret);
- if (getsockname(fd, &sa.sa, &salen) < 0) {
- log_error_errno(errno, "getsockname(%d) failed: %m", fd);
- return -errno;
- }
+ if (getsockname(fd, &sa.sa, &salen) < 0)
+ return log_error_errno(errno, "getsockname(%d) failed: %m", fd);
return socknameinfo_pretty(&sa, salen, ret);
}
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index c5b635d17d..ca3875628a 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -56,10 +56,8 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
old_root_remove = in_initrd();
- if (stat(new_root, &new_root_stat) < 0) {
- log_error_errno(errno, "Failed to stat directory %s: %m", new_root);
- return -errno;
- }
+ if (stat(new_root, &new_root_stat) < 0)
+ return log_error_errno(errno, "Failed to stat directory %s: %m", new_root);
/* Work-around for kernel design: the kernel refuses switching
* root if any file systems are mounted MS_SHARED. Hence
@@ -109,10 +107,8 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
* switch_root() nevertheless. */
(void) base_filesystem_create(new_root);
- if (chdir(new_root) < 0) {
- log_error_errno(errno, "Failed to change directory to %s: %m", new_root);
- return -errno;
- }
+ if (chdir(new_root) < 0)
+ return log_error_errno(errno, "Failed to change directory to %s: %m", new_root);
if (old_root_remove) {
old_root_fd = open("/", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY|O_DIRECTORY);
@@ -132,20 +128,14 @@ int switch_root(const char *new_root, const char *oldroot, bool detach_oldroot,
oldroot,
errno == ENOENT ? "ignoring" : "leaving it around");
- } else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0) {
- log_error_errno(errno, "Failed to mount moving %s to /: %m", new_root);
- return -errno;
- }
+ } else if (mount(new_root, "/", NULL, MS_MOVE, NULL) < 0)
+ return log_error_errno(errno, "Failed to mount moving %s to /: %m", new_root);
- if (chroot(".") < 0) {
- log_error_errno(errno, "Failed to change root: %m");
- return -errno;
- }
+ if (chroot(".") < 0)
+ return log_error_errno(errno, "Failed to change root: %m");
- if (chdir("/") < 0) {
- log_error_errno(errno, "Failed to change directory: %m");
- return -errno;
- }
+ if (chdir("/") < 0)
+ return log_error_errno(errno, "Failed to change directory: %m");
if (old_root_fd >= 0) {
struct stat rb;
diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c
index 386751418e..2fe4eb81cf 100644
--- a/src/shared/watchdog.c
+++ b/src/shared/watchdog.c
@@ -44,36 +44,28 @@ static int update_timeout(void) {
flags = WDIOS_DISABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0) {
- log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
} else {
int sec, flags;
char buf[FORMAT_TIMESPAN_MAX];
sec = (int) ((watchdog_timeout + USEC_PER_SEC - 1) / USEC_PER_SEC);
r = ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec);
- if (r < 0) {
- log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
watchdog_timeout = (usec_t) sec * USEC_PER_SEC;
log_info("Set hardware watchdog to %s.", format_timespan(buf, sizeof(buf), watchdog_timeout, 0));
flags = WDIOS_ENABLECARD;
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
- if (r < 0) {
- log_warning_errno(errno, "Failed to enable hardware watchdog: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Failed to enable hardware watchdog: %m");
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
- if (r < 0) {
- log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
}
return 0;
@@ -127,10 +119,8 @@ int watchdog_ping(void) {
}
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
- if (r < 0) {
- log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
return 0;
}
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index a7506ed771..415893ba74 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -77,10 +77,8 @@ static int write_state(FILE **f, char **states) {
fclose(*f);
*f = fopen("/sys/power/state", "we");
- if (!*f) {
- log_error_errno(errno, "Failed to open /sys/power/state: %m");
- return -errno;
- }
+ if (!*f)
+ return log_error_errno(errno, "Failed to open /sys/power/state: %m");
}
return r;
@@ -101,10 +99,8 @@ static int execute(char **modes, char **states) {
/* This file is opened first, so that if we hit an error,
* we can abort before modifying any state. */
f = fopen("/sys/power/state", "we");
- if (!f) {
- log_error_errno(errno, "Failed to open /sys/power/state: %m");
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open /sys/power/state: %m");
/* Configure the hibernation mode */
r = write_mode(modes);
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index a2507ad456..a3c3c87f11 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -120,18 +120,14 @@ static int connection_create_pipes(Connection *c, int buffer[2], size_t *sz) {
return 0;
r = pipe2(buffer, O_CLOEXEC|O_NONBLOCK);
- if (r < 0) {
- log_error_errno(errno, "Failed to allocate pipe buffer: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to allocate pipe buffer: %m");
(void) fcntl(buffer[0], F_SETPIPE_SZ, BUFFER_SIZE);
r = fcntl(buffer[0], F_GETPIPE_SZ);
- if (r < 0) {
- log_error_errno(errno, "Failed to get pipe buffer size: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to get pipe buffer size: %m");
assert(r > 0);
*sz = r;
@@ -171,10 +167,8 @@ static int connection_shovel(
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
*from_source = sd_event_source_unref(*from_source);
*from = safe_close(*from);
- } else if (errno != EAGAIN && errno != EINTR) {
- log_error_errno(errno, "Failed to splice: %m");
- return -errno;
- }
+ } else if (errno != EAGAIN && errno != EINTR)
+ return log_error_errno(errno, "Failed to splice: %m");
}
if (*full > 0 && *to >= 0) {
@@ -185,10 +179,8 @@ static int connection_shovel(
} else if (z == 0 || errno == EPIPE || errno == ECONNRESET) {
*to_source = sd_event_source_unref(*to_source);
*to = safe_close(*to);
- } else if (errno != EAGAIN && errno != EINTR) {
- log_error_errno(errno, "Failed to splice: %m");
- return -errno;
- }
+ } else if (errno != EAGAIN && errno != EINTR)
+ return log_error_errno(errno, "Failed to splice: %m");
}
} while (shoveled);
diff --git a/src/system-update-generator/system-update-generator.c b/src/system-update-generator/system-update-generator.c
index 2e37410bf4..464ee22b20 100644
--- a/src/system-update-generator/system-update-generator.c
+++ b/src/system-update-generator/system-update-generator.c
@@ -46,10 +46,8 @@ static int generate_symlink(void) {
}
p = strappenda(arg_dest, "/default.target");
- if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0) {
- log_error_errno(errno, "Failed to create symlink %s: %m", p);
- return -errno;
- }
+ if (symlink(SYSTEM_DATA_UNIT_PATH "/system-update.target", p) < 0)
+ return log_error_errno(errno, "Failed to create symlink %s: %m", p);
return 0;
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 69f157cebb..ffb97df141 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -5219,10 +5219,9 @@ static int enable_sysv_units(const char *verb, char **args) {
log_info("Executing %s", l);
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork: %m");
+ else if (pid == 0) {
/* Child */
execv(argv[0], (char**) argv);
@@ -6952,10 +6951,8 @@ static int reload_with_fallback(sd_bus *bus) {
/* Nothing else worked, so let's try signals */
assert(arg_action == ACTION_RELOAD || arg_action == ACTION_REEXEC);
- if (kill(1, arg_action == ACTION_RELOAD ? SIGHUP : SIGTERM) < 0) {
- log_error_errno(errno, "kill() failed: %m");
- return -errno;
- }
+ if (kill(1, arg_action == ACTION_RELOAD ? SIGHUP : SIGTERM) < 0)
+ return log_error_errno(errno, "kill() failed: %m");
return 0;
}
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index e69a5f58ad..685bbefd8d 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -898,10 +898,8 @@ static int add_user(Item *i) {
i->description = strdup(p->pw_gecos);
return 0;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error_errno(errno, "Failed to check if user %s already exists: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if user %s already exists: %m", i->name);
/* And shadow too, just to be sure */
errno = 0;
@@ -910,10 +908,8 @@ static int add_user(Item *i) {
log_error("User %s already exists in shadow database, but not in user database.", i->name);
return -EBADMSG;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error_errno(errno, "Failed to check if user %s already exists in shadow database: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if user %s already exists in shadow database: %m", i->name);
}
/* Try to use the suggested numeric uid */
@@ -1056,10 +1052,8 @@ static int add_group(Item *i) {
i->gid_set = true;
return 0;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error_errno(errno, "Failed to check if group %s already exists: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if group %s already exists: %m", i->name);
}
/* Try to use the suggested numeric gid */
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 434947e1ef..e6eef315e9 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -143,10 +143,8 @@ static int generate_unit_file(SysvStub *s) {
return log_oom();
f = fopen(unit, "wxe");
- if (!f) {
- log_error_errno(errno, "Failed to create unit file %s: %m", unit);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to create unit file %s: %m", unit);
fprintf(f,
"# Automatically generated by systemd-sysv-generator\n\n"
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index b16b25a96a..3653854a63 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -311,15 +311,11 @@ static int manager_clock_watch_setup(Manager *m) {
safe_close(m->clock_watch_fd);
m->clock_watch_fd = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK|TFD_CLOEXEC);
- if (m->clock_watch_fd < 0) {
- log_error_errno(errno, "Failed to create timerfd: %m");
- return -errno;
- }
+ if (m->clock_watch_fd < 0)
+ return log_error_errno(errno, "Failed to create timerfd: %m");
- if (timerfd_settime(m->clock_watch_fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0) {
- log_error_errno(errno, "Failed to set up timerfd: %m");
- return -errno;
- }
+ if (timerfd_settime(m->clock_watch_fd, TFD_TIMER_ABSTIME|TFD_TIMER_CANCEL_ON_SET, &its, NULL) < 0)
+ return log_error_errno(errno, "Failed to set up timerfd: %m");
r = sd_event_add_io(m->event, &m->event_clock_watch, m->clock_watch_fd, EPOLLIN, manager_clock_watch, m);
if (r < 0)
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 852bb45315..f19fa970cf 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -469,10 +469,8 @@ static int item_set_perms(Item *i, const char *path) {
}
if (!st_valid || m != (st.st_mode & 07777)) {
- if (chmod(path, m) < 0) {
- log_error_errno(errno, "chmod(%s) failed: %m", path);
- return -errno;
- }
+ if (chmod(path, m) < 0)
+ return log_error_errno(errno, "chmod(%s) failed: %m", path);
}
}
@@ -534,10 +532,8 @@ static int write_one_file(Item *i, const char *path) {
fd = safe_close(fd);
- if (stat(path, &st) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", path);
- return -errno;
- }
+ if (stat(path, &st) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", path);
if (!S_ISREG(st.st_mode)) {
log_error("%s is not a file.", path);
@@ -670,15 +666,11 @@ static int create_item(Item *i) {
if (r != -EEXIST)
return log_error_errno(r, "Failed to copy files to %s: %m", i->path);
- if (stat(i->argument, &a) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->argument);
- return -errno;
- }
+ if (stat(i->argument, &a) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->argument);
- if (stat(i->path, &b) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->path);
- return -errno;
- }
+ if (stat(i->path, &b) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->path);
if ((a.st_mode ^ b.st_mode) & S_IFMT) {
log_debug("Can't copy to %s, file exists already and is of different type", i->path);
@@ -711,10 +703,8 @@ static int create_item(Item *i) {
if (r != -EEXIST)
return log_error_errno(r, "Failed to create directory %s: %m", i->path);
- if (stat(i->path, &st) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->path);
- return -errno;
- }
+ if (stat(i->path, &st) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->path);
if (!S_ISDIR(st.st_mode)) {
log_debug("%s already exists and is not a directory.", i->path);
@@ -737,15 +727,11 @@ static int create_item(Item *i) {
}
if (r < 0) {
- if (errno != EEXIST) {
- log_error_errno(errno, "Failed to create fifo %s: %m", i->path);
- return -errno;
- }
+ if (errno != EEXIST)
+ return log_error_errno(errno, "Failed to create fifo %s: %m", i->path);
- if (stat(i->path, &st) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->path);
- return -errno;
- }
+ if (stat(i->path, &st) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->path);
if (!S_ISFIFO(st.st_mode)) {
@@ -781,10 +767,8 @@ static int create_item(Item *i) {
if (r < 0) {
_cleanup_free_ char *x = NULL;
- if (errno != EEXIST) {
- log_error_errno(errno, "symlink(%s, %s) failed: %m", i->argument, i->path);
- return -errno;
- }
+ if (errno != EEXIST)
+ return log_error_errno(errno, "symlink(%s, %s) failed: %m", i->argument, i->path);
r = readlink_malloc(i->path, &x);
if (r < 0 || !streq(i->argument, x)) {
@@ -834,15 +818,11 @@ static int create_item(Item *i) {
return 0;
}
- if (errno != EEXIST) {
- log_error_errno(errno, "Failed to create device node %s: %m", i->path);
- return -errno;
- }
+ if (errno != EEXIST)
+ return log_error_errno(errno, "Failed to create device node %s: %m", i->path);
- if (stat(i->path, &st) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->path);
- return -errno;
- }
+ if (stat(i->path, &st) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->path);
if ((st.st_mode & S_IFMT) != file_type) {
@@ -916,10 +896,8 @@ static int remove_item_instance(Item *i, const char *instance) {
break;
case REMOVE_PATH:
- if (remove(instance) < 0 && errno != ENOENT) {
- log_error_errno(errno, "remove(%s): %m", instance);
- return -errno;
- }
+ if (remove(instance) < 0 && errno != ENOENT)
+ return log_error_errno(errno, "remove(%s): %m", instance);
break;
@@ -997,20 +975,16 @@ static int clean_item_instance(Item *i, const char* instance) {
return -errno;
}
- if (fstat(dirfd(d), &s) < 0) {
- log_error_errno(errno, "stat(%s) failed: %m", i->path);
- return -errno;
- }
+ if (fstat(dirfd(d), &s) < 0)
+ return log_error_errno(errno, "stat(%s) failed: %m", i->path);
if (!S_ISDIR(s.st_mode)) {
log_error("%s is not a directory.", i->path);
return -ENOTDIR;
}
- if (fstatat(dirfd(d), "..", &ps, AT_SYMLINK_NOFOLLOW) != 0) {
- log_error_errno(errno, "stat(%s/..) failed: %m", i->path);
- return -errno;
- }
+ if (fstatat(dirfd(d), "..", &ps, AT_SYMLINK_NOFOLLOW) != 0)
+ return log_error_errno(errno, "stat(%s/..) failed: %m", i->path);
mountpoint = s.st_dev != ps.st_dev ||
(s.st_dev == ps.st_dev && s.st_ino == ps.st_ino);
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 f8e80a39be..fa8448cfae 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -90,10 +90,8 @@ static int ask_password_plymouth(
return -errno;
r = connect(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(sa.un.sun_path+1));
- if (r < 0) {
- log_error_errno(errno, "Failed to connect to Plymouth: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to connect to Plymouth: %m");
if (accept_cached) {
packet = strdup("c");
@@ -342,10 +340,8 @@ static int parse_password(const char *filename, char **wall) {
return log_error_errno(r, "Failed to query password: %m");
socket_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
- if (socket_fd < 0) {
- log_error_errno(errno, "socket(): %m");
- return -errno;
- }
+ if (socket_fd < 0)
+ return log_error_errno(errno, "socket(): %m");
sa.un.sun_family = AF_UNIX;
strncpy(sa.un.sun_path, socket_name, sizeof(sa.un.sun_path));
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index d72362fcbd..ff2d4ec850 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -2659,10 +2659,10 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
r = symlink(device_node, tag_symlink);
- if (r < 0 && errno != EEXIST) {
- log_error_errno(errno, "failed to create symlink %s -> %s: %m", tag_symlink, device_node);
- return -errno;
- } else
+ if (r < 0 && errno != EEXIST)
+ return log_error_errno(errno, "failed to create symlink %s -> %s: %m",
+ tag_symlink, device_node);
+ else
r = 0;
}
}
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
index e79ad2a5f0..40e4b22b99 100644
--- a/src/vconsole/vconsole-setup.c
+++ b/src/vconsole/vconsole-setup.c
@@ -122,10 +122,9 @@ static int keymap_load(const char *vc, const char *map, const char *map_toggle,
args[i++] = NULL;
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork: %m");
+ else if (pid == 0) {
execv(args[0], (char **) args);
_exit(EXIT_FAILURE);
}
@@ -160,10 +159,9 @@ static int font_load(const char *vc, const char *font, const char *map, const ch
args[i++] = NULL;
pid = fork();
- if (pid < 0) {
- log_error_errno(errno, "Failed to fork: %m");
- return -errno;
- } else if (pid == 0) {
+ if (pid < 0)
+ return log_error_errno(errno, "Failed to fork: %m");
+ else if (pid == 0) {
execv(args[0], (char **) args);
_exit(EXIT_FAILURE);
}