From: Lennart Poettering Date: Thu, 18 Oct 2018 14:15:35 +0000 (+0200) Subject: localectl: FOREACH_LINE excorcism X-Git-Tag: v240~513^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=271c8ec50f48fae5523f8355b5233fa1db5c6a42;p=platform%2Fupstream%2Fsystemd.git localectl: FOREACH_LINE excorcism --- diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 88fd077..e2a9415 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -280,7 +280,6 @@ static int set_x11_keymap(int argc, char **argv, void *userdata) { static int list_x11_keymaps(int argc, char **argv, void *userdata) { _cleanup_fclose_ FILE *f = NULL; _cleanup_strv_free_ char **list = NULL; - char line[LINE_MAX]; enum { NONE, MODELS, @@ -305,9 +304,16 @@ static int list_x11_keymaps(int argc, char **argv, void *userdata) { else assert_not_reached("Wrong parameter"); - FOREACH_LINE(line, f, break) { + for (;;) { + _cleanup_free_ char *line = NULL; char *l, *w; + r = read_line(f, LONG_LINE_MAX, &line); + if (r < 0) + return log_error_errno(r, "Failed to read keyboard mapping list: %m"); + if (r == 0) + break; + l = strstrip(line); if (isempty(l))