diff options
author | Tom Gundersen <teg@jklm.no> | 2016-01-03 14:02:10 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2016-01-03 14:02:10 +0100 |
commit | 113325b8641207a99447d8a439e7ffac1e69f196 (patch) | |
tree | 169dab1461ecff7e55fc54c7702d80511c2bd5ae /src/basic/conf-files.c | |
parent | 5809f340fd7e5e6c76e229059c50d92e1f57e8d8 (diff) | |
parent | c1dafe4f310aeb80d513c00a388d8cbb5a397838 (diff) |
Merge pull request #2256 from poettering/dnssec10
Tenth DNSSEC patch set
Diffstat (limited to 'src/basic/conf-files.c')
-rw-r--r-- | src/basic/conf-files.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/basic/conf-files.c b/src/basic/conf-files.c index 75dad228e3..5854caeb51 100644 --- a/src/basic/conf-files.c +++ b/src/basic/conf-files.c @@ -41,6 +41,7 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) { _cleanup_closedir_ DIR *dir = NULL; const char *dirpath; + struct dirent *de; int r; assert(path); @@ -55,18 +56,9 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char return -errno; } - for (;;) { - struct dirent *de; + FOREACH_DIRENT(de, dir, return -errno) { char *p; - errno = 0; - de = readdir(dir); - if (!de && errno != 0) - return -errno; - - if (!de) - break; - if (!dirent_is_file_with_suffix(de, suffix)) continue; @@ -116,17 +108,15 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const STRV_FOREACH(p, dirs) { r = files_add(fh, root, *p, suffix); - if (r == -ENOMEM) { + if (r == -ENOMEM) return r; - } else if (r < 0) - log_debug_errno(r, "Failed to search for files in %s: %m", - *p); + if (r < 0) + log_debug_errno(r, "Failed to search for files in %s, ignoring: %m", *p); } files = hashmap_get_strv(fh); - if (files == NULL) { + if (!files) return -ENOMEM; - } qsort_safe(files, hashmap_size(fh), sizeof(char *), base_cmp); *strv = files; |