Re: [PATCH v3 09/10] gpiolib: use gpiochip_dup_line_label() in for_each helpers

From: Bartosz Golaszewski
Date: Mon Dec 04 2023 - 08:40:44 EST


On Mon, Dec 4, 2023 at 2:24 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> On Mon, Dec 04, 2023 at 10:35:08AM +0100, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
> >
> > Rework for_each_requested_gpio_in_range() to use the new helper to
> > retrieve a dynamically allocated copy of the descriptor label and free
> > it at the end of each iteration. We need to leverage the CLASS()'
> > destructor to make sure that the label is freed even when breaking out
> > of the loop.
>
> ...
>
> > - if ((label = gpiochip_is_requested(chip, base + i)) == NULL) {} else
>
> I see, but...
>
> > + if ((*_data.label = \
> > + gpiochip_dup_line_label(_chip, _base + *_data.i)) == NULL) {} \
>
> ...can we drop this NULL check by using !(...) notation?
>

I'd rather not. this is already quite hard to understand and a single
`!` is less readable than `== NULL`.

Bart

>
> --
> With Best Regards,
> Andy Shevchenko
>
>