checkpatch: comment ends inside strings is most likely not an open comment
[pandora-kernel.git] / scripts / checkpatch.pl
index f88bb3e..45a97c9 100755 (executable)
@@ -116,7 +116,8 @@ our $Attribute      = qr{
                        __(?:mem|cpu|dev|)(?:initdata|init)|
                        ____cacheline_aligned|
                        ____cacheline_aligned_in_smp|
-                       ____cacheline_internodealigned_in_smp
+                       ____cacheline_internodealigned_in_smp|
+                       __weak
                  }x;
 our $Modifier;
 our $Inline    = qr{inline|__always_inline|noinline};
@@ -366,7 +367,7 @@ sub sanitise_line {
                        }
                }
 
-               #print "SQ:$sanitise_quote\n";
+               #print "c<$c> SQ<$sanitise_quote>\n";
                if ($off != 0 && $sanitise_quote eq '*/' && $c ne "\t") {
                        substr($res, $off, 1, $;);
                } elsif ($off != 0 && $sanitise_quote && $c ne "\t") {
@@ -843,11 +844,11 @@ sub annotate_values {
                        $type = 'V';
                        $av_pending = 'V';
 
-               } elsif ($cur =~ /^($Ident\s*):/) {
-                       if ($type eq 'E') {
-                               $av_pend_colon = 'L';
-                       } elsif ($type eq 'T') {
+               } elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {
+                       if (defined $2 && $type eq 'C' || $type eq 'T') {
                                $av_pend_colon = 'B';
+                       } elsif ($type eq 'E') {
+                               $av_pend_colon = 'L';
                        }
                        print "IDENT_COLON($1,$type>$av_pend_colon)\n" if ($dbg_values > 1);
                        $type = 'V';
@@ -865,6 +866,10 @@ sub annotate_values {
                        $type = 'E';
                        $av_pend_colon = 'O';
 
+               } elsif ($cur =~/^(,)/) {
+                       print "COMMA($1)\n" if ($dbg_values > 1);
+                       $type = 'C';
+
                } elsif ($cur =~ /^(\?)/o) {
                        print "QUESTION($1)\n" if ($dbg_values > 1);
                        $type = 'N';
@@ -880,7 +885,7 @@ sub annotate_values {
                        }
                        $av_pend_colon = 'O';
 
-               } elsif ($cur =~ /^(;|\[)/o) {
+               } elsif ($cur =~ /^(\[)/o) {
                        print "CLOSE($1)\n" if ($dbg_values > 1);
                        $type = 'N';
 
@@ -1097,9 +1102,12 @@ sub process {
                                         $rawlines[$ln - 1] =~ /^-/);
                                $cnt--;
                                #print "RAW<$rawlines[$ln - 1]>\n";
-                               ($edge) = (defined $rawlines[$ln - 1] &&
-                                       $rawlines[$ln - 1] =~ m@(/\*|\*/)@);
-                               last if (defined $edge);
+                               last if (!defined $rawlines[$ln - 1]);
+                               if ($rawlines[$ln - 1] =~ m@(/\*|\*/)@ &&
+                                   $rawlines[$ln - 1] !~ m@"[^"]*(?:/\*|\*/)[^"]*"@) {
+                                       ($edge) = $1;
+                                       last;
+                               }
                        }
                        if (defined $edge && $edge eq '*/') {
                                $in_comment = 1;
@@ -1109,7 +1117,7 @@ sub process {
                        # is the start of a diff block and this line starts
                        # ' *' then it is very likely a comment.
                        if (!defined $edge &&
-                           $rawlines[$linenr] =~ m@^.\s* \*(?:\s|$)@)
+                           $rawlines[$linenr] =~ m@^.\s*(?:\*\*+| \*)(?:\s|$)@)
                        {
                                $in_comment = 1;
                        }
@@ -2167,9 +2175,10 @@ sub process {
                                MODULE_PARAM_DESC|
                                DECLARE_PER_CPU|
                                DEFINE_PER_CPU|
-                               __typeof__\(
+                               __typeof__\(|
+                               \.$Ident\s*=\s*
                        }x;
-                       #print "REST<$rest>\n";
+                       #print "REST<$rest> dstat<$dstat>\n";
                        if ($rest ne '') {
                                if ($rest !~ /while\s*\(/ &&
                                    $dstat !~ /$exceptions/)
@@ -2466,6 +2475,15 @@ sub process {
                                last;
                        }
                }
+
+# whine mightly about in_atomic
+               if ($line =~ /\bin_atomic\s*\(/) {
+                       if ($realfile =~ m@^drivers/@) {
+                               ERROR("do not use in_atomic in drivers\n" . $herecurr);
+                       } else {
+                               WARN("use of in_atomic() is incorrect outside core kernel code\n" . $herecurr);
+                       }
+               }
        }
 
        # If we have no input at all, then there is nothing to report on