summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-16 07:00:22 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-19 15:00:00 +0100
commitcb51ee7a6e537da5706b4eb4a6d673ebe9654ceb (patch)
treeab4f7be9a4bccf1afea8705e018a424afeee1389
parentaf229d7a5be768a49a7f0d1028d878a71b797bad (diff)
downloadsystemd-cb51ee7a6e537da5706b4eb4a6d673ebe9654ceb.tar.gz
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).
-rw-r--r--src/journal/journald-stream.c4
-rw-r--r--src/login/logind.c4
-rw-r--r--src/udev/udev-watch.c2
3 files changed, 7 insertions, 3 deletions
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 671ada718c..bb7330f3db 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -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;
}
diff --git a/src/login/logind.c b/src/login/logind.c
index 0a869ba447..3fa7d2fed6 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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;
}
diff --git a/src/udev/udev-watch.c b/src/udev/udev-watch.c
index 351cb6345a..61179ce03d 100644
--- a/src/udev/udev-watch.c
+++ b/src/udev/udev-watch.c
@@ -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);