Skip to content

Commit 51d792c

Browse files
committed
kconfig: refactor listnewconfig code
We can reuse __print_symbol() helper to print symbols for listnewconfig. Only the difference is the format for "n" symbols. This prints "CONFIG_FOO=n" instead of "# CONFIG_FOO is not set". Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 6ce45a9 commit 51d792c

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

scripts/kconfig/conf.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -646,18 +646,8 @@ static void check_conf(struct menu *menu)
646646

647647
switch (input_mode) {
648648
case listnewconfig:
649-
if (sym->name) {
650-
const char *val = sym_get_string_value(sym);
651-
char *escaped = NULL;
652-
653-
if (sym->type == S_STRING) {
654-
escaped = sym_escape_string_value(val);
655-
val = escaped;
656-
}
657-
658-
printf("%s%s=%s\n", CONFIG_, sym->name, val);
659-
free(escaped);
660-
}
649+
if (sym->name)
650+
print_symbol_for_listconfig(sym);
661651
break;
662652
case helpnewconfig:
663653
printf("-----\n");

scripts/kconfig/confdata.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ static void print_symbol_for_autoconf(FILE *fp, struct symbol *sym)
667667
__print_symbol(fp, sym, OUTPUT_N_NONE, true);
668668
}
669669

670+
void print_symbol_for_listconfig(struct symbol *sym)
671+
{
672+
__print_symbol(stdout, sym, OUTPUT_N, true);
673+
}
674+
670675
static void print_symbol_for_c(FILE *fp, struct symbol *sym)
671676
{
672677
const char *val;

scripts/kconfig/lkc_proto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
1919
struct symbol * sym_lookup(const char *name, int flags);
2020
struct symbol * sym_find(const char *name);
2121
char *sym_escape_string_value(const char *in);
22+
void print_symbol_for_listconfig(struct symbol *sym);
2223
struct symbol ** sym_re_search(const char *pattern);
2324
const char * sym_type_name(enum symbol_type type);
2425
void sym_calc_value(struct symbol *sym);

0 commit comments

Comments
 (0)