All of lore.kernel.org
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE
@ 2020-11-15 17:18 Aditya Srivastava
  2020-11-15 20:12 ` Lukas Bulwahn
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Srivastava @ 2020-11-15 17:18 UTC (permalink / raw)
  To: lukas.bulwahn; +Cc: linux-kernel-mentees, yashsri421

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 6f736909f0a4 ("MAINTAINERS: Add
patchwork link for PWM entry") reports this warning:

WARNING: Misordered MAINTAINERS entry - list 'Q:' before 'T:'
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git
+Q:	https://patchwork.ozlabs.org/project/linux-pwm/list/

Provide a simple fix by swapping the unordered lines

Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
Changes in v2:
modified commit message

 scripts/checkpatch.pl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2749f32dffe9..c9aaaa443265 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) {
+							# 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) {
+							$fixed[$fixlinenr - 1] = $rawline;
+							$fixed[$fixlinenr] = $prevrawline;
+						}
 					}
 				}
 			}
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE
  2020-11-15 17:18 [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE Aditya Srivastava
@ 2020-11-15 20:12 ` Lukas Bulwahn
  0 siblings, 0 replies; 4+ messages in thread
From: Lukas Bulwahn @ 2020-11-15 20:12 UTC (permalink / raw)
  To: Aditya Srivastava; +Cc: linux-kernel-mentees

On Sun, Nov 15, 2020 at 6:19 PM Aditya Srivastava <yashsri421@gmail.com> 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 6f736909f0a4 ("MAINTAINERS: Add
> patchwork link for PWM entry") reports this warning:
>
> WARNING: Misordered MAINTAINERS entry - list 'Q:' before 'T:'
>  T:     git git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git
> +Q:     https://patchwork.ozlabs.org/project/linux-pwm/list/
>
> Provide a simple fix by swapping the unordered lines
>


Looks good to me.

Lukas

> Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
> ---
> Changes in v2:
> modified commit message
>
>  scripts/checkpatch.pl | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2749f32dffe9..c9aaaa443265 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) {
> +                                                       # 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) {
> +                                                       $fixed[$fixlinenr - 1] = $rawline;
> +                                                       $fixed[$fixlinenr] = $prevrawline;
> +                                               }
>                                         }
>                                 }
>                         }
> --
> 2.17.1
>
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE
  2020-11-16  7:19 Aditya Srivastava
@ 2020-11-16 21:55 ` Joe Perches
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2020-11-16 21:55 UTC (permalink / raw)
  To: Aditya Srivastava; +Cc: linux-kernel-mentees, linux-kernel

On Mon, 2020-11-16 at 12:49 +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 6f736909f0a4 ("MAINTAINERS: Add
> patchwork link for PWM entry") reports this warning:
> 
> WARNING: Misordered MAINTAINERS entry - list 'Q:' before 'T:'
>  T:	git git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git
> +Q:	https://patchwork.ozlabs.org/project/linux-pwm/list/
> 
> Provide a simple fix by swapping the unordered lines

NAK.

This --fix option can't work if a patch merely adds a single line.
The patch context lines would be wrong.

This has to make sure the both lines are additions (start with +)


> diff --git 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) {
> +							# 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) {
> +							$fixed[$fixlinenr - 1] = $rawline;
> +							$fixed[$fixlinenr] = $prevrawline;
> +						}
>  					}
>  				}
>  			}


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE
@ 2020-11-16  7:19 Aditya Srivastava
  2020-11-16 21:55 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Srivastava @ 2020-11-16  7:19 UTC (permalink / raw)
  To: joe; +Cc: linux-kernel-mentees, linux-kernel, yashsri421

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 6f736909f0a4 ("MAINTAINERS: Add
patchwork link for PWM entry") reports this warning:

WARNING: Misordered MAINTAINERS entry - list 'Q:' before 'T:'
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm.git
+Q:	https://patchwork.ozlabs.org/project/linux-pwm/list/

Provide a simple fix by swapping the unordered lines

Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
Changes in v2:
modified commit message

 scripts/checkpatch.pl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2749f32dffe9..c9aaaa443265 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) {
+							# 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) {
+							$fixed[$fixlinenr - 1] = $rawline;
+							$fixed[$fixlinenr] = $prevrawline;
+						}
 					}
 				}
 			}
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-16 21:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-15 17:18 [Linux-kernel-mentees] [PATCH v2] checkpatch: add fix option for MAINTAINERS_STYLE Aditya Srivastava
2020-11-15 20:12 ` Lukas Bulwahn
2020-11-16  7:19 Aditya Srivastava
2020-11-16 21:55 ` Joe Perches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.