From 159636cf74e2a14009925335bdefcc54904cc991 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Mon, 3 Jan 2022 10:20:23 +0100 Subject: boot: Convert goto into loop --- src/boot/efi/boot.c | 99 +++++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index e623c2c8b6..af24d1e788 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1022,61 +1022,62 @@ static CHAR8 *line_get_key_value( assert(key_ret); assert(value_ret); -skip: - line = content + *pos; - if (*line == '\0') - return NULL; - - linelen = 0; - while (line[linelen] && !strchra((CHAR8 *)"\n\r", line[linelen])) - linelen++; - - /* move pos to next line */ - *pos += linelen; - if (content[*pos]) - (*pos)++; - - /* empty line */ - if (linelen == 0) - goto skip; - - /* terminate line */ - line[linelen] = '\0'; - - /* remove leading whitespace */ - while (strchra((CHAR8 *)" \t", *line)) { - line++; - linelen--; - } + for (;;) { + line = content + *pos; + if (*line == '\0') + return NULL; - /* remove trailing whitespace */ - while (linelen > 0 && strchra((CHAR8 *)" \t", line[linelen-1])) - linelen--; - line[linelen] = '\0'; + linelen = 0; + while (line[linelen] && !strchra((CHAR8 *) "\n\r", line[linelen])) + linelen++; - if (*line == '#') - goto skip; + /* move pos to next line */ + *pos += linelen; + if (content[*pos]) + (*pos)++; - /* split key/value */ - value = line; - while (*value && !strchra(sep, *value)) - value++; - if (*value == '\0') - goto skip; - *value = '\0'; - value++; - while (*value && strchra(sep, *value)) - value++; + /* empty line */ + if (linelen == 0) + continue; + + /* terminate line */ + line[linelen] = '\0'; + + /* remove leading whitespace */ + while (strchra((CHAR8 *) " \t", *line)) { + line++; + linelen--; + } - /* unquote */ - if (value[0] == '"' && line[linelen-1] == '"') { + /* remove trailing whitespace */ + while (linelen > 0 && strchra((CHAR8 *) " \t", line[linelen - 1])) + linelen--; + line[linelen] = '\0'; + + if (*line == '#') + continue; + + /* split key/value */ + value = line; + while (*value && !strchra(sep, *value)) + value++; + if (*value == '\0') + continue; + *value = '\0'; value++; - line[linelen-1] = '\0'; - } + while (*value && strchra(sep, *value)) + value++; + + /* unquote */ + if (value[0] == '"' && line[linelen - 1] == '"') { + value++; + line[linelen - 1] = '\0'; + } - *key_ret = line; - *value_ret = value; - return line; + *key_ret = line; + *value_ret = value; + return line; + } } static void config_defaults_load_from_file(Config *config, CHAR8 *content) { -- cgit v1.2.3