[PATCH] checkpatch: Improve EMBEDDED_FILENAME test

Joe Perches posted 1 patch 2 years, 7 months ago
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] checkpatch: Improve EMBEDDED_FILENAME test
Posted by Joe Perches 2 years, 7 months ago
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(-)

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