]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: replace readdir() loops with FOREACH_DIRENT 2487/head
authorMichal Sekletar <msekleta@redhat.com>
Sun, 31 Jan 2016 08:41:43 +0000 (09:41 +0100)
committerMichal Sekletar <msekleta@redhat.com>
Sun, 31 Jan 2016 08:44:53 +0000 (09:44 +0100)
src/boot/bootctl.c

index 77eea6aada40cac12f114f265292b9cfea098269..13cf323bb70101db9668f69d205759ff4fb2f639 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "alloc-util.h"
 #include "blkid-util.h"
+#include "dirent-util.h"
 #include "efivars.h"
 #include "fd-util.h"
 #include "fileio.h"
@@ -249,13 +250,10 @@ static int enumerate_binaries(const char *esp_path, const char *path, const char
                 return log_error_errno(errno, "Failed to read \"%s\": %m", p);
         }
 
-        while ((de = readdir(d))) {
+        FOREACH_DIRENT(de, d, break) {
                 _cleanup_close_ int fd = -1;
                 _cleanup_free_ char *v = NULL;
 
-                if (de->d_name[0] == '.')
-                        continue;
-
                 if (!endswith_no_case(de->d_name, ".efi"))
                         continue;
 
@@ -614,12 +612,9 @@ static int install_binaries(const char *esp_path, bool force) {
         if (!d)
                 return log_error_errno(errno, "Failed to open \""BOOTLIBDIR"\": %m");
 
-        while ((de = readdir(d))) {
+        FOREACH_DIRENT(de, d, break) {
                 int k;
 
-                if (de->d_name[0] == '.')
-                        continue;
-
                 if (!endswith_no_case(de->d_name, ".efi"))
                         continue;
 
@@ -797,13 +792,10 @@ static int remove_boot_efi(const char *esp_path) {
                 return log_error_errno(errno, "Failed to open directory \"%s\": %m", p);
         }
 
-        while ((de = readdir(d))) {
+        FOREACH_DIRENT(de, d, break) {
                 _cleanup_close_ int fd = -1;
                 _cleanup_free_ char *v = NULL;
 
-                if (de->d_name[0] == '.')
-                        continue;
-
                 if (!endswith_no_case(de->d_name, ".efi"))
                         continue;