checkpatch: add check for keyword 'boolean' in Kconfig definitions
[pandora-kernel.git] / scripts / checkpatch.pl
index f0bb6d6..6afc24b 100755 (executable)
@@ -278,6 +278,7 @@ our $Attribute      = qr{
                        __noreturn|
                        __used|
                        __cold|
+                       __pure|
                        __noclone|
                        __deprecated|
                        __read_mostly|
@@ -298,6 +299,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?};
 our $Hex       = qr{(?i)0x[0-9a-f]+$Int_type?};
 our $Int       = qr{[0-9]+$Int_type?};
 our $Octal     = qr{0[0-7]+$Int_type?};
+our $String    = qr{"[X\t]*"};
 our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
 our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
 our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
@@ -517,7 +519,7 @@ our $Typecast       = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
 
 our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
 our $LvalOrFunc        = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*};
-our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)};
+our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)};
 
 our $declaration_macros = qr{(?x:
        (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(|
@@ -2355,6 +2357,13 @@ sub process {
                             "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n");
                }
 
+# discourage the use of boolean for type definition attributes of Kconfig options
+               if ($realfile =~ /Kconfig/ &&
+                   $line =~ /^\+\s*\bboolean\b/) {
+                       WARN("CONFIG_TYPE_BOOLEAN",
+                            "Use of boolean is deprecated, please use bool instead.\n" . $herecurr);
+               }
+
                if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) &&
                    ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) {
                        my $flag = $1;
@@ -4545,7 +4554,7 @@ sub process {
                }
 
 # check for logging functions with KERN_<LEVEL>
-               if ($line !~ /printk\s*\(/ &&
+               if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ &&
                    $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) {
                        my $level = $1;
                        if (WARN("UNNECESSARY_KERN_LEVEL",
@@ -5089,6 +5098,12 @@ sub process {
                        }
                }
 
+# check for uses of __DATE__, __TIME__, __TIMESTAMP__
+               while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) {
+                       ERROR("DATE_TIME",
+                             "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr);
+               }
+
 # check for use of yield()
                if ($line =~ /\byield\s*\(\s*\)/) {
                        WARN("YIELD",
@@ -5255,6 +5270,9 @@ sub process {
                                             length($val) ne 4)) {
                                                ERROR("NON_OCTAL_PERMISSIONS",
                                                      "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr);
+                                       } elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) {
+                                               ERROR("EXPORTED_WORLD_WRITABLE",
+                                                     "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
                                        }
                                }
                        }