summaryrefslogtreecommitdiff
path: root/src/basic/fs-util.c
diff options
context:
space:
mode:
authorReverend Homer <mk.43.ecko@gmail.com>2016-12-09 12:04:30 +0300
committerMartin Pitt <martin.pitt@ubuntu.com>2016-12-09 10:04:30 +0100
commit8fb3f0099787a5b48213c4e2aa42d8ff61b0c7f1 (patch)
treec9bf990e18daac08ec1e744d6be365a9e98d2532 /src/basic/fs-util.c
parent9258a1cae3985ee590f1c698451bd7909aa38d2b (diff)
tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r--src/basic/fs-util.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
index b30cec4f92..5b23269109 100644
--- a/src/basic/fs-util.c
+++ b/src/basic/fs-util.c
@@ -17,7 +17,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include <dirent.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
@@ -446,6 +445,7 @@ int mkfifo_atomic(const char *path, mode_t mode) {
int get_files_in_directory(const char *path, char ***list) {
_cleanup_closedir_ DIR *d = NULL;
+ struct dirent *de;
size_t bufsize = 0, n = 0;
_cleanup_strv_free_ char **l = NULL;
@@ -459,16 +459,7 @@ int get_files_in_directory(const char *path, char ***list) {
if (!d)
return -errno;
- for (;;) {
- struct dirent *de;
-
- errno = 0;
- de = readdir(d);
- if (!de && errno > 0)
- return -errno;
- if (!de)
- break;
-
+ FOREACH_DIRENT_ALL(de, d, return -errno) {
dirent_ensure_type(d, de);
if (!dirent_is_file(de))