Skip to contentSkip to conversation

checkpatch: fix erroneous indentation errors

PATCH New Johannes Berg 1 participant 1 message Sep 5, 2012 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: fix erroneous indentation errors

From: Johannes Berg <[email protected]>

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.

---
 scripts/checkpatch.pl |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +3 -3
index e5bd60f..6a97c3b 100755
@@ -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 .
Signature · 1 line
1.7.10.4