diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-18 16:09:19 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-18 16:23:45 +0200 |
commit | 8d2b9d14c4d0db9d639987535efb3e7f671ce734 (patch) | |
tree | 7e111d3839dd790c9d7576915ad53196e38526b6 /src/basic/time-util.c | |
parent | 7e7a16a00e6702b04d424371a6a8b76050791f05 (diff) | |
download | systemd-8d2b9d14c4d0db9d639987535efb3e7f671ce734.tar.gz |
time-util: FOREACH_LINE excorcism
Diffstat (limited to 'src/basic/time-util.c')
-rw-r--r-- | src/basic/time-util.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 9ac739b42a..158e4aaf93 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -14,6 +14,7 @@ #include <unistd.h> #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; |