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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 29 Nov 2017 09:20:13 +0100
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Joe Perches <joe@...ches.com>
Cc:     "Gustavo A. R. Silva" <garsilva@...eddedor.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Alan Cox <gnomes@...rguk.ukuu.org.uk>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        "the arch/x86 maintainers" <x86@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs

Hi Joe,

On Wed, Nov 29, 2017 at 2:07 AM, Joe Perches <joe@...ches.com> wrote:
> On Tue, 2017-11-28 at 14:37 -0600, Gustavo A. R. Silva wrote:
>> Quoting Linus Torvalds <torvalds@...ux-foundation.org>:
>> > On Tue, Nov 28, 2017 at 11:00 AM, Alan Cox
>> > <gnomes@...rguk.ukuu.org.uk> wrote:
>> > > The notation in question has been standard in tools like lint since the
>> > > end of the 1970s
>> >
>> > Yes.
>> >
>> > That said, maybe one option would be to annotate the "case:" and
>> > "default:" statements if that makes people happier.
>> >
>> > IOW, we could do something like
>> >
>> >     #define fallthrough __atttibute__((fallthrough))
>> >
>> > and then write
>> >
>> >     fallthrough case 1:
>> >         ...
>> >
>> > which while absolutely not traditional, might look and read a bit more
>> > logical to people. I mean, it literally _is_ a "fallthrough case", so
>> > it makes semantic sense.
>> >
>>
>> This is elegant. The thing is that this makes it appear as if there is
>> an unconditional fall through.
>>
>> It is not uncommon to have multiple break statements in the same case
>> block and to fall through also.
>
> My preferred syntax would be to use __fallthrough or fallthrough
> in the same manner as break;
>
>         switch (foo) {
>         case bar:
>                 bar();
>                 fallthrough;
>         case baz:
>                 baz();
>                 break;
>         default;
>                 qux();
>                 exit(1);
>         }

Makes sense to me.

Comments are fragile.
In addition, they are stripped if you run cpp (or gcc -E) separately, unlike
__atttibute__((fallthrough)).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ