From: Joe Perches <joe@perches.com>
To: Jim Cromie <jim.cromie@gmail.com>, linux-kernel@vger.kernel.org
Cc: akpm@linuxfoundation.org, Andy Whitcroft <apw@canonical.com>,
Dwaipayan Ray <dwaipayanray1@gmail.com>,
Lukas Bulwahn <lukas.bulwahn@gmail.com>
Subject: Re: [PATCH v2 2/2] checkpatch: 3 use-cases for --debug rx=1 option
Date: Sun, 26 Oct 2025 16:40:44 -0700 [thread overview]
Message-ID: <5114af1db16a396b65b798029b83d7b8a2c3aff5.camel@perches.com> (raw)
In-Reply-To: <20251026202142.1622060-3-jim.cromie@gmail.com>
On Sun, 2025-10-26 at 14:21 -0600, Jim Cromie wrote:
> Use the drx_print() helper in 3 cases inside code which counts macro
> arg expansions.
[]
> diff --git 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;
stray trailing ; in the replacement ?
> + $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 }
This might be easier to read using a qr but I'm not sure the
embedded capture groups and their use in drx_print is sensible
as it doesn't seem extensible.
our $stmt_stripper = qr{\b(
__must_be_array |
offsetof | typeof | __typeof__ |
sizeof | sizeof_field |
__builtin\w+
typecheck\s*\(\s*$Type\s*,|\#+)\s*\(*\s*$arg\s*\)\(*\s*$arg\s*\)*
> + {
> + drx_print("-arg-inspections-");
> + }xge;
> +
> my $use_cnt = () = $tmp_stmt =~ /\b$arg\b/g;
> if ($use_cnt > 1) {
> CHK("MACRO_ARG_REUSE",
Back with I suggested this a dozen years ago I thought it was overkill.
Maybe it is and the whole test should be offed.
https://lore.kernel.org/lkml/1352198139.16194.21.camel@joe-AO722/
next prev parent reply other threads:[~2025-10-26 23:40 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 ` [PATCH v2 2/2] checkpatch: 3 use-cases for --debug rx=1 option Jim Cromie
2025-10-26 23:40 ` Joe Perches [this message]
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=5114af1db16a396b65b798029b83d7b8a2c3aff5.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linuxfoundation.org \
--cc=apw@canonical.com \
--cc=dwaipayanray1@gmail.com \
--cc=jim.cromie@gmail.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®