[PATCH] checkpatch: Improve EMBEDDED_FILENAME test

From: Joe Perches
Date: Tue Jan 24 2023 - 18:17:08 EST


Privately, Heinz Mauelshagen showed that the embedded filename test
is not specific enough.

> WARNING: It's generally not useful to have the filename in the file
> #113: FILE: errors.c:113:
> + block < registered_errors.blocks + registered_errors.count;

Extend the test to use the appropriate word boundary tests.

Reported-by: Heinz Mauelshagen <heinzm@xxxxxxxxxx>
Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---

Heinz, next time please make sure to CC linux-kernel@xxxxxxxxxxxxxxx

scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a6d6d7e1d0cf1..40102bc0ce535 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3727,7 +3727,7 @@ sub process {
}

# check for embedded filenames
- if ($rawline =~ /^\+.*\Q$realfile\E/) {
+ if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) {
WARN("EMBEDDED_FILENAME",
"It's generally not useful to have the filename in the file\n" . $herecurr);
}