summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-31 14:57:20 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-31 14:57:20 +0100
commit09ce74e196d5f24ebaed32ff2883e5a870abd6f8 (patch)
tree697c12baf3376d076055a33f5bc33095ebf7cb23
parentdcabda41558bf80724992d3973388af6974af5eb (diff)
parente41256dcec37e03f80f9913d629a0917812abb9e (diff)
Merge pull request #2487 from msekletar/bootctl-foreach-dirent
bootctl: replace readdir() loops with FOREACH_DIRENT
-rw-r--r--src/boot/bootctl.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 77eea6aada..13cf323bb7 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -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;