Skip to content

Commit f498926

Browse files
committed
kconfig: improve the recursive dependency report
This commit improves the messages of the recursive dependency. Currently, sym->dir_dep.expr is not checked. Hence, any dependency in property visibility is regarded as the dependency of the symbol. [Test Code 1] config A bool "a" depends on B config B bool "b" depends on A [Test Code 2] config A bool "a" if B config B bool "b" depends on A For both cases above, the same message is displayed: symbol B depends on A symbol A depends on B This commit changes the message for the latter, like this: symbol B depends on A symbol A prompt is visible depending on B Also, 'select' and 'imply' are distinguished. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Dirk Gouders <dirk@gouders.net>
1 parent 5e8c529 commit f498926

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

‎scripts/kconfig/symbol.c‎

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ static struct dep_stack {
10111011
struct dep_stack *prev, *next;
10121012
struct symbol *sym;
10131013
struct property *prop;
1014-
struct expr *expr;
1014+
struct expr **expr;
10151015
} *check_top;
10161016

10171017
static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
@@ -1076,31 +1076,42 @@ static void sym_check_print_recursive(struct symbol *last_sym)
10761076
fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
10771077
prop->file->name, prop->lineno);
10781078

1079-
if (stack->expr) {
1080-
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1081-
prop->file->name, prop->lineno,
1079+
if (sym_is_choice(sym)) {
1080+
fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1081+
menu->file->name, menu->lineno,
1082+
sym->name ? sym->name : "<choice>",
1083+
next_sym->name ? next_sym->name : "<choice>");
1084+
} else if (sym_is_choice_value(sym)) {
1085+
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1086+
menu->file->name, menu->lineno,
10821087
sym->name ? sym->name : "<choice>",
1083-
prop_get_type_name(prop->type),
10841088
next_sym->name ? next_sym->name : "<choice>");
1085-
} else if (stack->prop) {
1089+
} else if (stack->expr == &sym->dir_dep.expr) {
10861090
fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
10871091
prop->file->name, prop->lineno,
10881092
sym->name ? sym->name : "<choice>",
10891093
next_sym->name ? next_sym->name : "<choice>");
1090-
} else if (sym_is_choice(sym)) {
1091-
fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1092-
menu->file->name, menu->lineno,
1094+
} else if (stack->expr == &sym->rev_dep.expr) {
1095+
fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1096+
prop->file->name, prop->lineno,
10931097
sym->name ? sym->name : "<choice>",
10941098
next_sym->name ? next_sym->name : "<choice>");
1095-
} else if (sym_is_choice_value(sym)) {
1096-
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1097-
menu->file->name, menu->lineno,
1099+
} else if (stack->expr == &sym->implied.expr) {
1100+
fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
1101+
prop->file->name, prop->lineno,
10981102
sym->name ? sym->name : "<choice>",
10991103
next_sym->name ? next_sym->name : "<choice>");
1104+
} else if (stack->expr) {
1105+
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1106+
prop->file->name, prop->lineno,
1107+
sym->name ? sym->name : "<choice>",
1108+
prop_get_type_name(prop->type),
1109+
next_sym->name ? next_sym->name : "<choice>");
11001110
} else {
1101-
fprintf(stderr, "%s:%d:\tsymbol %s is selected or implied by %s\n",
1111+
fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
11021112
prop->file->name, prop->lineno,
11031113
sym->name ? sym->name : "<choice>",
1114+
prop_get_type_name(prop->type),
11041115
next_sym->name ? next_sym->name : "<choice>");
11051116
}
11061117
}
@@ -1157,14 +1168,23 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym)
11571168

11581169
dep_stack_insert(&stack, sym);
11591170

1171+
stack.expr = &sym->dir_dep.expr;
1172+
sym2 = sym_check_expr_deps(sym->dir_dep.expr);
1173+
if (sym2)
1174+
goto out;
1175+
1176+
stack.expr = &sym->rev_dep.expr;
11601177
sym2 = sym_check_expr_deps(sym->rev_dep.expr);
11611178
if (sym2)
11621179
goto out;
11631180

1181+
stack.expr = &sym->implied.expr;
11641182
sym2 = sym_check_expr_deps(sym->implied.expr);
11651183
if (sym2)
11661184
goto out;
11671185

1186+
stack.expr = NULL;
1187+
11681188
for (prop = sym->prop; prop; prop = prop->next) {
11691189
if (prop->type == P_CHOICE || prop->type == P_SELECT ||
11701190
prop->type == P_IMPLY)
@@ -1175,7 +1195,7 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym)
11751195
break;
11761196
if (prop->type != P_DEFAULT || sym_is_choice(sym))
11771197
continue;
1178-
stack.expr = prop->expr;
1198+
stack.expr = &prop->expr;
11791199
sym2 = sym_check_expr_deps(prop->expr);
11801200
if (sym2)
11811201
break;

‎scripts/kconfig/tests/err_recursive_dep/expected_stderr‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Kconfig:11:error: recursive dependency detected!
2-
Kconfig:11: symbol B is selected or implied by B
2+
Kconfig:11: symbol B is selected by B
33
For a resolution refer to Documentation/kbuild/kconfig-language.txt
44
subsection "Kconfig recursive dependency limitations"
55

@@ -15,14 +15,14 @@ For a resolution refer to Documentation/kbuild/kconfig-language.txt
1515
subsection "Kconfig recursive dependency limitations"
1616

1717
Kconfig:32:error: recursive dependency detected!
18-
Kconfig:32: symbol D2 is selected or implied by D1
18+
Kconfig:32: symbol D2 is selected by D1
1919
Kconfig:27: symbol D1 depends on D2
2020
For a resolution refer to Documentation/kbuild/kconfig-language.txt
2121
subsection "Kconfig recursive dependency limitations"
2222

2323
Kconfig:37:error: recursive dependency detected!
2424
Kconfig:37: symbol E1 depends on E2
25-
Kconfig:42: symbol E2 is selected or implied by E1
25+
Kconfig:42: symbol E2 is implied by E1
2626
For a resolution refer to Documentation/kbuild/kconfig-language.txt
2727
subsection "Kconfig recursive dependency limitations"
2828

0 commit comments

Comments
 (0)