checkpatch: switch indent allow plain return
[linux-2.6-block.git] / scripts / checkpatch.pl
index bc6779398229757a94a44a4d3ef4a70dbf618a49..c6782ac6f130b5c8d83c7b72d9b38743adff2256 100755 (executable)
@@ -782,9 +782,9 @@ 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) {
@@ -792,7 +792,7 @@ sub annotate_values {
                        $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';
 
@@ -858,7 +858,7 @@ sub annotate_values {
                        print "CLOSE($1)\n" if ($dbg_values > 1);
                        $type = 'N';
 
-               } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&(?!\&))/o) {
+               } elsif ($cur =~ /^(-(?![->])|\+(?!\+)|\*|\&\&|\&)/o) {
                        my $variant;
 
                        print "OPV($1)\n" if ($dbg_values > 1);
@@ -1295,7 +1295,11 @@ sub process {
                        }
                }
                if ($line =~ /^.\s*(?:case\s*.*|default\s*):/g &&
-                   $line !~ /\G(?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$/g) {
+                   $line !~ /\G(?:
+                       (?:\s*{)?(?:\s*$;*)(?:\s*\\)?\s*$|
+                       \s*return\s+
+                   )/xg)
+               {
                        ERROR("trailing statements should be on next line\n" . $herecurr);
                }
 
@@ -1493,11 +1497,13 @@ sub process {
 
 # check for spacing round square brackets; allowed:
 #  1. with a type on the left -- int [] a;
-#  2. at the beginning of a line for slice initialisers -- [0..10] = 5,
+#  2. at the beginning of a line for slice initialisers -- [0...10] = 5,
+#  3. inside a curly brace -- = { [0...10] = 5 }
                while ($line =~ /(.*?\s)\[/g) {
                        my ($where, $prefix) = ($-[1], $1);
                        if ($prefix !~ /$Type\s+$/ &&
-                           ($where != 0 || $prefix !~ /^.\s+$/)) {
+                           ($where != 0 || $prefix !~ /^.\s+$/) &&
+                           $prefix !~ /{\s+$/) {
                                ERROR("space prohibited before open square bracket '['\n" . $herecurr);
                        }
                }
@@ -1632,7 +1638,7 @@ sub process {
                                # unary operator, or a cast
                                } elsif ($op eq '!' || $op eq '~' ||
                                         $opv eq '*U' || $opv eq '-U' ||
-                                        $opv eq '&U') {
+                                        $opv eq '&U' || $opv eq '&&U') {
                                        if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
                                                ERROR("space required before that '$op' $at\n" . $hereptr);
                                        }
@@ -1844,6 +1850,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";