lkml.org 
[lkml]   [2017]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] x86/syscalls: Mark expected switch fall-throughs
From
Date
On Tue, 2017-11-28 at 14:37 -0600, Gustavo A. R. Silva wrote:
> Quoting Linus Torvalds <torvalds@linux-foundation.org>:
>
> > On Tue, Nov 28, 2017 at 11:00 AM, Alan Cox
> > <gnomes@lxorguk.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);
}

\
 
 \ /
  Last update: 2017-11-29 02:08    [W:0.116 / U:0.924 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site