Skip to contentSkip to conversation

scripts/checkpatch: Fix multiple Reported-by: false positive warning

PATCH RESEND In review Advait Dhamorikar 1 participant 2 messages Nov 4, 2024 – Nov 18, 2024 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 scripts/checkpatch: Fix multiple Reported-by: false positive warning

If multiple Reported-by: tags are used, the checkpatch script throws a false positive warning even when there is a Closes tag following the two tags. This fix checks if the closes tag is present after multiple Reported-by tags.

Here is an example of the same:

Quoted 7 lines

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#10:

total: 0 errors, 1 warnings, 0 checks, 8 lines checked

---
 scripts/checkpatch.pl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +6 -3
index 4427572b2477..c74519f02180 100755
@@ -3188,10 +3188,13 @@ sub process {
 			if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) {
 				if (!defined $lines[$linenr]) {
 					WARN("BAD_REPORTED_BY_LINK",
-					     "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
-				} elsif ($rawlines[$linenr] !~ /^closes:\s*/i) {
+						"Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
+				} elsif ($lines[$linenr] =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] =~ /^reported(?:|-and-tested)-by:/i) {
+       				 # Do nothing if the next line is another Reported-by:
+                }
+				elsif ($lines[$linenr]  =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] !~ /^closes:\s*/i) {
 					WARN("BAD_REPORTED_BY_LINK",
-					     "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
+						"Reported-by: should be immediately followed by Closes: with a URL to the report\n" . "#" . ($linenr + 1) . ":" . "\n" . $rawlines[$linenr] . "\n");
 				}
 			}
 		}
Signature · 1 line
2.34.1
#1 lore raw

Hello Joe,

Please let me know if you have any feedback for this patch, if there's something more that can be worked on in this fix.

Kind regards,
Advait

Quoted 45 lines · Advait Dhamorikar

If multiple Reported-by: tags are used, the checkpatch script throws a false positive warning even when there is a Closes tag following the two tags. This fix checks if the closes tag is present after multiple Reported-by tags.

Here is an example of the same:

Quoted 7 lines

WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#10:

total: 0 errors, 1 warnings, 0 checks, 8 lines checked

---
 scripts/checkpatch.pl | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +6 -4
index 4427572b2477..c74519f02180 100755
@@ -3188,10 +3188,13 @@ sub process {
                        if ($sign_off =~ /^reported(?:|-and-tested)-by:$/i) {
                                if (!defined $lines[$linenr]) {
                                        WARN("BAD_REPORTED_BY_LINK",
-                                            "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
-                               } elsif ($rawlines[$linenr] !~ /^closes:\s*/i) {
+                                               "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . "\n");
+                               } elsif ($lines[$linenr] =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] =~ /^reported(?:|-and-tested)-by:/i) {
+                                        # Do nothing if the next line is another Reported-by:
+                }
+                               elsif ($lines[$linenr]  =~ /^reported(?:|-and-tested)-by:/i && $lines[$linenr + 1] !~ /^closes:\s*/i) {
                                        WARN("BAD_REPORTED_BY_LINK",
-                                            "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . $herecurr . $rawlines[$linenr] . "\n");
+                                               "Reported-by: should be immediately followed by Closes: with a URL to the report\n" . "#" . ($linenr + 1) . ":" . "\n" . $rawlines[$linenr] . "\n");
                                }
                        }
                }
--

2.34.1