Skip to content

Commit

Permalink
checkpatch: conditional indent -- labels have different indent rules
Browse files Browse the repository at this point in the history
Labels have different indent rules and must be ignored when checking the
conditional indent levels.  Also correct identify labels in single
statement conditionals.

Signed-off-by: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
awhitcroft authored and torvalds committed Oct 16, 2008
1 parent 0d41386 commit 14b111c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -782,17 +782,17 @@ sub annotate_values {
}
$type = 'N';

} elsif ($cur =~ /^(if|while|typeof|__typeof__|for)\b/o) {
} elsif ($cur =~ /^(if|while|for)\b/o) {
print "COND($1)\n" if ($dbg_values > 1);
$av_pending = 'N';
$av_pending = 'E';
$type = 'N';

} elsif ($cur =~/^(case)/o) {
print "CASE($1)\n" if ($dbg_values > 1);
$av_pend_colon = 'C';
$type = 'N';

} elsif ($cur =~/^(return|else|goto)/o) {
} elsif ($cur =~/^(return|else|goto|typeof|__typeof__)\b/o) {
print "KEYWORD($1)\n" if ($dbg_values > 1);
$type = 'N';

Expand Down Expand Up @@ -1846,6 +1846,11 @@ sub process {
$check = 0;
}

# Ignore the current line if it is label.
if ($s =~ /^\s*$Ident\s*:/) {
$check = 0;
}

my (undef, $sindent) = line_stats("+" . $s);

##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s>\n";
Expand Down

0 comments on commit 14b111c

Please sign in to comment.