[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190801105051.GA11487@hmswarspite.think-freely.org>
Date: Thu, 1 Aug 2019 06:50:51 -0400
From: Neil Horman <nhorman@...driver.com>
To: Joe Perches <joe@...ches.com>
Cc: Vlad Yasevich <vyasevich@...il.com>,
Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
"David S. Miller" <davem@...emloft.net>,
linux-sctp@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: sctp: Rename fallthrough label to unhandled
On Wed, Jul 31, 2019 at 03:23:46PM -0700, Joe Perches wrote:
> On Wed, 2019-07-31 at 16:58 -0400, Neil Horman wrote:
> > On Wed, Jul 31, 2019 at 09:35:31AM -0700, Joe Perches wrote:
> > > On Wed, 2019-07-31 at 08:16 -0400, Neil Horman wrote:
> > > > On Wed, Jul 31, 2019 at 04:32:43AM -0700, Joe Perches wrote:
> > > > > On Wed, 2019-07-31 at 07:19 -0400, Neil Horman wrote:
> > > > > > On Tue, Jul 30, 2019 at 10:04:37PM -0700, Joe Perches wrote:
> > > > > > > fallthrough may become a pseudo reserved keyword so this only use of
> > > > > > > fallthrough is better renamed to allow it.
> > > > > > >
> > > > > > > Signed-off-by: Joe Perches <joe@...ches.com>
> > > > > > Are you referring to the __attribute__((fallthrough)) statement that gcc
> > > > > > supports? If so the compiler should by all rights be able to differentiate
> > > > > > between a null statement attribute and a explicit goto and label without the
> > > > > > need for renaming here. Or are you referring to something else?
> > > > >
> > > > > Hi.
> > > > >
> > > > > I sent after this a patch that adds
> > > > >
> > > > > # define fallthrough __attribute__((__fallthrough__))
> > > > >
> > > > > https://lore.kernel.org/patchwork/patch/1108577/
> > > > >
> > > > > So this rename is a prerequisite to adding this #define.
> > > > >
> > > > why not just define __fallthrough instead, like we do for all the other
> > > > attributes we alias (i.e. __read_mostly, __protected_by, __unused, __exception,
> > > > etc)
> > >
> > > Because it's not as intelligible when used as a statement.
> > I think thats somewhat debatable. __fallthrough to me looks like an internal
> > macro, whereas fallthrough looks like a comment someone forgot to /* */
>
>
> I'd rather see:
>
> switch (foo) {
> case FOO:
> bar |= baz;
> fallthrough;
> case BAR:
> bar |= qux;
> break;
> default:
> error();
> }
>
> than
>
> switch (foo) {
> case FOO:
> bar |= baz;
> __fallthrough;
> case BAR:
> bar |= qux;
> break;
> default:
> error();
> }
>
> or esoecially
>
> switch (foo) {
> case FOO:
> bar |= baz;
> /* fallthrough
> */;
> case BAR:
> bar |= qux;
> break;
> default:
> error();
> }
>
> but <shrug>, bikeshed ahoy!...
You can say that if you want, but you made the point that your think the macro
as you have written is more readable. You example illustrates though that /*
fallthrough */ is a pretty common comment, and not prefixing it makes it look
like someone didn't add a comment that they meant to. The __ prefix is standard
practice for defining macros to attributes (212 instances of it by my count). I
don't mind rewriting the goto labels at all, but I think consistency is
valuable.
Neil
>
>
>
Powered by blists - more mailing lists