Skip to contentSkip to conversation

checkpatch: add fix option for MAINTAINERS_STYLE

PATCH In review Aditya Srivastava 2 participants 2 messages Nov 15, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: add fix option for MAINTAINERS_STYLE

Checkpatch expects entry 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

---
 scripts/checkpatch.pl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +13 -4
index 2749f32dffe9..c9aaaa443265 100755
@@ -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;
+						}
 					}
 				}
 			}
Signature · 6 lines
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 2 lines · Aditya Srivastava

Checkpatch expects entry in maintainers file in a specific order and

s/entry/entries/
s/maintainers/MAINTAINERS/

Quoted 11 lines

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

Generally, looks good to me.

Lukas

Quoted 37 lines
---
 scripts/checkpatch.pl | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +13 -5
index 2749f32dffe9..c9aaaa443265 100755
@@ -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;
+                                               }
                                        }
                                }
                        }
--
Quoted 2 lines

2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees