]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - scripts/checkpatch.pl
Merge tag 'sunxi-fixes-for-4.11' of https://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / scripts / checkpatch.pl
index 4f53093a1b0bd7f274228901e3889260736fef66..baa3c7be04ad8897761f92abd2b5d428d24f8471 100755 (executable)
@@ -424,7 +424,7 @@ our $typeTypedefs = qr{(?x:
 our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};
 
 our $logFunctions = qr{(?x:
-       printk(?:_ratelimited|_once|)|
+       printk(?:_ratelimited|_once|_deferred_once|_deferred|)|
        (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
        WARN(?:_RATELIMIT|_ONCE|)|
        panic|
@@ -1848,6 +1848,8 @@ my $prefix = '';
 sub show_type {
        my ($type) = @_;
 
+       $type =~ tr/[a-z]/[A-Z]/;
+
        return defined $use_type{$type} if (scalar keys %use_type > 0);
 
        return !defined $ignore_type{$type};
@@ -2703,6 +2705,7 @@ sub process {
 
 # Check for FSF mailing addresses.
                if ($rawline =~ /\bwrite to the Free/i ||
+                   $rawline =~ /\b675\s+Mass\s+Ave/i ||
                    $rawline =~ /\b59\s+Temple\s+Pl/i ||
                    $rawline =~ /\b51\s+Franklin\s+St/i) {
                        my $herevet = "$here\n" . cat_vet($rawline) . "\n";
@@ -5103,6 +5106,12 @@ sub process {
                        }
                }
 
+# check for single line unbalanced braces
+               if ($sline =~ /^.\s*\}\s*else\s*$/ ||
+                   $sline =~ /^.\s*else\s*\{\s*$/) {
+                       CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
+               }
+
 # check for unnecessary blank lines around braces
                if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
                        if (CHK("BRACES",
@@ -5197,18 +5206,27 @@ sub process {
                             "Consecutive strings are generally better as a single string\n" . $herecurr);
                }
 
-# check for %L{u,d,i} and 0x%[udi] in strings
-               my $string;
+# check for non-standard and hex prefixed decimal printf formats
+               my $show_L = 1; #don't show the same defect twice
+               my $show_Z = 1;
                while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {
-                       $string = substr($rawline, $-[1], $+[1] - $-[1]);
+                       my $string = substr($rawline, $-[1], $+[1] - $-[1]);
                        $string =~ s/%%/__/g;
-                       if ($string =~ /(?<!%)%[\*\d\.\$]*L[udi]/) {
+                       # check for %L
+                       if ($show_L && $string =~ /%[\*\d\.\$]*L([diouxX])/) {
                                WARN("PRINTF_L",
-                                    "\%Ld/%Lu are not-standard C, use %lld/%llu\n" . $herecurr);
-                               last;
-                       }
-                       if ($string =~ /0x%[\*\d\.\$\Llzth]*[udi]/) {
-                               ERROR("PRINTF_0xDECIMAL",
+                                    "\%L$1 is non-standard C, use %ll$1\n" . $herecurr);
+                               $show_L = 0;
+                       }
+                       # check for %Z
+                       if ($show_Z && $string =~ /%[\*\d\.\$]*Z([diouxX])/) {
+                               WARN("PRINTF_Z",
+                                    "%Z$1 is non-standard C, use %z$1\n" . $herecurr);
+                               $show_Z = 0;
+                       }
+                       # check for 0x<decimal>
+                       if ($string =~ /0x%[\*\d\.\$\Llzth]*[diou]/) {
+                               ERROR("PRINTF_0XDECIMAL",
                                      "Prefixing 0x with decimal output is defective\n" . $herecurr);
                        }
                }
@@ -5287,6 +5305,12 @@ sub process {
                        }
                }
 
+# check for logging continuations
+               if ($line =~ /\bprintk\s*\(\s*KERN_CONT\b|\bpr_cont\s*\(/) {
+                       WARN("LOGGING_CONTINUATION",
+                            "Avoid logging continuation uses where feasible\n" . $herecurr);
+               }
+
 # check for mask then right shift without a parentheses
                if ($^V && $^V ge 5.10.0 &&
                    $line =~ /$LvalOrFunc\s*\&\s*($LvalOrFunc)\s*>>/ &&