diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-06-18 18:43:02 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-06-20 02:08:44 +0200 |
commit | dede0e335d1bf901b6ebfd774fab28928501e2fb (patch) | |
tree | 286421ba2d61df86e2404cd5cadb2fff2e0da9ad /src/shared/util.c | |
parent | tests: add tests for strv_extendf (diff) | |
download | systemd-dede0e335d1bf901b6ebfd774fab28928501e2fb.tar.xz systemd-dede0e335d1bf901b6ebfd774fab28928501e2fb.zip |
util.c: simplify rm_rf_children_dangerous
Diffstat (limited to '')
-rw-r--r-- | src/shared/util.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index bce4e634c2..34e91762bc 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -2671,7 +2671,7 @@ finish: } int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) { - DIR *d; + _cleanup_closedir_ DIR *d = NULL; int ret = 0; assert(fd >= 0); @@ -2694,15 +2694,12 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct errno = 0; de = readdir(d); - if (!de && errno != 0) { - if (ret == 0) + if (!de) { + if (errno != 0 && ret == 0) ret = -errno; - break; + return ret; } - if (!de) - break; - if (streq(de->d_name, ".") || streq(de->d_name, "..")) continue; @@ -2758,10 +2755,6 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct } } } - - closedir(d); - - return ret; } _pure_ static int is_temporary_fs(struct statfs *s) { |