i2c: pca-platform: fix broken email address
[cascardo/linux.git] / scripts / checkpatch.pl
index 9a8b2bd..89b1df4 100755 (executable)
@@ -1690,7 +1690,7 @@ sub fix_inserted_deleted_lines {
        foreach my $old_line (@{$linesRef}) {
                my $save_line = 1;
                my $line = $old_line;   #don't modify the array
-               if ($line =~ /^(?:\+\+\+\|\-\-\-)\s+\S+/) {     #new filename
+               if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) {      #new filename
                        $delta_offset = 0;
                } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) {    #new hunk
                        $range_last_linenr = $new_linenr;
@@ -2513,8 +2513,9 @@ sub process {
 #line length limit
                if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
                    $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
-                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
-                   $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
+                   !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?$String\s*(?:|,|\)\s*;)\s*$/ ||
+                     $line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
+                     $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) &&
                    $length > $max_line_length)
                {
                        WARN("LONG_LINE",
@@ -3226,6 +3227,19 @@ sub process {
                                $herecurr);
                }
 
+# check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
+               if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
+                       my $array = $1;
+                       if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))@) {
+                               my $array_div = $1;
+                               if (WARN("ARRAY_SIZE",
+                                        "Prefer ARRAY_SIZE($array)\n" . $herecurr) &&
+                                   $fix) {
+                                       $fixed[$fixlinenr] =~ s/\Q$array_div\E/ARRAY_SIZE($array)/;
+                               }
+                       }
+               }
+
 # check for function declarations without arguments like "int foo()"
                if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
                        if (ERROR("FUNCTION_WITHOUT_ARGS",
@@ -3382,6 +3396,14 @@ sub process {
                             "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
                }
 
+# ENOSYS means "bad syscall nr" and nothing else.  This will have a small
+# number of false positives, but assembly files are not checked, so at
+# least the arch entry code will not trigger this warning.
+               if ($line =~ /\bENOSYS\b/) {
+                       WARN("ENOSYS",
+                            "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
+               }
+
 # function brace can't be on same line, except for #defines of do while,
 # or if closed on same line
                if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
@@ -3638,7 +3660,7 @@ sub process {
 
                                # Ignore operators passed as parameters.
                                if ($op_type ne 'V' &&
-                                   $ca =~ /\s$/ && $cc =~ /^\s*,/) {
+                                   $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) {
 
 #                              # Ignore comments
 #                              } elsif ($op =~ /^$;+$/) {
@@ -3823,6 +3845,14 @@ sub process {
                                                $ok = 1;
                                        }
 
+                                       # for asm volatile statements
+                                       # ignore a colon with another
+                                       # colon immediately before or after
+                                       if (($op eq ':') &&
+                                           ($ca =~ /:$/ || $cc =~ /^:/)) {
+                                               $ok = 1;
+                                       }
+
                                        # messages are ERROR, but ?: are CHK
                                        if ($ok == 0) {
                                                my $msg_type = \&ERROR;
@@ -4777,6 +4807,16 @@ sub process {
                        }
                }
 
+# check for __read_mostly with const non-pointer (should just be const)
+               if ($line =~ /\b__read_mostly\b/ &&
+                   $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
+                       if (ERROR("CONST_READ_MOSTLY",
+                                 "Invalid use of __read_mostly with const type\n" . $herecurr) &&
+                           $fix) {
+                               $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//;
+                       }
+               }
+
 # don't use __constant_<foo> functions outside of include/uapi/
                if ($realfile !~ m@^include/uapi/@ &&
                    $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
@@ -5338,6 +5378,7 @@ sub process {
                                stacktrace_ops|
                                sysfs_ops|
                                tty_operations|
+                               uart_ops|
                                usb_mon_operations|
                                wd_ops}x;
                if ($line !~ /\bconst\b/ &&