From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] fix diagnostic source path from command line
Date: Sun, 2 Aug 2020 16:40:50 +0200 [thread overview]
Message-ID: <20200802144050.53191-1-luc.vanoostenryck@gmail.com> (raw)
Now, diagnostic messages are prepended with the source path.
But if the problem comes from a file included directly from
the command line like:
sparse -include some-buggy-file.c
the prepended message will be:
(null): note: in included file ...
because there isn't a source path yet.
So, initialize the source path to "command-line".
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.c | 2 ++
validation/preprocessor/bad-cmdline-include.c | 11 +++++++++++
2 files changed, 13 insertions(+)
create mode 100644 validation/preprocessor/bad-cmdline-include.c
diff --git a/lib.c b/lib.c
index 2b600fee26cc..4bc5cd028781 100644
--- a/lib.c
+++ b/lib.c
@@ -383,6 +383,8 @@ struct symbol_list *sparse_initialize(int argc, char **argv, struct string_list
char **args;
struct symbol_list *list;
+ base_filename = "command-line";
+
// Initialize symbol stream first, so that we can add defines etc
init_symbols();
diff --git a/validation/preprocessor/bad-cmdline-include.c b/validation/preprocessor/bad-cmdline-include.c
new file mode 100644
index 000000000000..e4ee03f450c4
--- /dev/null
+++ b/validation/preprocessor/bad-cmdline-include.c
@@ -0,0 +1,11 @@
+#error some random error
+
+/*
+ * check-name: bad-cmdline-include
+ * check-command: sparse -include $file
+ *
+ * check-error-start
+command-line: note: in included file (through builtin):
+preprocessor/bad-cmdline-include.c:1:2: error: some random error
+ * check-error-end
+ */
--
2.28.0
reply other threads:[~2020-08-02 14:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200802144050.53191-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@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;
as well as URLs for NNTP newsgroup(s).