From: Lennart Poettering Date: Thu, 18 Oct 2018 14:09:19 +0000 (+0200) Subject: time-util: FOREACH_LINE excorcism X-Git-Tag: v240~513^2~20 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8d2b9d14c4d0db9d639987535efb3e7f671ce734;p=thirdparty%2Fsystemd.git time-util: FOREACH_LINE excorcism --- diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 9ac739b42ad..158e4aaf934 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -14,6 +14,7 @@ #include #include "alloc-util.h" +#include "def.h" #include "fd-util.h" #include "fileio.h" #include "fs-util.h" @@ -1222,6 +1223,7 @@ int get_timezones(char ***ret) { _cleanup_fclose_ FILE *f = NULL; _cleanup_strv_free_ char **zones = NULL; size_t n_zones = 0, n_allocated = 0; + int r; assert(ret); @@ -1234,13 +1236,18 @@ int get_timezones(char ***ret) { f = fopen("/usr/share/zoneinfo/zone.tab", "re"); if (f) { - char l[LINE_MAX]; - - FOREACH_LINE(l, f, return -errno) { + for (;;) { + _cleanup_free_ char *line = NULL; char *p, *w; size_t k; - p = strstrip(l); + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return r; + if (r == 0) + break; + + p = strstrip(line); if (isempty(p) || *p == '#') continue;