diff mbox series

[130/156] checkpatch: emit a warning on embedded filenames

Message ID 20201016024911.qdfDRaUsY%akpm@linux-foundation.org (mailing list archive)
State New
Headers show
Series [001/156] device-dax/kmem: fix resource release | expand

Commit Message

Andrew Morton Oct. 16, 2020, 2:49 a.m. UTC
From: Joe Perches <joe@perches.com>
Subject: checkpatch: emit a warning on embedded filenames

Embedding the complete filename path inside the file isn't particularly
useful as often the path is moved around and becomes incorrect.

Emit a warning when the source contains the filename.

[akpm@linux-foundation.org: remove stray " di"]
Link: https://lkml.kernel.org/r/1fd5f9188a14acdca703ca00301ee323de672a8d.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

 scripts/checkpatch.pl |    6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series


--- a/scripts/checkpatch.pl~checkpatch-emit-a-warning-on-embedded-filenames
+++ a/scripts/checkpatch.pl
@@ -3271,6 +3271,12 @@  sub process {
+# check for embedded filenames
+		if ($rawline =~ /^\+.*\Q$realfile\E/) {
+			     "It's generally not useful to have the filename in the file\n" . $herecurr);
+		}
 # check we are in a valid source file if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);