Commit 379a8eb8 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: detect recursive inclusion earlier

Currently, the recursive inclusion is not detected when the offending
file is about to be included; it is detected the offending file is
about to include the *next* file.  This is because the detection loop
does not involve the file being included.

Do this check against the file that is about to be included so that
the recursive inclusion is detected before unneeded parsing happens.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 32a94b8b
...@@ -325,23 +325,25 @@ void zconf_nextfile(const char *name) ...@@ -325,23 +325,25 @@ void zconf_nextfile(const char *name)
buf->parent = current_buf; buf->parent = current_buf;
current_buf = buf; current_buf = buf;
for (iter = current_file->parent; iter; iter = iter->parent ) { file->parent = current_file;
if (!strcmp(current_file->name,iter->name) ) {
for (iter = current_file; iter; iter = iter->parent) {
if (!strcmp(iter->name, file->name)) {
fprintf(stderr, fprintf(stderr,
"Recursive inclusion detected.\n" "Recursive inclusion detected.\n"
"Inclusion path:\n" "Inclusion path:\n"
" current file : %s\n", zconf_curname()); " current file : %s\n", file->name);
iter = current_file; iter = file;
do { do {
iter = iter->parent; iter = iter->parent;
fprintf(stderr, " included from: %s:%d\n", fprintf(stderr, " included from: %s:%d\n",
iter->name, iter->lineno - 1); iter->name, iter->lineno - 1);
} while (strcmp(iter->name, current_file->name)); } while (strcmp(iter->name, file->name));
exit(1); exit(1);
} }
} }
file->lineno = 1; file->lineno = 1;
file->parent = current_file;
current_file = file; current_file = file;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment