History

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.

Andy Whitcroft committed 18 years ago

Commit 9bd49ef1 parent 4d001e41 file · +15 −10Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+15−10
@@ -1434,7 +1434,7 @@ sub process { · 1433 unmodified lines
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 { · 5 unmodified lines
1446 $check = 0;1446 $check = 0;
1447 }1447 }
1448 1448
1449 # Ignore the current line if its is a preprocessor1449 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 { · 9 unmodified lines
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 ''))) {