aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-10-16 01:02:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:35 -0400
commit9bd49efe4e4bf88d9c1026db50325fd1b2e59519 (patch)
treed768c2adcefd444c0bd8742ce8246e131be32a47 /scripts/checkpatch.pl
parent4d001e4d88a57ba8347b43e3a20412cd6b67fbd7 (diff)
checkpatch: suspect indent -- skip over preprocessor, label and blank lines
We should skip over and check the lines which follow preprocessor statements, labels, and blank lines. These all have legitimate reasons to be indented differently. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl25
1 files changed, 15 insertions, 10 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3ae79ab2cab..6ddae89c3cfa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1434,7 +1434,7 @@ sub process {
1434 if ($s =~ s/^\s*\\//) { 1434 if ($s =~ s/^\s*\\//) {
1435 $continuation = 1; 1435 $continuation = 1;
1436 } 1436 }
1437 if ($s =~ s/^\s*\n//) { 1437 if ($s =~ s/^\s*?\n//) {
1438 $check = 1; 1438 $check = 1;
1439 $cond_lines++; 1439 $cond_lines++;
1440 } 1440 }
@@ -1446,15 +1446,20 @@ sub process {
1446 $check = 0; 1446 $check = 0;
1447 } 1447 }
1448 1448
1449 # Ignore the current line if its is a preprocessor 1449 my $cond_ptr = -1;
1450 # line. 1450 while ($cond_ptr != $cond_lines) {
1451 if ($s =~ /^\s*#\s*/) { 1451 $cond_ptr = $cond_lines;
1452 $check = 0;
1453 }
1454 1452
1455 # Ignore the current line if it is label. 1453 # Ignore:
1456 if ($s =~ /^\s*$Ident\s*:/) { 1454 # 1) blank lines, they should be at 0,
1457 $check = 0; 1455 # 2) preprocessor lines, and
1456 # 3) labels.
1457 if ($s =~ /^\s*?\n/ ||
1458 $s =~ /^\s*#\s*?/ ||
1459 $s =~ /^\s*$Ident\s*:/) {
1460 $s =~ s/^.*?\n//;
1461 $cond_lines++;
1462 }
1458 } 1463 }
1459 1464
1460 my (undef, $sindent) = line_stats("+" . $s); 1465 my (undef, $sindent) = line_stats("+" . $s);
@@ -1470,7 +1475,7 @@ sub process {
1470 $stat_real = "[...]\n$stat_real"; 1475 $stat_real = "[...]\n$stat_real";
1471 } 1476 }
1472 1477
1473 ##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n"; 1478 #print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s> cond_lines<$cond_lines> stat_real<$stat_real> stat<$stat>\n";
1474 1479
1475 if ($check && (($sindent % 8) != 0 || 1480 if ($check && (($sindent % 8) != 0 ||
1476 ($sindent <= $indent && $s ne ''))) { 1481 ($sindent <= $indent && $s ne ''))) {