diff options
author | Reverend Homer <mk.43.ecko@gmail.com> | 2016-12-09 12:04:30 +0300 |
---|---|---|
committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-12-09 10:04:30 +0100 |
commit | 8fb3f0099787a5b48213c4e2aa42d8ff61b0c7f1 (patch) | |
tree | c9bf990e18daac08ec1e744d6be365a9e98d2532 /src/core | |
parent | 9258a1cae3985ee590f1c698451bd7909aa38d2b (diff) |
tree-wide: replace all readdir cycles with FOREACH_DIRENT{,_ALL} (#4853)
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/killall.c | 3 | ||||
-rw-r--r-- | src/core/manager.c | 14 |
2 files changed, 5 insertions, 12 deletions
diff --git a/src/core/killall.c b/src/core/killall.c index 3bc19e9c84..b3aa22adc5 100644 --- a/src/core/killall.c +++ b/src/core/killall.c @@ -24,6 +24,7 @@ #include "alloc-util.h" #include "def.h" +#include "dirent-util.h" #include "fd-util.h" #include "format-util.h" #include "killall.h" @@ -172,7 +173,7 @@ static int killall(int sig, Set *pids, bool send_sighup) { if (!dir) return -errno; - while ((d = readdir(dir))) { + FOREACH_DIRENT_ALL(d, dir, break) { pid_t pid; int r; diff --git a/src/core/manager.c b/src/core/manager.c index 1f663d3c1d..21cd6062c6 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -17,7 +17,6 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <dirent.h> #include <errno.h> #include <fcntl.h> #include <linux/kd.h> @@ -233,6 +232,7 @@ static void manager_print_jobs_in_progress(Manager *m) { static int have_ask_password(void) { _cleanup_closedir_ DIR *dir; + struct dirent *de; dir = opendir("/run/systemd/ask-password"); if (!dir) { @@ -242,19 +242,11 @@ static int have_ask_password(void) { return -errno; } - for (;;) { - struct dirent *de; - - errno = 0; - de = readdir(dir); - if (!de && errno > 0) - return -errno; - if (!de) - return false; - + FOREACH_DIRENT_ALL(de, dir, return -errno) { if (startswith(de->d_name, "ask.")) return true; } + return false; } static int manager_dispatch_ask_password_fd(sd_event_source *source, |