Skip to content

Commit 5ae6fcc

Browse files
committed
kconfig: fix line number in recursive inclusion error message
When recursive inclusion is detected, the line number of the last 'included from:' is wrong. [Test Case] Kconfig: -------->8-------- source "Kconfig2" -------->8-------- Kconfig2: -------->8-------- source "Kconfig3" -------->8-------- Kconfig3: -------->8-------- source "Kconfig" -------->8-------- [Result] $ make allyesconfig scripts/kconfig/conf --allyesconfig Kconfig Kconfig:1: recursive inclusion detected. Inclusion path: current file : 'Kconfig' included from: 'Kconfig3:1' included from: 'Kconfig2:1' included from: 'Kconfig:3' scripts/kconfig/Makefile:89: recipe for target 'allyesconfig' failed make[1]: *** [allyesconfig] Error 1 Makefile:512: recipe for target 'allyesconfig' failed make: *** [allyesconfig] Error 2 where we expect current file : 'Kconfig' included from: 'Kconfig3:1' included from: 'Kconfig2:1' included from: 'Kconfig:1' The 'iter->lineno+1' in the second fpinrtf() should be 'iter->lineno-1'. I refactored the code to merge the two fprintf() calls. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Ulf Magnusson <[email protected]>
1 parent a11761c commit 5ae6fcc

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

scripts/kconfig/zconf.l

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,12 @@ void zconf_nextfile(const char *name)
332332
"Inclusion path:\n current file : '%s'\n",
333333
zconf_curname(), zconf_lineno(),
334334
zconf_curname());
335-
iter = current_file->parent;
336-
while (iter && \
337-
strcmp(iter->name,current_file->name)) {
338-
fprintf(stderr, " included from: '%s:%d'\n",
339-
iter->name, iter->lineno-1);
335+
iter = current_file;
336+
do {
340337
iter = iter->parent;
341-
}
342-
if (iter)
343338
fprintf(stderr, " included from: '%s:%d'\n",
344-
iter->name, iter->lineno+1);
339+
iter->name, iter->lineno - 1);
340+
} while (strcmp(iter->name, current_file->name));
345341
exit(1);
346342
}
347343
}

0 commit comments

Comments
 (0)