From: Lennart Poettering Date: Thu, 18 Oct 2018 14:18:20 +0000 (+0200) Subject: install: FOREACH_LINE excorcism X-Git-Tag: v240~513^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bef77f378c4391e1baacd106944853639aa68517;p=thirdparty%2Fsystemd.git install: FOREACH_LINE excorcism --- diff --git a/src/shared/install.c b/src/shared/install.c index ccb999998ce..61b713c6b60 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -15,6 +15,7 @@ #include "alloc-util.h" #include "conf-files.h" #include "conf-parser.h" +#include "def.h" #include "dirent-util.h" #include "extract-word.h" #include "fd-util.h" @@ -2841,7 +2842,6 @@ static int read_presets(UnitFileScope scope, const char *root_dir, Presets *pres STRV_FOREACH(p, files) { _cleanup_fclose_ FILE *f; - char line[LINE_MAX]; int n = 0; f = fopen(*p, "re"); @@ -2852,11 +2852,18 @@ static int read_presets(UnitFileScope scope, const char *root_dir, Presets *pres return -errno; } - FOREACH_LINE(line, f, return -errno) { + for (;;) { + _cleanup_free_ char *line = NULL; PresetRule rule = {}; const char *parameter; char *l; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; + l = strstrip(line); n++;