[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <477496bed101ed007e7e8db6d511ece2fa2d119c.camel@perches.com>
Date: Mon, 16 Nov 2020 20:20:42 -0800
From: Joe Perches <joe@...ches.com>
To: Aditya Srivastava <yashsri421@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel-mentees@...ts.linuxfoundation.org,
linux-kernel@...r.kernel.org, lukas.bulwahn@...il.com
Subject: Re: [PATCH v3] checkpatch: add fix option for MAINTAINERS_STYLE
On Tue, 2020-11-17 at 09:35 +0530, Aditya Srivastava wrote:
> Checkpatch expects entries in MAINTAINERS file in a specific order and
> warns if the changes made do not follow the specified order.
>
> E.g., running checkpatch on commit b33bc2b878e0 ("nexthop: Add entry to
> MAINTAINERS") reports this warning:
>
> WARNING: Misordered MAINTAINERS entry - list file patterns in
> alphabetic order
> +F: include/uapi/linux/nexthop.h
> +F: include/net/netns/nexthop.h
OK, this should work.
Thanks Aditya.
Acked-by: Joe Perches <joe@...ches.com>
>
> Provide a simple fix by swapping the unordered lines, if both the lines
> are additions (start with '+')
>
> Signed-off-by: Aditya Srivastava <yashsri421@...il.com>
> ---
> Changes in v2:
> modified commit message
>
> Changes in v3:
> add check if both the lines are additions(ie start with '+')
>
> scripts/checkpatch.pl | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2749f32dffe9..7ee3f05c354d 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -3299,13 +3299,22 @@ sub process {
> "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);
> + if (WARN("MAINTAINERS_STYLE",
> + "Misordered MAINTAINERS entry - list '$cur:' before '$prev:'\n" . $hereprev) &&
> + $fix && $prevrawline =~ /^\+[A-Z]:/) {
> + # swap these lines
> + $fixed[$fixlinenr - 1] = $rawline;
> + $fixed[$fixlinenr] = $prevrawline;
> + }
> } 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);
> + if (WARN("MAINTAINERS_STYLE",
> + "Misordered MAINTAINERS entry - list file patterns in alphabetic order\n" . $hereprev) &&
> + $fix && $prevrawline =~ /^\+[A-Z]:/) {
> + $fixed[$fixlinenr - 1] = $rawline;
> + $fixed[$fixlinenr] = $prevrawline;
> + }
> }
> }
> }
Powered by blists - more mailing lists