From 8fb3f0099787a5b48213c4e2aa42d8ff61b0c7f1 Mon Sep 17 00:00:00 2001 From: Reverend Homer Date: Fri, 9 Dec 2016 12:04:30 +0300 Subject: tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853) --- src/delta/delta.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/delta/delta.c') diff --git a/src/delta/delta.c b/src/delta/delta.c index 107b105fde..9a44b15da7 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -297,6 +297,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const char *path, bool dropins) { _cleanup_closedir_ DIR *d; + struct dirent *de; assert(top); assert(bottom); @@ -313,16 +314,10 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch return log_error_errno(errno, "Failed to open %s: %m", path); } - for (;;) { - struct dirent *de; + FOREACH_DIRENT_ALL(de, d, return -errno) { int k; char *p; - errno = 0; - de = readdir(d); - if (!de) - return -errno; - dirent_ensure_type(d, de); if (dropins && de->d_type == DT_DIR && endswith(de->d_name, ".d")) @@ -354,6 +349,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch return k; } } + return 0; } static int should_skip_prefix(const char* p) { -- cgit v1.2.3