mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
tree-wide: make use of log_error_errno() return value in more cases
The previous coccinelle semantic patch that improved usage of log_error_errno()'s return value, only looked for log_error_errno() invocations with a single parameter after the error parameter. Update the patch to handle arbitrary numbers of additional arguments.
This commit is contained in:
parent
9c00a6adfa
commit
94c156cd45
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user