chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:58:58 +0000 (07:58 +0200)
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/login/logind.c

index 10cec356605232eba56e90836dc520cd4a396c0c..7246c13ecd9e3f14d1e39f3ffff2bf25a643474a 100644 (file)
@@ -350,7 +350,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;
                 }