diff options
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, |