On Mo., 9. Nov. 2020 at 14:10, Aditya Srivastava <yashsri421@gmail.com> wrote:
Currently checkpatch warns us if there is no 'Signed-off-by' line
for the patch.

E.g., running checkpatch on commit f68e7927212f ("Revert
"powerpc/book3s32: Reorder _PAGE_XXX flags to simplify TLB handling"")
reports this error:

ERROR: Missing Signed-off-by: line(s)

Provide a fix by adding a Signed-off-by line corresponding to the author
of the patch before the start of diff(s)

Can you please provide an evaluation first?

As far as remember, the fix is often not to add a Signed-off-by: tag but it requires something completely different.

Lukas


Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Aditya Srivastava <yashsri421@gmail.com>
---
 scripts/checkpatch.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index cb46288127ac..bc447aa4e5b0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2404,6 +2404,7 @@ sub process {

        my $last_blank_line = 0;
        my $last_coalesced_string_linenr = -1;
+       my $diff_linenr = 0;

        our @report = ();
        our $cnt_lines = 0;
@@ -2602,6 +2603,10 @@ sub process {
                        $realfile =~ s@^([^/]*)/@@ if (!$file);
                        $in_commit_log = 0;
                        $found_file = 1;
+                       # to add missing sign off line before diff(s)
+                       if($diff_linenr == 0) {
+                               $diff_linenr = $fixlinenr;
+                       }
                } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
                        $realfile = $1;
                        $realfile =~ s@^([^/]*)/@@ if (!$file);
@@ -7119,8 +7124,11 @@ sub process {
        }
        if ($is_patch && $has_commit_log && $chk_signoff) {
                if ($signoff == 0) {
-                       ERROR("MISSING_SIGN_OFF",
-                             "Missing Signed-off-by: line(s)\n");
+                       if (ERROR("MISSING_SIGN_OFF",
+                                 "Missing Signed-off-by: line(s)\n") &&
+                           $fix) {
+                               fix_insert_line($diff_linenr, "Signed-off-by: $author\n");
+                       }
                } elsif ($authorsignoff != 1) {
                        # authorsignoff values:
                        # 0 -> missing sign off
--
2.17.1