From: Jim Cromie <jim.cromie@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linuxfoundation.org, Jim Cromie <jim.cromie@gmail.com>,
Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: [PATCH v2 2/2] checkpatch: 3 use-cases for --debug rx=1 option
Date: Sun, 26 Oct 2025 14:21:41 -0600 [thread overview]
Message-ID: <20251026202142.1622060-3-jim.cromie@gmail.com> (raw)
In-Reply-To: <20251026202142.1622060-1-jim.cromie@gmail.com>
Use the drx_print() helper in 3 cases inside code which counts macro
arg expansions.
$ scripts/checkpatch.pl --strict patch-1 --debug rx='##'
drx_print: 'arg ##' catenations
>> Matched (`$&`): <_id##>
drx_print: 'arg ##' catenations
>> Matched (`$&`): <_id##>
drx_print: '#|## arg' catenations
>> Matched (`$&`): <##_model>
drx_print: '#|## arg' catenations
>> Matched (`$&`): <##_model>
$ scripts/checkpatch.pl --strict patch-1 --debug rx='insp'
drx_print: -arg-inspections-
>> Matched (`$&`): <__builtin_constant_p(cls>
>> Capture 1 (`$1`): <__builtin_constant_p>
NB: see also the extended --debug key=1 facility:
$ scripts/checkpatch.pl --strict ../linux.git/pt-1 --debug foo=1
Unknown debug key 'foo', expecting: 'values possible type attr rx'
NB: I moved the 2 #|## strippers above the more complex macro, because
the latter caught one ## case that it needn't have.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
scripts/checkpatch.pl | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c174e3bef2b2..240ddab17d89 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6078,9 +6078,17 @@ sub process {
next if ($arg =~ /\.\.\./);
next if ($arg =~ /^type$/i);
my $tmp_stmt = $define_stmt;
- $tmp_stmt =~ s/\b(__must_be_array|offsetof|sizeof|sizeof_field|__stringify|typeof|__typeof__|__builtin\w+|typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b//g;
- $tmp_stmt =~ s/\#+\s*$arg\b//g;
- $tmp_stmt =~ s/\b$arg\s*\#\#//g;
+
+ $tmp_stmt =~ s/\#+\s*$arg\b/drx_print("'#|## arg' catenations")/ge;
+ $tmp_stmt =~ s/\b$arg\s*\#\#/drx_print("'arg ##' catenations");/ge;
+ $tmp_stmt =~ s{
+ \b(__must_be_array|offsetof|sizeof|sizeof_field|
+ __stringify|typeof|__typeof__|__builtin\w+|
+ typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)*\b }
+ {
+ drx_print("-arg-inspections-");
+ }xge;
+
my $use_cnt = () = $tmp_stmt =~ /\b$arg\b/g;
if ($use_cnt > 1) {
CHK("MACRO_ARG_REUSE",
--
2.51.0
next prev parent reply other threads:[~2025-10-26 20:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 20:21 [PATCH v2 0/2] checkpatch --debug rx=1 facility Jim Cromie
2025-10-26 20:21 ` [PATCH v2 1/2] checkpatch: add --debug rx=1|foo option and drx_print() helper Jim Cromie
2025-10-26 20:21 ` Jim Cromie [this message]
2025-10-26 23:40 ` [PATCH v2 2/2] checkpatch: 3 use-cases for --debug rx=1 option Joe Perches
2025-10-29 19:20 ` jim.cromie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251026202142.1622060-3-jim.cromie@gmail.com \
--to=jim.cromie@gmail.com \
--cc=akpm@linuxfoundation.org \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®