[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <603e564ce2de6a66054760b01fd82d1eb0da9c66.camel@perches.com>
Date: Sat, 25 Oct 2025 16:24:13 -0700
From: Joe Perches <joe@...ches.com>
To: Jim Cromie <jim.cromie@...il.com>, linux-kernel@...r.kernel.org
Cc: akpm@...uxfoundation.org, Andy Whitcroft <apw@...onical.com>, Dwaipayan
Ray <dwaipayanray1@...il.com>, Lukas Bulwahn <lukas.bulwahn@...il.com>
Subject: Re: [PATCH 1/3] checkpatch: add --drx option and drx_print() helper
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.
Powered by blists - more mailing lists