Skip to content

Commit 5447d34

Browse files
committed
kconfig: error out if recursive dependencies are found
Sample: config FOO bool "This is foo" depends on BAR config BAR bool "This is bar" depends on FOO This will result in following error message: error: found recursive dependency: FOO -> BAR -> FOO And will then exit with exit code equal 1 so make will stop. Inspired by patch from: Adrian Bunk <bunk@stusta.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Adrian Bunk <bunk@stusta.de> Cc: Roman Zippel <zippel@linux-m68k.org>
1 parent 04c58f8 commit 5447d34

3 files changed

Lines changed: 13 additions & 12 deletions

File tree

‎scripts/kconfig/symbol.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,15 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
786786
return NULL;
787787
}
788788

789+
/* return NULL when dependencies are OK */
789790
struct symbol *sym_check_deps(struct symbol *sym)
790791
{
791792
struct symbol *sym2;
792793
struct property *prop;
793794

794795
if (sym->flags & SYMBOL_CHECK) {
795-
printf("Warning! Found recursive dependency: %s", sym->name);
796+
fprintf(stderr, "%s:%d:error: found recursive dependency: %s",
797+
sym->prop->file->name, sym->prop->lineno, sym->name);
796798
return sym;
797799
}
798800
if (sym->flags & SYMBOL_CHECKED)
@@ -816,13 +818,8 @@ struct symbol *sym_check_deps(struct symbol *sym)
816818
goto out;
817819
}
818820
out:
819-
if (sym2) {
820-
printf(" %s", sym->name);
821-
if (sym2 == sym) {
822-
printf("\n");
823-
sym2 = NULL;
824-
}
825-
}
821+
if (sym2)
822+
fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": "");
826823
sym->flags &= ~SYMBOL_CHECK;
827824
return sym2;
828825
}

‎scripts/kconfig/zconf.tab.c_shipped‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,9 +2132,11 @@ void conf_parse(const char *name)
21322132
}
21332133
menu_finalize(&rootmenu);
21342134
for_all_symbols(i, sym) {
2135-
sym_check_deps(sym);
2135+
if (sym_check_deps(sym))
2136+
zconfnerrs++;
21362137
}
2137-
2138+
if (zconfnerrs)
2139+
exit(1);
21382140
sym_set_change_count(1);
21392141
}
21402142

‎scripts/kconfig/zconf.y‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,11 @@ void conf_parse(const char *name)
501501
}
502502
menu_finalize(&rootmenu);
503503
for_all_symbols(i, sym) {
504-
sym_check_deps(sym);
504+
if (sym_check_deps(sym))
505+
zconfnerrs++;
505506
}
506-
507+
if (zconfnerrs)
508+
exit(1);
507509
sym_set_change_count(1);
508510
}
509511

0 commit comments

Comments
 (0)