Skip to content

Commit 8baefd3

Browse files
committed
kconfig: replace a switch()' statement by a more flexible if()' statement
With the upcoming dynamical configuration prefix, we can no longer assume that the prefix will start by a 'C'. As such, we can no longer hardcode this value in the `case ...:', so replace the `switch() { ... }' statement by a more flexible 'if () { ... }' statement. Signed-off-by: Arnaud Lacombe <lacombar@gmail.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Reviewed-by: Michal Marek <mmarek@suse.cz>
1 parent 71d8066 commit 8baefd3

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

‎scripts/kconfig/confdata.c‎

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ int conf_read_simple(const char *name, int def)
221221
while (fgets(line, sizeof(line), in)) {
222222
conf_lineno++;
223223
sym = NULL;
224-
switch (line[0]) {
225-
case '#':
224+
if (line[0] == '#') {
226225
if (memcmp(line + 2, "CONFIG_", 7))
227226
continue;
228227
p = strchr(line + 9, ' ');
@@ -254,12 +253,7 @@ int conf_read_simple(const char *name, int def)
254253
default:
255254
;
256255
}
257-
break;
258-
case 'C':
259-
if (memcmp(line, "CONFIG_", 7)) {
260-
conf_warning("unexpected data");
261-
continue;
262-
}
256+
} else if (memcmp(line, "CONFIG_", 7) == 0) {
263257
p = strchr(line + 7, '=');
264258
if (!p)
265259
continue;
@@ -286,12 +280,9 @@ int conf_read_simple(const char *name, int def)
286280
}
287281
if (conf_set_sym_val(sym, def, def_flags, p))
288282
continue;
289-
break;
290-
case '\r':
291-
case '\n':
292-
break;
293-
default:
294-
conf_warning("unexpected data");
283+
} else {
284+
if (line[0] != '\r' && line[0] != '\n')
285+
conf_warning("unexpected data");
295286
continue;
296287
}
297288
if (sym && sym_is_choice_value(sym)) {

0 commit comments

Comments
 (0)