Skip to content

Commit

Permalink
kconfig: fix line number in recursive inclusion error message
Browse files Browse the repository at this point in the history
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 <yamada.masahiro@socionext.com>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
  • Loading branch information
Masahiro Yamada committed Mar 2, 2018
1 parent a11761c commit 5ae6fcc
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions scripts/kconfig/zconf.l
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,12 @@ void zconf_nextfile(const char *name)
"Inclusion path:\n current file : '%s'\n",
zconf_curname(), zconf_lineno(),
zconf_curname());
iter = current_file->parent;
while (iter && \
strcmp(iter->name,current_file->name)) {
fprintf(stderr, " included from: '%s:%d'\n",
iter->name, iter->lineno-1);
iter = current_file;
do {
iter = iter->parent;
}
if (iter)
fprintf(stderr, " included from: '%s:%d'\n",
iter->name, iter->lineno+1);
iter->name, iter->lineno - 1);
} while (strcmp(iter->name, current_file->name));
exit(1);
}
}
Expand Down

0 comments on commit 5ae6fcc

Please sign in to comment.