summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coccinelle/errno.cocci42
-rw-r--r--src/core/namespace.c12
-rw-r--r--src/debug-generator/debug-generator.c10
-rw-r--r--src/journal/coredumpctl.c5
-rw-r--r--src/journal/journalctl.c3
-rw-r--r--src/login/logind-session.c20
-rw-r--r--src/shared/clean-ipc.c25
7 files changed, 67 insertions, 50 deletions
diff --git a/coccinelle/errno.cocci b/coccinelle/errno.cocci
index 073d905141..45f2b6e9d5 100644
--- a/coccinelle/errno.cocci
+++ b/coccinelle/errno.cocci
@@ -1,42 +1,48 @@
@@
identifier r;
-expression t, e;
+expression e;
@@
- r = -e;
-- log_error_errno(e, t);
-+ r = log_error_errno(e, t);
+- log_error_errno(e,
++ r = log_error_errno(e,
+ ...);
@@
identifier r;
-expression t, e;
+expression e;
@@
-- log_error_errno(e, t);
+- log_error_errno(e,
++ r = log_error_errno(e,
+ ...);
- r = -e;
-+ r = log_error_errno(e, t);
@@
identifier r;
-expression t, e;
+expression e;
@@
-- r = log_error_errno(e, t);
+- r = log_error_errno(e,
++ return log_error_errno(e,
+ ...);
- return r;
-+ return log_error_errno(e, t);
@@
identifier r;
-expression t, e;
+expression e;
@@
- r = -e;
-- log_warning_errno(e, t);
-+ r = log_warning_errno(e, t);
+- log_warning_errno(e,
++ r = log_warning_errno(e,
+ ...);
@@
identifier r;
-expression t, e;
+expression e;
@@
-- log_warning_errno(e, t);
+- log_warning_errno(e,
++ r = log_warning_errno(e,
+ ...);
- r = -e;
-+ r = log_warning_errno(e, t);
@@
identifier r;
-expression t, e;
+expression e;
@@
-- r = log_warning_errno(e, t);
+- r = log_warning_errno(e,
++ return log_warning_errno(e,
+ ...);
- return r;
-+ return log_warning_errno(e, t);
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 0b85b859fa..5ff35b38fb 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -294,15 +294,15 @@ static int mount_kdbus(BindMount *m) {
busnode = strjoina(root, "/bus");
if (mknod(busnode, (st.st_mode & ~07777) | 0600, st.st_rdev) < 0) {
- log_error_errno(errno, "mknod() for %s failed: %m", busnode);
- r = -errno;
+ r = log_error_errno(errno, "mknod() for %s failed: %m",
+ busnode);
goto fail;
}
r = mount(m->path, busnode, NULL, MS_BIND, NULL);
if (r < 0) {
- log_error_errno(errno, "bind mount of %s failed: %m", m->path);
- r = -errno;
+ r = log_error_errno(errno, "bind mount of %s failed: %m",
+ m->path);
goto fail;
}
@@ -313,8 +313,8 @@ static int mount_kdbus(BindMount *m) {
}
if (mount(root, basepath, NULL, MS_MOVE, NULL) < 0) {
- log_error_errno(errno, "bind mount of %s failed: %m", basepath);
- r = -errno;
+ r = log_error_errno(errno, "bind mount of %s failed: %m",
+ basepath);
goto fail;
}
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 9d0ab06e2f..3ae9634414 100644
--- a/src/debug-generator/debug-generator.c
+++ b/src/debug-generator/debug-generator.c
@@ -96,8 +96,9 @@ static int generate_mask_symlinks(void) {
return log_oom();
if (symlink("/dev/null", p) < 0) {
- log_error_errno(errno, "Failed to create mask symlink %s: %m", p);
- r = -errno;
+ r = log_error_errno(errno,
+ "Failed to create mask symlink %s: %m",
+ p);
}
}
@@ -125,8 +126,9 @@ static int generate_wants_symlinks(void) {
mkdir_parents_label(p, 0755);
if (symlink(f, p) < 0) {
- log_error_errno(errno, "Failed to create wants symlink %s: %m", p);
- r = -errno;
+ r = log_error_errno(errno,
+ "Failed to create wants symlink %s: %m",
+ p);
}
}
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 0fa427003b..0546290318 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -646,8 +646,9 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
fdf = open(filename, O_RDONLY | O_CLOEXEC);
if (fdf < 0) {
- log_error_errno(errno, "Failed to open %s: %m", filename);
- r = -errno;
+ r = log_error_errno(errno,
+ "Failed to open %s: %m",
+ filename);
goto error;
}
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index d31ab1c6d7..576e4e4d03 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -1453,8 +1453,7 @@ static int setup_keys(void) {
safe_close(fd);
fd = mkostemp_safe(k, O_WRONLY|O_CLOEXEC);
if (fd < 0) {
- log_error_errno(errno, "Failed to open %s: %m", k);
- r = -errno;
+ r = log_error_errno(errno, "Failed to open %s: %m", k);
goto finish;
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index d2c5a29801..f5fe030b07 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -1005,22 +1005,25 @@ int session_prepare_vt(Session *s) {
r = fchown(vt, s->user->uid, -1);
if (r < 0) {
- r = -errno;
- log_error_errno(errno, "Cannot change owner of /dev/tty%u: %m", s->vtnr);
+ r = log_error_errno(errno,
+ "Cannot change owner of /dev/tty%u: %m",
+ s->vtnr);
goto error;
}
r = ioctl(vt, KDSKBMODE, K_OFF);
if (r < 0) {
- r = -errno;
- log_error_errno(errno, "Cannot set K_OFF on /dev/tty%u: %m", s->vtnr);
+ r = log_error_errno(errno,
+ "Cannot set K_OFF on /dev/tty%u: %m",
+ s->vtnr);
goto error;
}
r = ioctl(vt, KDSETMODE, KD_GRAPHICS);
if (r < 0) {
- r = -errno;
- log_error_errno(errno, "Cannot set KD_GRAPHICS on /dev/tty%u: %m", s->vtnr);
+ r = log_error_errno(errno,
+ "Cannot set KD_GRAPHICS on /dev/tty%u: %m",
+ s->vtnr);
goto error;
}
@@ -1032,8 +1035,9 @@ int session_prepare_vt(Session *s) {
mode.acqsig = SIGRTMIN + 1;
r = ioctl(vt, VT_SETMODE, &mode);
if (r < 0) {
- r = -errno;
- log_error_errno(errno, "Cannot set VT_PROCESS on /dev/tty%u: %m", s->vtnr);
+ r = log_error_errno(errno,
+ "Cannot set VT_PROCESS on /dev/tty%u: %m",
+ s->vtnr);
goto error;
}
diff --git a/src/shared/clean-ipc.c b/src/shared/clean-ipc.c
index 48b10865da..d1cdb151b2 100644
--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -78,8 +78,9 @@ static int clean_sysvipc_shm(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning_errno(errno, "Failed to remove SysV shared memory segment %i: %m", shmid);
- ret = -errno;
+ ret = log_warning_errno(errno,
+ "Failed to remove SysV shared memory segment %i: %m",
+ shmid);
}
}
@@ -130,8 +131,9 @@ static int clean_sysvipc_sem(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning_errno(errno, "Failed to remove SysV semaphores object %i: %m", semid);
- ret = -errno;
+ ret = log_warning_errno(errno,
+ "Failed to remove SysV semaphores object %i: %m",
+ semid);
}
}
@@ -183,8 +185,9 @@ static int clean_sysvipc_msg(uid_t delete_uid) {
if (errno == EIDRM || errno == EINVAL)
continue;
- log_warning_errno(errno, "Failed to remove SysV message queue %i: %m", msgid);
- ret = -errno;
+ ret = log_warning_errno(errno,
+ "Failed to remove SysV message queue %i: %m",
+ msgid);
}
}
@@ -302,8 +305,9 @@ static int clean_posix_mq(uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning_errno(errno, "Failed to stat() MQ segment %s: %m", de->d_name);
- ret = -errno;
+ ret = log_warning_errno(errno,
+ "Failed to stat() MQ segment %s: %m",
+ de->d_name);
continue;
}
@@ -317,8 +321,9 @@ static int clean_posix_mq(uid_t uid) {
if (errno == ENOENT)
continue;
- log_warning_errno(errno, "Failed to unlink POSIX message queue %s: %m", fn);
- ret = -errno;
+ ret = log_warning_errno(errno,
+ "Failed to unlink POSIX message queue %s: %m",
+ fn);
}
}