1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

Add some handling to remaining unlinkat calls

Coverity now started warning about this ("Calling unlinkat without checking
return value (as is done elsewhere 12 out of 15 times).", and it is right:
most of the time we should at list print a log message so people can figure
out something is wrong when this happens.

v2:
- use warning level in journald too (this is unlikely to happen ever, so it
  should be safe to something that is visible by default).
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2018-02-16 07:00:22 +01:00
parent af229d7a5b
commit cb51ee7a6e
3 changed files with 7 additions and 3 deletions

View File

@ -778,7 +778,9 @@ int server_restore_streams(Server *s, FDSet *fds) {
if (!found) {
/* No file descriptor? Then let's delete the state file */
log_debug("Cannot restore stream file %s", de->d_name);
unlinkat(dirfd(d), de->d_name, 0);
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to remove /run/systemd/journal/streams/%s: %m",
de->d_name);
continue;
}

View File

@ -323,7 +323,9 @@ static int manager_enumerate_seats(Manager *m) {
s = hashmap_get(m->seats, de->d_name);
if (!s) {
unlinkat(dirfd(d), de->d_name, 0);
if (unlinkat(dirfd(d), de->d_name, 0) < 0)
log_warning("Failed to remove /run/systemd/seats/%s: %m",
de->d_name);
continue;
}

View File

@ -79,7 +79,7 @@ void udev_watch_restore(struct udev *udev) {
udev_watch_begin(udev, dev);
udev_device_unref(dev);
unlink:
unlinkat(dirfd(dir), ent->d_name, 0);
(void) unlinkat(dirfd(dir), ent->d_name, 0);
}
closedir(dir);