checkpatch: improve EMBEDDED_FILENAME test
authorJoe Perches <joe@perches.com>
Tue, 24 Jan 2023 23:16:55 +0000 (15:16 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 3 Feb 2023 06:50:07 +0000 (22:50 -0800)
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.

Link: https://lkml.kernel.org/r/36069dac5d07509dab1c7f1238f8cbb08db80ac6.camel@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
scripts/checkpatch.pl

index a2fc7d556126728127a8a43699b02007557f2054..bd44d12965c98e99042938880a17730c6dfac5c9 100755 (executable)
@@ -3751,7 +3751,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);
                }