Re: [PATCH] refactor various if (x) FREE_AND_NULL(x) to just FREE_AND_NULL(x)
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Aug 17, 2018, 18:29 UTC
- Message-ID
- <CACsJy8DW6MP-a8u8KgB0ueO8d9eWmoZwF6c0Z5i+Psy980XcHg@mail.gmail.com>
- In-Reply-To
- <20180817173308.GA9111@sigill.intra.peff.net>
On Fri, Aug 17, 2018 at 7:33 PM Jeff King <peff@peff.net> wrote:
Show 22 quoted lines
> > On Fri, Aug 17, 2018 at 10:07:36AM -0700, Junio C Hamano wrote: > > > Junio C Hamano <gitster@pobox.com> writes: > > > > > It is a bit sad that > > > > > > - if (E) > > > FREE_AND_NULL(E); > > > > > > is not sufficient to catch it. Shouldn't we be doing the same for > > > regular free(E) as well? IOW, like the attached patch. > > > ... > > > > And revised even more to also spell "E" as "E != NULL" (and "!E" as > > "E == NULL"), which seems to make a difference, which is even more > > sad. I do not want to wonder if I have to also add "NULL == E" and > > other variants, so I'll stop here. > > I think it makes sense that these are all distinct if you're using > coccinelle to do stylistic transformations between them (e.g., enforcing > curly braces even around one-liners).
Googling a bit shows a kernel patch [1]. Assuming that it works (I didn't check if it made it to linux.git) it would simplify our rules a bit.
[1] https://patchwork.kernel.org/patch/5167641/
-- Duy