mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andy Whitcroft <apw@shadowen.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Julian Andres Klode <jak@jak-linux.org>,
	devel@driverdev.osuosl.org, Greg Kroah-Hartman <gregkh@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] checkpatch: Add warning for asymmetric brace use
Date: Wed, 11 Jan 2012 12:43:02 -0800	[thread overview]
Message-ID: <1326314582.6774.4.camel@joe2Laptop> (raw)
In-Reply-To: <1326311897.3491.6.camel@joe2Laptop>

On Wed, 2012-01-11 at 11:58 -0800, Joe Perches wrote:
> Here's a possible checkpatch patch.
> It seems to work on the test cases I've tried.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +				if ($seen) {
> +					my $sum_allowed = 0;
> +					foreach (@allowed) {
> +						$sum_allowed += $_;
> +					}
> +					if ($sum_allowed == 0) {
> +						WARN("BRACES",
> +						     "braces {} are not necessary for any arm of this statement\n" . $herectx);
> +					} elsif ($sum_allowed != $allow) {

I ran some more tests against the kernel source.
This works better as:

+					} elsif ($sum_allowed != $allow &&
+						 $seen != $allow) {

> +						WARN("BRACES",
> +						     "braces {} should be used on all arms of this statement\n" . $herectx);
> +					}




      reply	other threads:[~2012-01-11 20:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1324918660-25708-1-git-send-email-jak@jak-linux.org>
     [not found] ` <1324918660-25708-5-git-send-email-jak@jak-linux.org>
     [not found]   ` <20120110113552.GJ3644@mwanda>
     [not found]     ` <20120110114835.GB6325@jak-linux.org>
     [not found]       ` <20120110121453.GC16258@mwanda>
     [not found]         ` <1326216615.26536.18.camel@joe2Laptop>
2012-01-11 19:58           ` Joe Perches
2012-01-11 20:43             ` 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=1326314582.6774.4.camel@joe2Laptop \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@shadowen.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=jak@jak-linux.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®