Re: checkpatch
From: Joe Perches
Date: Thu Dec 10 2020 - 08:41:25 EST
On Thu, 2020-12-10 at 09:34 +0000, David Laight wrote:
> From: Joe Perches
> > Sent: 10 December 2020 05:26
> >
> > On Wed, 2020-12-09 at 19:13 +0100, Thomas Gleixner wrote:
> > > Joe,
> >
> > Hi Thomas.
> >
> > > the below made it through my filters for some reason so I actually
> > > looked and immediately wondered why checkpatch.pl did not identify this
> > > as pure garbage.
> > >
> > > Original mail is here: lore.kernel.org/r/69cb540a-09d5-4956-b062-071ccded7090@xxxxxx
> > >
> > > Can you have a look please? Adding brackets in the middle of the code
> > > for absolutely no reason is wrong to begin with and then not indenting
> > > the enclosed code makes it even worse.
> >
> > Well, maybe something like this, but there are probably some
> > drawbacks with initializations.
>
> Isn't the other likely problem where an extra code block
> is being squeezed in after a case label without generating
> a double-indent.
Probably not.
A common form for a case label with a brace is like the below
where the code is indented. There aren't many uses where the
code for the case is at the same indent level as the case.
case foo:
{
definitions;
code;
break;
}
Another puts the break at the same indent as the case.
case foo:
{
definitions;
code;
}
break;
The other form that's used with case statements have the brace
on the line with the case:
case foo: {
definitions;
code;
break;
}
There are some uses where the open brace is on a separate
line like the below, but checkpatch already emits a message
like "open brace should be on the previous line" for it.
Now another message will be emitted for the open brace.
switch (foo)
{
case bar: