staging: lustre: ldlm: Fix initialization of static variables
[firefly-linux-kernel-4.4.55.git] / scripts / checkpatch.pl
index 74bba23a8df030a08a4380cef8cdfd7150667601..374abf44363615004537cb895d3b55bc410ae99b 100755 (executable)
@@ -2641,10 +2641,14 @@ sub process {
                next if ($realfile !~ /\.(h|c)$/);
 
 # check indentation of any line with a bare else
+# (but not if it is a multiple line "if (foo) return bar; else return baz;")
 # if the previous line is a break or return and is indented 1 tab more...
                if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) {
                        my $tabs = length($1) + 1;
-                       if ($prevline =~ /^\+\t{$tabs,$tabs}(?:break|return)\b/) {
+                       if ($prevline =~ /^\+\t{$tabs,$tabs}break\b/ ||
+                           ($prevline =~ /^\+\t{$tabs,$tabs}return\b/ &&
+                            defined $lines[$linenr] &&
+                            $lines[$linenr] !~ /^[ \+]\t{$tabs,$tabs}return/)) {
                                WARN("UNNECESSARY_ELSE",
                                     "else is not generally useful after a break or return\n" . $hereprev);
                        }
@@ -4443,6 +4447,17 @@ sub process {
                        }
                }
 
+# check for logging functions with KERN_<LEVEL>
+               if ($line !~ /printk\s*\(/ &&
+                   $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
+                       my $level = $1;
+                       if (WARN("UNNECESSARY_KERN_LEVEL",
+                                "Possible unnecessary $level\n" . $herecurr) &&
+                           $fix) {
+                               $fixed[$fixlinenr] =~ s/\s*$level\s*//;
+                       }
+               }
+
 # check for bad placement of section $InitAttribute (e.g.: __initdata)
                if ($line =~ /(\b$InitAttribute\b)/) {
                        my $attr = $1;