Skip to content

Commit 953742c

Browse files
committed
kconfig: fix __enabled_ macros definition for invisible and un-selected symbols
__enabled_<sym-name> are only generated on visible or selected entries, do not reflect the purpose of its introduction. Fix this by always generating these entries for named symbol. Reported-by: Rabin Vincent <[email protected]> Signed-off-by: Arnaud Lacombe <[email protected]>
1 parent 322a8b0 commit 953742c

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

scripts/kconfig/confdata.c

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -503,17 +503,6 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
503503
fprintf(fp, "#define %s%s%s 1\n",
504504
CONFIG_, sym->name, suffix);
505505
}
506-
/*
507-
* Generate the __enabled_CONFIG_* and
508-
* __enabled_CONFIG_*_MODULE macros for use by the
509-
* IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
510-
* generated even for booleans so that the IS_ENABLED() macro
511-
* works.
512-
*/
513-
fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
514-
sym->name, (*value == 'y'));
515-
fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
516-
sym->name, (*value == 'm'));
517506
break;
518507
}
519508
case S_HEX: {
@@ -564,6 +553,35 @@ static struct conf_printer header_printer_cb =
564553
.print_comment = header_print_comment,
565554
};
566555

556+
/*
557+
* Generate the __enabled_CONFIG_* and __enabled_CONFIG_*_MODULE macros for
558+
* use by the IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is
559+
* generated even for booleans so that the IS_ENABLED() macro works.
560+
*/
561+
static void
562+
header_print__enabled_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
563+
{
564+
565+
switch (sym->type) {
566+
case S_BOOLEAN:
567+
case S_TRISTATE: {
568+
fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n",
569+
sym->name, (*value == 'y'));
570+
fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n",
571+
sym->name, (*value == 'm'));
572+
break;
573+
}
574+
default:
575+
break;
576+
}
577+
}
578+
579+
static struct conf_printer header__enabled_printer_cb =
580+
{
581+
.print_symbol = header_print__enabled_symbol,
582+
.print_comment = header_print_comment,
583+
};
584+
567585
/*
568586
* Tristate printer
569587
*
@@ -945,11 +963,16 @@ int conf_write_autoconf(void)
945963
conf_write_heading(out_h, &header_printer_cb, NULL);
946964

947965
for_all_symbols(i, sym) {
966+
if (!sym->name)
967+
continue;
968+
948969
sym_calc_value(sym);
949-
if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
970+
971+
conf_write_symbol(out_h, sym, &header__enabled_printer_cb, NULL);
972+
973+
if (!(sym->flags & SYMBOL_WRITE))
950974
continue;
951975

952-
/* write symbol to auto.conf, tristate and header files */
953976
conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
954977

955978
conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);

0 commit comments

Comments
 (0)