public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dan Carpenter <error27@gmail.com>
Cc: Andy Whitcroft <apw@canonical.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] checkpatch: putting the && or || on the wrong line
Date: Tue, 04 Jan 2011 06:58:50 +0000	[thread overview]
Message-ID: <1294124330.6617.15.camel@Joe-Laptop> (raw)
In-Reply-To: <20110104055900.GA5062@bicker>

On Tue, 2011-01-04 at 08:59 +0300, Dan Carpenter wrote:
> This patch makes checkpatch.pl complain if you break up conditions in
> the wrong way.
> 
> Wrong:
> 	if ((really_long_condition)
> 		&& (second_condition)) { ...
> Right:
> 	if ((really_long_condition) &&
> 		(second_condition)) { ...
> 
> If you do it in the wrong way the message is:  "put the && or || at the
> end of the previous line"
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index e3c7fc0..0a813db 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1509,6 +1509,11 @@ sub process {
>  			WARN("please, no space before tabs\n" . $herevet);
>  		}
>  
> +# check for && or || at the start of a line
> +		if ($rawline =~ /^\+\W+(&&|\|\|)/) {

This should be /^\+[ \t]*(&&|\|\|)/

> +			WARN("put the && or || at the end of the previous line\n" . $herecurr);

I've submitted something like this a couple of times and gotten
various objections but I think it's sensible.

https://lkml.org/lkml/2009/12/5/65
https://lkml.org/lkml/2010/7/11/92



  reply	other threads:[~2011-01-04  6:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-04  5:59 [patch] checkpatch: putting the && or || on the wrong line Dan Carpenter
2011-01-04  6:58 ` Joe Perches [this message]
2011-01-04  9:24   ` Dan Carpenter
2011-01-05 10:24     ` Martin Knoblauch
2011-01-04 16:38 ` J. Bruce Fields
2011-01-04 16:44   ` Samuel Thibault
2011-01-04 17:07     ` Joe Perches
2011-01-05 17:38       ` Krzysztof Halasa
2011-01-05 17:45         ` Joe Perches
2011-01-06 12:11           ` Martin Knoblauch
2011-01-06 17:43             ` Valdis.Kletnieks
2011-01-06 12:32           ` Krzysztof Halasa
2011-01-06 17:57             ` Joe Perches
2011-01-06 20:23               ` Krzysztof Halasa
2011-01-06 21:02                 ` Joe Perches
2011-01-06 21:14                   ` Krzysztof Halasa
2011-01-06 21:38                     ` Joe Perches
2011-01-07 17:12                       ` Valdis.Kletnieks
2011-01-08 13:42                       ` Krzysztof Halasa
2011-01-08 17:12                         ` Joe Perches
2011-01-06 11:55         ` Martin Knoblauch
2011-01-06 12:38           ` Krzysztof Halasa

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=1294124330.6617.15.camel@Joe-Laptop \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=error27@gmail.com \
    --cc=kernel-janitors@vger.kernel.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