Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kconfig: print recursive dependency errors in the parsed order

for_all_symbols() iterates in the symbol hash table. The order of
iteration depends on the hash table implementation.

If you use it for printing errors, they are shown in random order.

For example, the order of following test input and the corresponding
error do not match:
- scripts/kconfig/tests/err_recursive_dep/Kconfig
- scripts/kconfig/tests/err_recursive_dep/expected_stderr

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+27 -15
+16 -4
scripts/kconfig/parser.y
··· 473 473 474 474 void conf_parse(const char *name) 475 475 { 476 - struct symbol *sym; 477 - int i; 476 + struct menu *menu; 478 477 479 478 autoconf_cmd = str_new(); 480 479 ··· 516 517 } 517 518 518 519 menu_finalize(&rootmenu); 519 - for_all_symbols(i, sym) { 520 - if (sym_check_deps(sym)) 520 + 521 + menu = &rootmenu; 522 + while (menu) { 523 + if (menu->sym && sym_check_deps(menu->sym)) 521 524 yynerrs++; 525 + 526 + if (menu->list) { 527 + menu = menu->list; 528 + continue; 529 + } 530 + 531 + while (!menu->next && menu->parent) 532 + menu = menu->parent; 533 + 534 + menu = menu->next; 522 535 } 536 + 523 537 if (yynerrs) 524 538 exit(1); 525 539 conf_set_changed(true);
+11 -11
scripts/kconfig/tests/err_recursive_dep/expected_stderr
··· 1 - Kconfig:11:error: recursive dependency detected! 2 - Kconfig:11: symbol B is selected by B 1 + Kconfig:5:error: recursive dependency detected! 2 + Kconfig:5: symbol A depends on A 3 3 For a resolution refer to Documentation/kbuild/kconfig-language.rst 4 4 subsection "Kconfig recursive dependency limitations" 5 5 6 - Kconfig:5:error: recursive dependency detected! 7 - Kconfig:5: symbol A depends on A 6 + Kconfig:11:error: recursive dependency detected! 7 + Kconfig:11: symbol B is selected by B 8 8 For a resolution refer to Documentation/kbuild/kconfig-language.rst 9 9 subsection "Kconfig recursive dependency limitations" 10 10 ··· 14 14 For a resolution refer to Documentation/kbuild/kconfig-language.rst 15 15 subsection "Kconfig recursive dependency limitations" 16 16 17 - Kconfig:32:error: recursive dependency detected! 18 - Kconfig:32: symbol D2 is selected by D1 17 + Kconfig:27:error: recursive dependency detected! 19 18 Kconfig:27: symbol D1 depends on D2 19 + Kconfig:32: symbol D2 is selected by D1 20 20 For a resolution refer to Documentation/kbuild/kconfig-language.rst 21 21 subsection "Kconfig recursive dependency limitations" 22 22 ··· 26 26 For a resolution refer to Documentation/kbuild/kconfig-language.rst 27 27 subsection "Kconfig recursive dependency limitations" 28 28 29 - Kconfig:60:error: recursive dependency detected! 30 - Kconfig:60: symbol G depends on G 29 + Kconfig:49:error: recursive dependency detected! 30 + Kconfig:49: symbol F1 default value contains F2 31 + Kconfig:51: symbol F2 depends on F1 31 32 For a resolution refer to Documentation/kbuild/kconfig-language.rst 32 33 subsection "Kconfig recursive dependency limitations" 33 34 34 - Kconfig:51:error: recursive dependency detected! 35 - Kconfig:51: symbol F2 depends on F1 36 - Kconfig:49: symbol F1 default value contains F2 35 + Kconfig:60:error: recursive dependency detected! 36 + Kconfig:60: symbol G depends on G 37 37 For a resolution refer to Documentation/kbuild/kconfig-language.rst 38 38 subsection "Kconfig recursive dependency limitations"