Re: [PATCH] checkpatch: add fix option for MISSING_SIGN_OFF

From: Joe Perches
Date: Tue Nov 10 2020 - 15:19:56 EST


On Wed, 2020-11-11 at 00:36 +0530, Aditya Srivastava wrote:
> Currently checkpatch warns us if there is no 'Signed-off-by' line
> for the patch.

trivial style and a comment:

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2755,6 +2757,10 @@ sub process {
>   if ($line =~ /^---$/) {
>   $has_patch_separator = 1;
>   $in_commit_log = 0;
> + # to add missing sign off line before diff(s)
> + if($patch_separator_linenr == 0) {

space after if

> + $patch_separator_linenr = $linenr;
> + }
[]
> @@ -7118,9 +7127,12 @@ sub process {
>   "Does not appear to be a unified-diff format patch\n");
>   }
>   if ($is_patch && $has_commit_log && $chk_signoff) {
> - if ($signoff == 0) {
> - ERROR("MISSING_SIGN_OFF",
> - "Missing Signed-off-by: line(s)\n");
> + if ($signoff == 0 && !$non_standard_signature) {
> + if (ERROR("MISSING_SIGN_OFF",
> + "Missing Signed-off-by: line(s)\n") &&
> + $fix) {
> + fix_insert_line($patch_separator_linenr - 1, "Signed-off-by: $author");

Perhaps this needs to test $patch_separator_linenr to
make sure it's not 0.