chiark / gitweb /
util: make gcc shut up
[elogind.git] / util.c
diff --git a/util.c b/util.c
index f3af9567cf49cb79043977511e52b2112e0361b9..43826990cd702244cb67e5881da6a98e74f2c4b6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1133,7 +1133,7 @@ int close_all_fds(const int except[], unsigned n_except) {
                 return -errno;
 
         while ((de = readdir(d))) {
-                int fd;
+                int fd = -1;
 
                 if (de->d_name[0] == '.')
                         continue;
@@ -1162,10 +1162,15 @@ int close_all_fds(const int except[], unsigned n_except) {
                                 continue;
                 }
 
-                if ((r = close_nointr(fd)) < 0)
-                        goto finish;
+                if ((r = close_nointr(fd)) < 0) {
+                        /* Valgrind has its own FD and doesn't want to have it closed */
+                        if (errno != EBADF)
+                                goto finish;
+                }
         }
 
+        r = 0;
+
 finish:
         closedir(d);
         return r;