Skip to contentSkip to conversation

checkpatch: extend author Signed-off-by check for split From: header

PATCH Superseded Dwaipayan Ray 2 participants 4 messages Sep 19, 2020 – Sep 20, 2020 Checkpatch

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: extend author Signed-off-by check for split From: header

Checkpatch did not handle cases where the author From: header was split into multiple lines. The author identity could not be resolved and checkpatch generated a false NO_AUTHOR_SIGN_OFF warning.

Support split From: headers in AUTHOR_SIGN_OFF check by correctly parsing the entire From: header in such cases.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -0
index 504d2e431c60..8ee61ec346b3 100755
@@ -2661,6 +2661,10 @@ sub process {
 # Check the patch for a From:
 		if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
 			$author = $1;
+			my $curline = $linenr-1;
+			while(defined($rawlines[++$curline]) && ($rawlines[$curline] =~ /^\s+(.*)/)) {
+				$author.= $1;
+			}
 			$author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
 			$author =~ s/"//g;
 			$author = reformat_email($author);
Signature · 6 lines
2.27.0

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

Checkpatch did not handle cases where the author From: header was split into multiple lines. The author identity could not be resolved and checkpatch generated a false NO_AUTHOR_SIGN_OFF warning.

Support split From: headers in AUTHOR_SIGN_OFF check by correctly parsing the entire From: header in such cases.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -1
index 504d2e431c60..8ee61ec346b3 100755
@@ -2661,6 +2661,10 @@ sub process {
 # Check the patch for a From:
                if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
                        $author = $1;
+                       my $curline = $linenr-1;
+                       while(defined($rawlines[++$curline]) && ($rawlines[$curline] =~ /^\s+(.*)/)) {
+                               $author.= $1;
+                       }
                        $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
                        $author =~ s/"//g;
                        $author = reformat_email($author);
--
Quoted 2 lines

2.27.0

Hi,
Based on Joe's suggestions I updated the patch. It's totally similar except for the fact that Joe missed a closing parenthesis and he removed the decode("MIME-Header") part which caused parsing of utf-8 to fail.

example: (commit e33bcbab16d1)
WARNING: Missing Signed-off-by: line by nominal patch author '"=?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?=" <[email protected]>

So I fixed these.

Also, Joe stated that all split lines must start with a space. But I looked it up and it states that it must be a WSP, that is either a single space or a horizontal tab.
References:
WSP: (https://www.rfc-editor.org/std/std68.txt)
Long headers: https://tools.ietf.org/html/rfc2822#section-2.2.3

So, i went with the ^\s+ expression instead of ^ s*. Is it alright or should be changed?

I do have a final question though, since he had already solved it, is it okay to send this patch in again?

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

#2 lore raw
Quoted 54 lines · Dwaipayan Ray
Quoted 30 lines · Dwaipayan Ray

Checkpatch did not handle cases where the author From: header was split into multiple lines. The author identity could not be resolved and checkpatch generated a false NO_AUTHOR_SIGN_OFF warning.

Support split From: headers in AUTHOR_SIGN_OFF check by correctly parsing the entire From: header in such cases.

---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -1
index 504d2e431c60..8ee61ec346b3 100755
@@ -2661,6 +2661,10 @@ sub process {
 # Check the patch for a From:
                if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
                        $author = $1;
+                       my $curline = $linenr-1;
+                       while(defined($rawlines[++$curline]) && ($rawlines[$curline] =~ /^\s+(.*)/)) {
+                               $author.= $1;
+                       }
                        $author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
                        $author =~ s/"//g;
                        $author = reformat_email($author);
--
Quoted 2 lines

2.27.0

Hi,
Based on Joe's suggestions I updated the patch. It's totally similar except for the fact that Joe missed a closing parenthesis and he removed the decode("MIME-Header") part which caused parsing of utf-8 to fail.

example: (commit e33bcbab16d1)
WARNING: Missing Signed-off-by: line by nominal patch author '"=?UTF-8?q?Vesa=20J=C3=A4=C3=A4skel=C3=A4inen?=" <[email protected]>

So I fixed these.

Also, Joe stated that all split lines must start with a space. But I looked it up and it states that it must be a WSP, that is either a single space or a horizontal tab.
References:
WSP: (https://www.rfc-editor.org/std/std68.txt)
Long headers: https://tools.ietf.org/html/rfc2822#section-2.2.3

Quoted 6 lines

So, i went with the ^\s+ expression instead of ^ s*. Is it alright or should be changed?

I do have a final question though, since he had already solved it, is it okay to send this patch in again?

Yes, please provide your design decisions in the commit message.

You can add a 'Suggested-by:' tag to name that Joe pointed out the idea.

Also, you can add a 'Link:' to the previous email from Joe with a proper lore.kernel.org hyperlink.

Just send out your PATCH v2, then we can all review and test it.

When we have this patch accepted, we can discuss with Joe some way to handle the further cases of false warnings in AUTHOR_SIGN_OFF.

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

#3 lore raw
In reply to Dwaipayan Ray
Quoted 8 lines · Dwaipayan Ray

Checkpatch did not handle cases where the author From: header was split into multiple lines. The author identity could not be resolved and checkpatch generated a false NO_AUTHOR_SIGN_OFF warning.

Support split From: headers in AUTHOR_SIGN_OFF check by correctly parsing the entire From: header in such cases.

Looks good to me.

Maybe you can some examples that are now handled better, typical cases of the different classes and a summary on your evaluation in the commit message.

Do that and send out the PATCH v2 to the linux-kernel mailing list with the typical recipients.

Lukas

Quoted 24 lines
---
 scripts/checkpatch.pl | 4 ++++
 1 file changed, 4 insertions(+)
scripts/checkpatch.pl +4 -0
index 504d2e431c60..8ee61ec346b3 100755
@@ -2661,6 +2661,10 @@ sub process {
 # Check the patch for a From:
 		if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
 			$author = $1;
+			my $curline = $linenr-1;
+			while(defined($rawlines[++$curline]) && ($rawlines[$curline] =~ /^\s+(.*)/)) {
+				$author.= $1;
+			}
 			$author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
 			$author =~ s/"//g;
 			$author = reformat_email($author);
Signature · 1 line
2.27.0

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