Re: [PATCH 01/23] contrib/coccinnelle: add equals-null.cocci
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 30, 2022, 20:56 UTC
- Message-ID
- <xmqqpmky70jb.fsf@gitster.g>
- In-Reply-To
- <6e8cd958-b749-0a55-d8ae-ff249f06bd2f@iee.email>
Philip Oakley <philipoakley@iee.email> writes:
Show 14 quoted lines
> On 30/04/2022 05:13, Elia Pinto wrote: >> Add a coccinelle semantic patch necessary to reinforce the git coding style >> guideline: >> >> "Do not explicitly compute an integral value with constant 0 or '\ 0', or a > > s/compute/compare/ >> pointer value with constant NULL." > > If this gets re-rolled, perhaps include a simple example for those who > don't immediately understand that quoted sentence. It will also help > decode the coccinelle script > > so: `if (ptr == NULL)` becomes `if (!ptr)` etc.
That is certainly a good suggestion, but I am wondering if we want to also emphasize another more generally applicable rule that appears much earlier in the guideline document:
- Fixing style violations while working on a real change as a preparatory clean-up step is good, but otherwise avoid useless code churn for the sake of conforming to the style.
"Once it _is_ in the tree, it's not really worth the patch noise to go and fix it up." Cf. http://lkml.iu.edu/hypermail/linux/kernel/1001.3/01069.html