mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 1/3] checkpatch: add --drx option and drx_print() helper
Date: Sat, 25 Oct 2025 16:24:13 -0700	[thread overview]
Message-ID: <603e564ce2de6a66054760b01fd82d1eb0da9c66.camel@perches.com> (raw)
In-Reply-To: <20251025211519.1616439-2-jim.cromie@gmail.com>

On Sat, 2025-10-25 at 15:15 -0600, Jim Cromie wrote:
> checkpatch has ~235 heuristic s/$patt// statements which strip
> code-snippets that are "OK", leaving the remainder for further
> heuristics to apply further "cleanups".
> 
> Many of these have obvious purpose, but surely some are inscrutable.
> For those cases, add drx_print($reason) helper, which is designed to
> be called from a s/// or s///g statement (in the 'replacement' side),
> to "explain" what it is doing.
> 
> You can use it to instrument the code to "explain" itself, then
> validate that explanation by experiment and exersize:
> 
>   s/$patt/drx_print("why")/e;
>   s/$patt/drx_print("whys")/ge;
> 
> To activate the "debug" output, pass --drx or --drx=why to enable all
> (or just matching) cleanup heuristics to validate the "whys".
> 
> Here it is in action, on a patch which triggered enough noise that I
> wanted this visibility into what it was doing.
> 
> $ scripts/checkpatch.pl --strict --drx=builtins ../linux.git/pt-1
> drx_print: -builtins-
>   >> Matched (`$&`): <__builtin_constant_p(cls>
>   >> Capture 1 (`$1`): <__builtin_constant_p>

I'd prefer you extend the existing --debug KEY=[0|1] mechanism.

  reply	other threads:[~2025-10-25 23:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-25 21:15 [PATCH 0/3] checkpatch --strict | ci-pipeline improvements Jim Cromie
2025-10-25 21:15 ` [PATCH 1/3] checkpatch: add --drx option and drx_print() helper Jim Cromie
2025-10-25 23:24   ` Joe Perches [this message]
2025-10-25 21:15 ` [PATCH 2/3] checkpatch: recognize __chkp_no_side_effects(_var) hint macro Jim Cromie
2025-10-26 16:48   ` Joe Perches
2025-10-25 21:15 ` [PATCH 3/3] compiler.h: add __chkp_no_side_effects() empty hint/assertion macro Jim Cromie
2025-10-26  0:09   ` Linus Torvalds

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=603e564ce2de6a66054760b01fd82d1eb0da9c66.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®