mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dwaipayan Ray <dwaipayanray1@gmail.com>
To: joe@perches.com
Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com,
	Dwaipayan Ray <dwaipayanray1@gmail.com>
Subject: [PATCH] checkpatch: Fix check for embedded filename
Date: Sat,  5 Jun 2021 21:42:19 +0530	[thread overview]
Message-ID: <20210605161219.26421-1-dwaipayanray1@gmail.com> (raw)

When checkpatch is run on file contents piped through stdin,
it may generate false EMBEDDED_FILENAME warnings if the
--file flag is used.

Consider the following test file:
$cat test.c
int x = a - b;

$cat test.c | ./scripts/checkpatch.pl -f
WARNING: It's generally not useful to have the filename in the file
+int x = a - b;

So any instance of "-" in the file contents will trigger
an EMBEDDED_FILENAME warning.

Fix it by checking if $realfile is not "-".

Signed-off-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3e1795311c87..2f50fafa0ac1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3619,7 +3619,7 @@ sub process {
 		}
 
 # check for embedded filenames
-		if ($rawline =~ /^\+.*\Q$realfile\E/) {
+		if ($realfile ne "-" && $rawline =~ /^\+.*\Q$realfile\E/) {
 			WARN("EMBEDDED_FILENAME",
 			     "It's generally not useful to have the filename in the file\n" . $herecurr);
 		}
-- 
2.28.0


             reply	other threads:[~2021-06-05 16:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05 16:12 Dwaipayan Ray [this message]
2021-06-05 17:21 ` Joe Perches
2021-06-05 17:33   ` Dwaipayan Ray
2021-06-05 18:33     ` Joe Perches
2021-06-05 18:44       ` Dwaipayan Ray
2021-06-05 18:52         ` Joe Perches

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=20210605161219.26421-1-dwaipayanray1@gmail.com \
    --to=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /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

all inboxes | Powered by JetHome®