mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] get_maintainer.pl: Fix inexact file pattern matching
@ 2026-11-01 18:36 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2026-11-01 18:36 UTC (permalink / raw)
  To: Andrew Morton; +Cc: LKML, Borislav Petkov

The intent of file pattern matches is to exactly specify a
file pattern with or without wildcard **, *, or ? expansion.

The pattern match code failed to include a trailing $ to
match the end of the pattern.

A pattern like:

F:	include/drm/drm

would match files like include/drm/drm_<foo>

Fix it and the self-test code too.

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/get_maintainer.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 16b80a700d4ac..48328c48f5341 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -768,6 +768,10 @@ sub self_test {
 	    if ((-d $value)) {
 		$value =~ s@([^/])$@$1/@;
 	    }
+	    if (substr($value, -1) ne "/") {
+		$value .= '$';
+	    }
+
 	    if (!grep(m@^$value@, @lsfiles)) {
 		print("$x->{file}:$x->{linenr}: warning: no file matches\t$x->{line}\n");
 	    }
@@ -1062,7 +1066,7 @@ sub file_match_pattern {
 	    return 1;
 	}
     } else {
-	if ($file =~ m@^$pattern@) {
+	if ($file =~ m@^$pattern$@) {
 	    my $s1 = ($file =~ tr@/@@);
 	    my $s2 = ($pattern =~ tr@/@@);
 	    if ($s1 == $s2 || $pattern =~ /\(\?:/) {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-01 18:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01 18:36 [PATCH] get_maintainer.pl: Fix inexact file pattern matching Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®