Commit 14b111c1 authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Linus Torvalds

checkpatch: conditional indent -- labels have different indent rules

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: default avatarAndy Whitcroft <apw@shadowen.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0d413866
...@@ -782,9 +782,9 @@ sub annotate_values { ...@@ -782,9 +782,9 @@ sub annotate_values {
} }
$type = 'N'; $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); print "COND($1)\n" if ($dbg_values > 1);
$av_pending = 'N'; $av_pending = 'E';
$type = 'N'; $type = 'N';
} elsif ($cur =~/^(case)/o) { } elsif ($cur =~/^(case)/o) {
...@@ -792,7 +792,7 @@ sub annotate_values { ...@@ -792,7 +792,7 @@ sub annotate_values {
$av_pend_colon = 'C'; $av_pend_colon = 'C';
$type = 'N'; $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); print "KEYWORD($1)\n" if ($dbg_values > 1);
$type = 'N'; $type = 'N';
...@@ -1846,6 +1846,11 @@ sub process { ...@@ -1846,6 +1846,11 @@ sub process {
$check = 0; $check = 0;
} }
# Ignore the current line if it is label.
if ($s =~ /^\s*$Ident\s*:/) {
$check = 0;
}
my (undef, $sindent) = line_stats("+" . $s); my (undef, $sindent) = line_stats("+" . $s);
##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s>\n"; ##print "line<$line> prevline<$prevline> indent<$indent> sindent<$sindent> check<$check> continuation<$continuation> s<$s>\n";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment