From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796165650; b=C0C8BT0zxTeFQ9tnUnPPjqSZMs0z1GaX792+1yBL2A5KzN5GdHc+0RX9gasCQ9N4Leb8 WXJOgCTytkXEegg5+gUr8qidT1XeBWvoNNfbHOtbsz99oKuYnJ93YXFhWnuCRtqxpCAQa 9MO8gwgHBoXNdN+0LVK5U5ymQixpFrVn90jU4xBAzWazraSIiCaDySk4Cz/5eOmGE84zV nnAigH1+VKSlJxcpYm/sOSV6JH9Ej7ZzQmMxgZRS4R2ZqCMvc0ldq6s+MTC9PuPb/2485 DTxqKCRYt/MHu3Zou/h40Avcc86q1+ug5wbYQgHAHzDs3raMCWlIOfkZ9xKswYIXQaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796165650; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; bh=DaCv5lBzWOTb/TohHJZSCQp+iKc6XxRPx5kMt7C93Wg=; b=dXzWn2xH4gC0rtOTXHjCq2Sg+1tcPdn1YzSepsgB3i8B7D68BJBU/SlFkkZPmuycDGlI ZcuUBRFceP8hw1vbsTWZ7NKA5oCbcl8XicsAuioT5B/Q1+Njala/FjA9vmQTciaQvzssy bjIx2Onvi9kU1NdXqMM8xHl54jXyarnkyGWMPYajSTTTnS5ruc8t5YGQ0X0uOOCZD8uze lIGxvaxo2CI83QjPuXsdgxEmO63lleP9myVn+SfZ/vaTJUkum0OsNcepdiuqQHRFFGecx sVrbhte2ez+WBOqAGS8sRImXjqRsy0TnnVB1G26TuyAWHEsyFklvXvBqCn+XNlchZjg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=IealgRiM; arc=none smtp.remote-ip=199.89.1.14 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 847D7606A692 for ; Tue, 1 Dec 2026 22:54:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 847D7606A692 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=IealgRiM Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4jfGR61GzKz1XMYJb; Tue, 1 Dec 2026 22:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=mr01; t=1796165645; x=1798757646; bh=DaCv5 lBzWOTb/TohHJZSCQp+iKc6XxRPx5kMt7C93Wg=; b=IealgRiMvnIsHmnD6BpTZ O0SL2f6TC/1rHMEKzVNmHEFi9gyeBbIrByCUV5aZ4k0GmLHJ/p4ZVg/oK03NXiP7 ovfdN0fqofwqTETeeHKIxeT6z9dXAay7jibuxi5/QV9Qz6UI9HpGeWOwhuYflu8u 5hRgiQP7lv93HgFDUxcTAeWUxonstzeMSZHJY3tMITq2VjxUPYTIS7Z7NWyVLbxf HiyLon9Hd9VS+q2aVBicQKhCDo5yDRutTCD78Yv835sPAsqjzpLa+dppqcGFCSQI TPZs0siBgEF/swyL7fKbnm1QPounYTXW2XSWJmWfNQRzmSnZY6hlmZc4Jst3BR/Z A== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id lYo_0WoJzo8R; Tue, 1 Dec 2026 22:54:05 +0000 (UTC) Received: from bvanassche.c.googlers.com.com (57.237.82.34.bc.googleusercontent.com [34.82.237.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4jfGQy52mTz1XMYJP; Tue, 1 Dec 2026 22:54:02 +0000 (UTC) From: Bart Van Assche To: Joe Perches , Andy Whitcroft Cc: Andrew Morton , linux-kernel@vger.kernel.org, Bart Van Assche Subject: [PATCH 01/10] checkpatch: pre-filter obsolete MAINTAINERS checks and gate on OBSOLETE Date: Tue, 1 Dec 2026 14:53:45 -0800 Message-ID: <059159036efcda969eb16477ae36266b4feab5ce.1796165270.git.bvanassche@acm.org> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Pre-filter candidate paths in is_maintained_obsolete() by scanning MAINTAINERS once via load_obsolete_candidates() for sections whose S: lin= e matches obsolete, and gate the call site in process() on show_type("OBSOLETE"). Avoid spawning perl scripts/get_maintainer.pl (~210 ms per unique file) for paths that cannot match any obsolete F: or N: entry and when OBSOLETE warnings are suppressed via --ignore or --types. Fall back to invoking scripts/get_maintainer.pl whenever MAINTAINERS is not a regular file, a .get_maintainer.conf file is present, an obsolete section contains K: or bracket/brace globs, or an N: regex fails to compile. Signed-off-by: Bart Van Assche --- scripts/checkpatch.pl | 144 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b8b64f720191..543fd002ee29 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -11,7 +11,8 @@ use strict; use warnings; use POSIX; use File::Basename; -use Cwd 'abs_path'; +use Cwd qw(abs_path fastgetcwd); +use File::Spec::Functions qw(canonpath); use Term::ANSIColor qw(:constants); use Encode qw(decode encode); =20 @@ -1170,6 +1171,121 @@ sub seed_camelcase_file { } =20 our %maintained_status =3D (); +my $obsolete_candidates_loaded =3D 0; +my $obsolete_candidates_fallback =3D 0; +my @obsolete_candidates =3D (); + +sub flush_obsolete_section { + my ($header, $is_obsolete, $has_r, $r_obsolete, $has_k, $fn_ref) =3D @_= ; + + return 1 if (!$is_obsolete && !($has_r && ($r_obsolete || $header =3D~ = /obsolete/i))); + return 0 if ($has_k); + + foreach my $entry (@$fn_ref) { + my ($tag, $pat) =3D @$entry; + return 0 if ($pat eq ''); + if ($tag eq 'N') { + return 0 if ($pat =3D~ /[^\x00-\x7f]/); + local $@; + my $nre =3D eval { no warnings 'regexp'; qr{$pat}x }; + return 0 if ($@); + push(@obsolete_candidates, $nre); + } else { + return 0 if ($pat =3D~ /[\[\{\(\)\|\+\\\^\$\x00]/ || + $pat =3D~ /[^\x00-\x7f]/); + my $re =3D quotemeta($pat); + $re =3D~ s/\\\*/.*/g; + $re =3D~ s/\\\?/./g; + push(@obsolete_candidates, qr{^$re}); + } + } + return 1; +} + +sub load_obsolete_candidates { + return if ($obsolete_candidates_loaded); + $obsolete_candidates_loaded =3D 1; + + my $cwd =3D abs_path('.'); + my $root_abs =3D abs_path($root); + my $home =3D defined($ENV{HOME}) ? $ENV{HOME} : ""; + my $has_conf =3D grep { -e "$_/.get_maintainer.conf" } + split(/:/, ".:$home:.scripts"); + if (!defined($cwd) || !defined($root_abs) || $cwd ne $root_abs || + $root =3D~ /obsolete/i || + !(-f "MAINTAINERS") || + $has_conf) { + $obsolete_candidates_fallback =3D 1; + return; + } + + if (-f ".mailmap") { + open(my $mm, '<', ".mailmap") or do { + $obsolete_candidates_fallback =3D 1; + return; + }; + while (my $line =3D <$mm>) { + $line =3D~ s/#.*$//; + if ($line =3D~ /obsolete/i) { + $obsolete_candidates_fallback =3D 1; + close($mm); + return; + } + } + close($mm); + } + + # Decode as UTF-8 like get_maintainer.pl does such that \s matches + # the same (Unicode) whitespace characters. + open(my $maint, '<:encoding(UTF-8)', "MAINTAINERS") or do { + $obsolete_candidates_fallback =3D 1; + return; + }; + + my $header =3D ''; + my $is_obsolete =3D 0; + my $has_r =3D 0; + my $r_obsolete =3D 0; + my $has_k =3D 0; + my @fn =3D (); + + no warnings 'utf8'; + while (my $line =3D <$maint>) { + chomp $line; + if ($line =3D~ /^([A-Z]):\s*(.*)/) { + my ($tag, $val) =3D ($1, $2); + if ($tag eq 'S') { + $is_obsolete =3D 1 if ($val =3D~ /obsolete/i); + } elsif ($tag eq 'R') { + $has_r =3D 1; + $r_obsolete =3D 1 if ($val =3D~ /obsolete/i); + } elsif ($tag eq 'K') { + $has_k =3D 1; + } elsif ($tag eq 'F' || $tag eq 'N') { + push(@fn, [$tag, $val]); + } + } elsif ($line !~ /^\s*$/ && $line !~ /^\s*\#/) { + if (!flush_obsolete_section($header, $is_obsolete, $has_r, + $r_obsolete, $has_k, \@fn)) { + $obsolete_candidates_fallback =3D 1; + close($maint); + return; + } + $header =3D $line; + $is_obsolete =3D 0; + $has_r =3D 0; + $r_obsolete =3D 0; + $has_k =3D 0; + @fn =3D (); + } + } + close($maint); + + if (!flush_obsolete_section($header, $is_obsolete, $has_r, + $r_obsolete, $has_k, \@fn)) { + $obsolete_candidates_fallback =3D 1; + } +} =20 sub is_maintained_obsolete { my ($filename) =3D @_; @@ -1177,6 +1293,30 @@ sub is_maintained_obsolete { return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl")); =20 if (!exists($maintained_status{$filename})) { + load_obsolete_candidates(); + if (!$obsolete_candidates_fallback && + $filename =3D~ m{^[A-Za-z0-9_/.+,:\@=3D%][A-Za-z0-9_/.+,:\-\@=3D%]= *\z} && + $filename !~ /obsolete/i) { + my $norm =3D canonpath($filename); + if ($norm !~ m@(?:^|/)\.\.(?:/|$)@ && + $norm !~ /\.yaml$/i) { + $norm .=3D '/' if (-d $norm && $norm !~ m@/$@); + my $cur_path =3D fastgetcwd() . '/'; + $norm =3D~ s/^\Q$cur_path\E//; + $norm =3D~ s@^\./@@; + my $matched =3D 0; + foreach my $re (@obsolete_candidates) { + if ($norm =3D~ $re) { + $matched =3D 1; + last; + } + } + if (!$matched) { + $maintained_status{$filename} =3D ""; + return 0; + } + } + } $maintained_status{$filename} =3D `perl $root/scripts/get_maintainer.p= l --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`; } =20 @@ -2945,7 +3085,7 @@ sub process { } =20 if ($found_file) { - if (is_maintained_obsolete($realfile)) { + if (show_type("OBSOLETE") && is_maintained_obsolete($realfile)) { WARN("OBSOLETE", "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy= . No unnecessary modifications please.\n"); }