checkpatch: additional MAINTAINER section entry ordering checks
[linux-2.6-microblaze.git] / scripts / checkpatch.pl
index b83be17..10d75da 100755 (executable)
@@ -3062,14 +3062,43 @@ sub process {
                        #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
                }
 
-# check for MAINTAINERS entries that don't have the right form
-               if ($realfile =~ /^MAINTAINERS$/ &&
-                   $rawline =~ /^\+[A-Z]:/ &&
-                   $rawline !~ /^\+[A-Z]:\t\S/) {
-                       if (WARN("MAINTAINERS_STYLE",
-                                "MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
-                           $fix) {
-                               $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
+# check MAINTAINERS entries
+               if ($realfile =~ /^MAINTAINERS$/) {
+# check MAINTAINERS entries for the right form
+                       if ($rawline =~ /^\+[A-Z]:/ &&
+                           $rawline !~ /^\+[A-Z]:\t\S/) {
+                               if (WARN("MAINTAINERS_STYLE",
+                                        "MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
+                                   $fix) {
+                                       $fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/;
+                               }
+                       }
+# check MAINTAINERS entries for the right ordering too
+                       my $preferred_order = 'MRLSWQBCPTFXNK';
+                       if ($rawline =~ /^\+[A-Z]:/ &&
+                           $prevrawline =~ /^[\+ ][A-Z]:/) {
+                               $rawline =~ /^\+([A-Z]):\s*(.*)/;
+                               my $cur = $1;
+                               my $curval = $2;
+                               $prevrawline =~ /^[\+ ]([A-Z]):\s*(.*)/;
+                               my $prev = $1;
+                               my $prevval = $2;
+                               my $curindex = index($preferred_order, $cur);
+                               my $previndex = index($preferred_order, $prev);
+                               if ($curindex < 0) {
+                                       WARN("MAINTAINERS_STYLE",
+                                            "Unknown MAINTAINERS entry type: '$cur'\n" . $herecurr);
+                               } else {
+                                       if ($previndex >= 0 && $curindex < $previndex) {
+                                               WARN("MAINTAINERS_STYLE",
+                                                    "Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev);
+                                       } elsif ((($prev eq 'F' && $cur eq 'F') ||
+                                                 ($prev eq 'X' && $cur eq 'X')) &&
+                                                ($prevval cmp $curval) > 0) {
+                                               WARN("MAINTAINERS_STYLE",
+                                                    "Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev);
+                                       }
+                               }
                        }
                }
 
@@ -4203,6 +4232,17 @@ sub process {
                             "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
                }
 
+# ENOTSUPP is not a standard error code and should be avoided in new patches.
+# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP.
+# Similarly to ENOSYS warning a small number of false positives is expected.
+               if (!$file && $line =~ /\bENOTSUPP\b/) {
+                       if (WARN("ENOTSUPP",
+                                "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP\n" . $herecurr) &&
+                           $fix) {
+                               $fixed[$fixlinenr] =~ s/\bENOTSUPP\b/EOPNOTSUPP/;
+                       }
+               }
+
 # function brace can't be on same line, except for #defines of do while,
 # or if closed on same line
                if ($perl_version_ok &&