Skip to content

Commit 48ab6c9

Browse files
committed
kconfig: massage the loop in conf_read_simple()
Make the while-loop code a little more readable. The gain is that "CONFIG_FOO" without '=' is warned as unexpected data. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 4aced3e commit 48ab6c9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

scripts/kconfig/confdata.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ int conf_read_simple(const char *name, int def)
443443

444444
while (getline_stripped(&line, &line_asize, in) != -1) {
445445
conf_lineno++;
446+
447+
if (!line[0]) /* blank line */
448+
continue;
449+
446450
if (line[0] == '#') {
447451
if (line[1] != ' ')
448452
continue;
@@ -458,17 +462,20 @@ int conf_read_simple(const char *name, int def)
458462
continue;
459463

460464
val = "n";
461-
} else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
465+
} else {
466+
if (memcmp(line, CONFIG_, strlen(CONFIG_))) {
467+
conf_warning("unexpected data: %s", line);
468+
continue;
469+
}
470+
462471
sym_name = line + strlen(CONFIG_);
463472
p = strchr(sym_name, '=');
464-
if (!p)
473+
if (!p) {
474+
conf_warning("unexpected data: %s", line);
465475
continue;
476+
}
466477
*p = 0;
467478
val = p + 1;
468-
} else {
469-
if (line[0] != '\0')
470-
conf_warning("unexpected data: %s", line);
471-
continue;
472479
}
473480

474481
sym = sym_find(sym_name);

0 commit comments

Comments
 (0)