Commit 7ccf41a8 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: additional MAINTAINER section entry ordering checks

There is a preferred order for the entries in MAINTAINERS sections.

See commits 3b50142d ("MAINTAINERS: sort field names for all
entries") and 6680125e ("MAINTAINERS: list the section entries in
the preferred order")

Add checkpatch tests to try to keep that ordering.
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Acked-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Link: http://lkml.kernel.org/r/17677130b3ca62d79817e6a22546bad39d7e81b4.camel@perches.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent bd93f003
...@@ -3062,14 +3062,43 @@ sub process { ...@@ -3062,14 +3062,43 @@ sub process {
#print "is_start<$is_start> is_end<$is_end> length<$length>\n"; #print "is_start<$is_start> is_end<$is_end> length<$length>\n";
} }
# check for MAINTAINERS entries that don't have the right form # check MAINTAINERS entries
if ($realfile =~ /^MAINTAINERS$/ && if ($realfile =~ /^MAINTAINERS$/) {
$rawline =~ /^\+[A-Z]:/ && # check MAINTAINERS entries for the right form
$rawline !~ /^\+[A-Z]:\t\S/) { if ($rawline =~ /^\+[A-Z]:/ &&
if (WARN("MAINTAINERS_STYLE", $rawline !~ /^\+[A-Z]:\t\S/) {
"MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) && if (WARN("MAINTAINERS_STYLE",
$fix) { "MAINTAINERS entries use one tab after TYPE:\n" . $herecurr) &&
$fixed[$fixlinenr] =~ s/^(\+[A-Z]):\s*/$1:\t/; $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);
}
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment