lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 22 Feb 2024 14:30:03 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>, 
	Linus Walleij <linus.walleij@...aro.org>, linux-gpio@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 1/1] gpiolib: Deduplicate cleanup for-loop in gpiochip_add_data_with_key()

On Thu, Feb 22, 2024 at 2:28 PM Andy Shevchenko
<andriy.shevchenko@...ux.intel.com> wrote:
>
> On Thu, Feb 22, 2024 at 10:48:00AM +0100, Bartosz Golaszewski wrote:
> > On Wed, Feb 21, 2024 at 8:36 PM Andy Shevchenko
> > <andriy.shevchenko@...ux.intel.com> wrote:
> > >
> > > There is no need to repeat for-loop twice in the error path in
> > > gpiochip_add_data_with_key(). Deduplicate it. While at it,
> > > rename loop variable to be more specific and avoid ambguity.
> > >
> > > It also properly unwinds the SRCU, i.e. in reversed order of allocating.
>
> ...
>
> > This doesn't apply on top of gpio/for-next, I think it depends on one
> > of your earlier patches?
>
> Yes, on the fix with error path.
>
> ...
>
> > > +       while (desc_index--)
> >
> > What about gdev->descs[0]?
>
> What about it? :-)
>
> for (i = i - 1; i >= 0; i--)
> while (--i >= 0)
> while (i--)
>
> are all equivalents.
>
> The difference is what the value will i get _after_ the loop.

Ugh of course. But the first one is more readable given I got tricked
by variant #3 at a quick glance but the for loop says out loud what it
does.

Bart

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ