Skip to content

Commit a0154cd

Browse files
JoePerchestorvalds
authored andcommitted
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. [[email protected]: remove stray " di"] Signed-off-by: Joe Perches <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent e7f929f commit a0154cd

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scripts/checkpatch.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,12 @@ sub process {
32713271
}
32723272
}
32733273

3274+
# check for embedded filenames
3275+
if ($rawline =~ /^\+.*\Q$realfile\E/) {
3276+
WARN("EMBEDDED_FILENAME",
3277+
"It's generally not useful to have the filename in the file\n" . $herecurr);
3278+
}
3279+
32743280
# check we are in a valid source file if not then ignore this hunk
32753281
next if ($realfile !~ /\.(h|c|s|S|sh|dtsi|dts)$/);
32763282

0 commit comments

Comments
 (0)