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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 15 Sep 2023 00:41:10 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Mitchell Levy <levymitchell0@...il.com>
Cc:     Geert Uytterhoeven <geert@...ux-m68k.org>,
        Bartosz Golaszewski <brgl@...ev.pl>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Andy Shevchenko <andy@...nel.org>
Subject: Re: guard coding style (was: Re: [PATCH v1 05/10] gpio: pca953x:
 Simplify code with cleanup helpers)

On Fri, Sep 15, 2023 at 12:26:39AM +0200, Peter Zijlstra wrote:
> On Thu, Sep 14, 2023 at 01:51:01PM -0700, Mitchell Levy wrote:
> 
> > The more I think on this issue, the more I go back and forth. If we
> > only had guard(...), the only way to approximate scoped guard would be
> > to either just do what the macro does (i.e., a dummy for loop that
> > only runs once) or use an anonymous scope, e.g.,
> > {
> >     guard(...);
> >     my_one_statement();
> > }
> > Since this is how I've previously used std::lock_guard in C++, this
> > pattern feels very familiar to me, and the scoped_guard feels almost
> > like syntax sugar for this. As such, I feel like including the braces
> > is most natural because, as Geert mentioned, it emphasizes the scope
> > that "should" (in my brain, at least) be there.
> 
> AFAIC the anonymous scope thing doesn't much happen in kernel coding
> style -- although I'm sure it's there, the code-base is simply too vast
> to not have it *somewhere*.

The kernel typical style would be:

	do {
		...
	} while (0)

to create a 'pointless' scope. Apparently this is also what I've done in
some conversions where a conditional lock was involved.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ