checkpatch: Improve EMBEDDED_FILENAME test

Message ID 36069dac5d07509dab1c7f1238f8cbb08db80ac6.camel@perches.com
State New
Headers
Series checkpatch: Improve EMBEDDED_FILENAME test |

Commit Message

Joe Perches Jan. 24, 2023, 11:16 p.m. UTC
  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@redhat.com>
Signed-off-by: Joe Perches <joe@perches.com>
---

Heinz, next time please make sure to CC linux-kernel@vger.kernel.org

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

Patch

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);
 		}