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]
Message-ID: <20230914222639.GB5492@noisy.programming.kicks-ass.net>
Date:   Fri, 15 Sep 2023 00:26:39 +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 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*.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ