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
14341434 if ($s =~ s/^\s*\\//) {
14351435 $continuation = 1;
14361436 }
1437− if ($s =~ s/^\s*\n//) {
1437+ if ($s =~ s/^\s*?\n//) {
14381438 $check = 1;
14391439 $cond_lines++;
14401440 }
@@ -1446,15 +1446,20 @@ sub process { · 5 unmodified lines
14461446 $check = 0;
14471447 }
14481448
1449− # Ignore the current line if its is a preprocessor
1450− # line.
1451− if ($s =~ /^\s*#\s*/) {
1452− $check = 0;
1453− }
1449+ my $cond_ptr = -1;
1450+ while ($cond_ptr != $cond_lines) {
1451+ $cond_ptr = $cond_lines;
14541452
1455− # Ignore the current line if it is label.
1456− if ($s =~ /^\s*$Ident\s*:/) {
1457− $check = 0;
1453+ # Ignore:
1454+ # 1) blank lines, they should be at 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+ }
14581463 }
14591464
14601465 my (undef, $sindent) = line_stats("+" . $s);
@@ -1470,7 +1475,7 @@ sub process { · 9 unmodified lines
14701475 $stat_real = "[...]\n$stat_real";
14711476 }
14721477
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";
14741479
14751480 if ($check && (($sindent % 8) != 0 ||
14761481 ($sindent <= $indent && $s ne ''))) {