diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-18 16:20:43 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-18 16:23:45 +0200 |
commit | e393eff6224792fe3e4339ffdd7cead92feee551 (patch) | |
tree | 77e007935bafad31e4de24b2520b50780cbd18e7 /src/sysv-generator | |
parent | sysusers: FOREACH_LINE excorcism (diff) | |
download | systemd-e393eff6224792fe3e4339ffdd7cead92feee551.tar.xz systemd-e393eff6224792fe3e4339ffdd7cead92feee551.zip |
sysv-generator: FOREACH_LINE excorcism
Diffstat (limited to 'src/sysv-generator')
-rw-r--r-- | src/sysv-generator/sysv-generator.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c index 2b1e267c08..65313d4416 100644 --- a/src/sysv-generator/sysv-generator.c +++ b/src/sysv-generator/sysv-generator.c @@ -5,6 +5,7 @@ #include <unistd.h> #include "alloc-util.h" +#include "def.h" #include "dirent-util.h" #include "exit-status.h" #include "fd-util.h" @@ -432,7 +433,6 @@ static int load_sysv(SysvStub *s) { _cleanup_free_ char *short_description = NULL, *long_description = NULL, *chkconfig_description = NULL; char *description; bool supports_reload = false; - char l[LINE_MAX]; assert(s); @@ -446,9 +446,16 @@ static int load_sysv(SysvStub *s) { log_debug("Loading SysV script %s", s->path); - FOREACH_LINE(l, f, goto fail) { + for (;;) { + _cleanup_free_ char *l = NULL; char *t; + r = read_line(f, LONG_LINE_MAX, &l); + if (r < 0) + return log_error_errno(r, "Failed to read configuration file '%s': %m", s->path); + if (r == 0) + break; + line++; t = strstrip(l); @@ -456,7 +463,7 @@ static int load_sysv(SysvStub *s) { /* Try to figure out whether this init script supports * the reload operation. This heuristic looks for * "Usage" lines which include the reload option. */ - if ( state == USAGE_CONTINUATION || + if (state == USAGE_CONTINUATION || (state == NORMAL && strcasestr(t, "usage"))) { if (usage_contains_reload(t)) { supports_reload = true; @@ -644,9 +651,6 @@ static int load_sysv(SysvStub *s) { s->loaded = true; return 0; - -fail: - return log_error_errno(errno, "Failed to read configuration file '%s': %m", s->path); } static int fix_order(SysvStub *s, Hashmap *all_services) { |