diff options
author | Jan Janssen <medhefgo@web.de> | 2022-01-03 10:20:23 +0100 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2022-01-03 10:20:23 +0100 |
commit | 159636cf74e2a14009925335bdefcc54904cc991 (patch) | |
tree | 1d5bce10258d240e718c32c6b268ebc195adbd04 | |
parent | boot: Rename cleanup functions (diff) | |
download | systemd-159636cf74e2a14009925335bdefcc54904cc991.tar.xz systemd-159636cf74e2a14009925335bdefcc54904cc991.zip |
boot: Convert goto into loop
-rw-r--r-- | src/boot/efi/boot.c | 99 |
1 files 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) { |