]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Add some handling to remaining unlinkat calls
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 16 Feb 2018 06:00:22 +0000 (07:00 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Feb 2018 14:00:00 +0000 (15:00 +0100)
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).

src/journal/journald-stream.c
src/login/logind.c
src/udev/udev-watch.c

index 671ada718c2e9bcad603f15709995487fc71ac64..bb7330f3db997afe47973b8816e609af51938a02 100644 (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;
                 }
 
index 0a869ba447d58cf18db269ac4f06ed11563a0b04..3fa7d2fed63f32d979a927843444b58195fee5be 100644 (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;
                 }
 
index 351cb6345a42f07edb37bef45dd9d7f1c983d4c4..61179ce03db8083ad85094f9f45eaa895c5754b1 100644 (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);