From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: Masahiro Yamada <masahiroy@kernel.org>, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] kconfig: fix line number in recursive inclusion detection
Date: Sun, 7 Jan 2024 22:19:48 +0900 [thread overview]
Message-ID: <20240107131948.39752-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20240107131948.39752-1-masahiroy@kernel.org>
The error message shows a wrong line number if the 'source' directive
is wrapped to the following line.
[Test Code]
source \
"Kconfig"
This results in the following error message:
Recursive inclusion detected.
Inclusion path:
current file : Kconfig
included from: Kconfig:2
The correct message should be as follows:
Recursive inclusion detected.
Inclusion path:
current file : Kconfig
included from: Kconfig:1
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
scripts/kconfig/lexer.l | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index d75423ec4eae..b3aeb29695d7 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -33,6 +33,7 @@ static int text_size, text_asize;
struct buffer {
struct buffer *parent;
YY_BUFFER_STATE state;
+ int lineno;
};
static struct buffer *current_buf;
@@ -402,6 +403,7 @@ void zconf_nextfile(const char *name)
struct buffer *buf = xmalloc(sizeof(*buf));
buf->state = YY_CURRENT_BUFFER;
+ buf->lineno = yylineno;
buf->parent = current_buf;
current_buf = buf;
yyin = zconf_fopen(file->name);
@@ -412,7 +414,7 @@ void zconf_nextfile(const char *name)
}
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
- current_file->lineno = yylineno;
+ current_file->lineno = zconf_lineno();
file->parent = current_file;
for (iter = current_file; iter; iter = iter->parent) {
@@ -425,7 +427,7 @@ void zconf_nextfile(const char *name)
do {
iter = iter->parent;
fprintf(stderr, " included from: %s:%d\n",
- iter->name, iter->lineno - 1);
+ iter->name, iter->lineno);
} while (strcmp(iter->name, file->name));
exit(1);
}
@@ -440,8 +442,6 @@ static void zconf_endfile(void)
struct buffer *tmp;
current_file = current_file->parent;
- if (current_file)
- yylineno = current_file->lineno;
if (!current_buf)
return;
@@ -449,6 +449,7 @@ static void zconf_endfile(void)
fclose(yyin);
yy_delete_buffer(YY_CURRENT_BUFFER);
yy_switch_to_buffer(current_buf->state);
+ yylineno = current_buf->lineno;
tmp = current_buf;
current_buf = current_buf->parent;
free(tmp);
--
2.40.1
prev parent reply other threads:[~2024-01-07 13:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-07 13:19 [PATCH 1/2] kconfig: remove unneeded buffer allocation in zconf_initscan() Masahiro Yamada
2024-01-07 13:19 ` Masahiro Yamada [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240107131948.39752-2-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox