mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Andy Whitcroft <apw@canonical.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Subject: [PATCH] checkpatch: fix erroneous indentation errors
Date: Wed, 05 Sep 2012 21:42:49 +0200	[thread overview]
Message-ID: <1346874169.4364.42.camel@jlt4.sipsolutions.net> (raw)

From: Johannes Berg <johannes.berg@intel.com>

In a few cases, checkpatch gives false indentation CHECKs:

@@ ... @@
-	foo(1, 2, 3,
+	foo(1, 2, 3, 4,
 	    5, 6, 7, 8);

will warn.

@@ ... @@
	foo(1, 2, 3, 4,
-	    5, 6, 7, 8);
+		5, 6, 7, 8);

will not warn.

Change this. The only disadvantage of the new code is
that it will warn about context-only indentation problems,
e.g.

@@ ... @@
	foo(1, 2, 3, 4,
		5, 6, 7, 8);
-	unrelated();

will cause a warning now. It could probably be prevented
by a match on $rawline, but I wasn't sure how to do that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 scripts/checkpatch.pl |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e5bd60f..6a97c3b 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1841,14 +1841,14 @@ sub process {
 
 # check multi-line statement indentation matches previous line
 		if ($^V && $^V ge 5.10.0 &&
-		    $prevline =~ /^\+(\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
-			$prevline =~ /^\+(\t*)(.*)$/;
+		    $prevline =~ /^[ \+](\t*)(if \(|$Ident\().*(\&\&|\|\||,)\s*$/) {
+			$prevline =~ /^[ \+](\t*)(.*)$/;
 			my $oldindent = $1;
 			my $rest = $2;
 
 			my $pos = pos_last_openparen($rest);
 			if ($pos >= 0) {
-				$line =~ /^\+([ \t]*)/;
+				$line =~ /^[\+ ]([ \t]*)/;
 				my $newindent = $1;
 
 				my $goodtabindent = $oldindent .
-- 
1.7.10.4




                 reply	other threads:[~2012-09-05 19:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1346874169.4364.42.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=apw@canonical.com \
    --cc=emmanuel.grumbach@intel.com \
    --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®