public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: David Laight <David.Laight@ACULAB.COM>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: checkpatch
Date: Thu, 10 Dec 2020 05:40:35 -0800	[thread overview]
Message-ID: <8ee5b1f0eaec9c71066027e4e130d473fe6532d7.camel@perches.com> (raw)
In-Reply-To: <32a8677e1bcf4d69ba019bfcefc9ea59@AcuMS.aculab.com>

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@web.de
> > > 
> > > 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:




      reply	other threads:[~2020-12-10 13:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87zh2mzw3h.fsf@nanos.tec.linutronix.de>
2020-12-10  5:25 ` checkpatch Joe Perches
2020-12-10  9:34   ` checkpatch David Laight
2020-12-10 13:40     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ee5b1f0eaec9c71066027e4e130d473fe6532d7.camel@perches.com \
    --to=joe@perches.com \
    --cc=David.Laight@ACULAB.COM \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox