Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-12 Thread Geert Uytterhoeven
Hi Joe,

On Wed, Jul 11, 2018 at 7:24 PM Joe Perches  wrote:
> On Wed, 2018-07-11 at 19:07 +0200, Geert Uytterhoeven wrote:
> > On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> > > On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > > > Print a warning if none of the Signed-off-by lines cover the patch
> > > > author.
> > > >
> > > > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > > > double quotes are handled.
> > > > Split From: headers are not fully handled: only the first part is
> > > > compared.
> > >
> > > []
> > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > >
> > > []
> > > > +# Check the patch for a From:
> > > > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > > > + $author = encode("utf8", $1);
> > > > + $author =~ s/"//g;
> > > > + }
> > > > +
> > > >  # Check the patch for a signoff:
> > > >   if ($line =~ /^\s*signed-off-by:/i) {
> > > >   $signoff++;
> > > >   $in_commit_log = 0;
> > > > + if ($author ne '') {
> > > > + my $l = $line;
> > > > + $l =~ s/"//g;
> > > > + if ($l =~ /^\s*signed-off-by: 
> > > > \Q$author\E/i) {
>
> if (/^\s*signed-off-by:\s*\Q$author\E/i)

Dropping the "$l =~" doesn't fly.
The "\s*" part does work.

> > > > + $authorsignoff = 1;
> > > > + }
> > > > + }
> > > >   }
> > >
> > > I don't see the point of removing the quotes.
> >
> > If the name contains a dot (e.g. "David S. Miller"), it must be protected
> > by double quotes in the From: email header, but that is usually not the case
> > in the Sob line.
>
> Right.
> It seems it's unusual for SOBs to use quotes around names.

But it does happen from time to time.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-12 Thread Geert Uytterhoeven
Hi Joe,

On Wed, Jul 11, 2018 at 7:24 PM Joe Perches  wrote:
> On Wed, 2018-07-11 at 19:07 +0200, Geert Uytterhoeven wrote:
> > On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> > > On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > > > Print a warning if none of the Signed-off-by lines cover the patch
> > > > author.
> > > >
> > > > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > > > double quotes are handled.
> > > > Split From: headers are not fully handled: only the first part is
> > > > compared.
> > >
> > > []
> > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > >
> > > []
> > > > +# Check the patch for a From:
> > > > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > > > + $author = encode("utf8", $1);
> > > > + $author =~ s/"//g;
> > > > + }
> > > > +
> > > >  # Check the patch for a signoff:
> > > >   if ($line =~ /^\s*signed-off-by:/i) {
> > > >   $signoff++;
> > > >   $in_commit_log = 0;
> > > > + if ($author ne '') {
> > > > + my $l = $line;
> > > > + $l =~ s/"//g;
> > > > + if ($l =~ /^\s*signed-off-by: 
> > > > \Q$author\E/i) {
>
> if (/^\s*signed-off-by:\s*\Q$author\E/i)

Dropping the "$l =~" doesn't fly.
The "\s*" part does work.

> > > > + $authorsignoff = 1;
> > > > + }
> > > > + }
> > > >   }
> > >
> > > I don't see the point of removing the quotes.
> >
> > If the name contains a dot (e.g. "David S. Miller"), it must be protected
> > by double quotes in the From: email header, but that is usually not the case
> > in the Sob line.
>
> Right.
> It seems it's unusual for SOBs to use quotes around names.

But it does happen from time to time.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Joe Perches
On Wed, 2018-07-11 at 19:07 +0200, Geert Uytterhoeven wrote:
> Hi Joe,

Rehi Geert.

> On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> > On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > > Print a warning if none of the Signed-off-by lines cover the patch
> > > author.
> > > 
> > > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > > double quotes are handled.
> > > Split From: headers are not fully handled: only the first part is
> > > compared.
> > 
> > []
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > 
> > []
> > > +# Check the patch for a From:
> > > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > > + $author = encode("utf8", $1);
> > > + $author =~ s/"//g;
> > > + }
> > > +
> > >  # Check the patch for a signoff:
> > >   if ($line =~ /^\s*signed-off-by:/i) {
> > >   $signoff++;
> > >   $in_commit_log = 0;
> > > + if ($author ne '') {
> > > + my $l = $line;
> > > + $l =~ s/"//g;
> > > + if ($l =~ /^\s*signed-off-by: 
> > > \Q$author\E/i) {

if (/^\s*signed-off-by:\s*\Q$author\E/i)

> > > + $authorsignoff = 1;
> > > + }
> > > + }
> > >   }
> > 
> > I don't see the point of removing the quotes.
> 
> If the name contains a dot (e.g. "David S. Miller"), it must be protected
> by double quotes in the From: email header, but that is usually not the case
> in the Sob line.

Right.
It seems it's unusual for SOBs to use quotes around names.

> > Another somewhat frequent Signed-off-by: defect pattern
> > is to have a lower-case name or no name at all used.
> > 
> > Perhaps it'd be useful to add some checks like
> > a single word for a name and all lower-case names:
> > 
> > e.g.:
> > Signed-off-by: joe perches 
> > 
> > emits
> > 
> > Unusual lower case name: 'joe perches '
> > 
> > and
> > Signed-off-by: root 
> > and
> > Signed-off-by: Root 
> > and
> > Signed-off-by: r...@mydomain.net
> > 
> > all emit that a single or missing name is unusual.
> 
> Perhaps. But adding email addresses is not the topic of this patch.

Just another possible improvement if you're feeling energetic.

cheers, Joe


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Joe Perches
On Wed, 2018-07-11 at 19:07 +0200, Geert Uytterhoeven wrote:
> Hi Joe,

Rehi Geert.

> On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> > On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > > Print a warning if none of the Signed-off-by lines cover the patch
> > > author.
> > > 
> > > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > > double quotes are handled.
> > > Split From: headers are not fully handled: only the first part is
> > > compared.
> > 
> > []
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > 
> > []
> > > +# Check the patch for a From:
> > > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > > + $author = encode("utf8", $1);
> > > + $author =~ s/"//g;
> > > + }
> > > +
> > >  # Check the patch for a signoff:
> > >   if ($line =~ /^\s*signed-off-by:/i) {
> > >   $signoff++;
> > >   $in_commit_log = 0;
> > > + if ($author ne '') {
> > > + my $l = $line;
> > > + $l =~ s/"//g;
> > > + if ($l =~ /^\s*signed-off-by: 
> > > \Q$author\E/i) {

if (/^\s*signed-off-by:\s*\Q$author\E/i)

> > > + $authorsignoff = 1;
> > > + }
> > > + }
> > >   }
> > 
> > I don't see the point of removing the quotes.
> 
> If the name contains a dot (e.g. "David S. Miller"), it must be protected
> by double quotes in the From: email header, but that is usually not the case
> in the Sob line.

Right.
It seems it's unusual for SOBs to use quotes around names.

> > Another somewhat frequent Signed-off-by: defect pattern
> > is to have a lower-case name or no name at all used.
> > 
> > Perhaps it'd be useful to add some checks like
> > a single word for a name and all lower-case names:
> > 
> > e.g.:
> > Signed-off-by: joe perches 
> > 
> > emits
> > 
> > Unusual lower case name: 'joe perches '
> > 
> > and
> > Signed-off-by: root 
> > and
> > Signed-off-by: Root 
> > and
> > Signed-off-by: r...@mydomain.net
> > 
> > all emit that a single or missing name is unusual.
> 
> Perhaps. But adding email addresses is not the topic of this patch.

Just another possible improvement if you're feeling energetic.

cheers, Joe


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Geert Uytterhoeven
Hi Joe,

On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > Print a warning if none of the Signed-off-by lines cover the patch
> > author.
> >
> > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > double quotes are handled.
> > Split From: headers are not fully handled: only the first part is
> > compared.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > +# Check the patch for a From:
> > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > + $author = encode("utf8", $1);
> > + $author =~ s/"//g;
> > + }
> > +
> >  # Check the patch for a signoff:
> >   if ($line =~ /^\s*signed-off-by:/i) {
> >   $signoff++;
> >   $in_commit_log = 0;
> > + if ($author ne '') {
> > + my $l = $line;
> > + $l =~ s/"//g;
> > + if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
> > + $authorsignoff = 1;
> > + }
> > + }
> >   }
>
> I don't see the point of removing the quotes.

If the name contains a dot (e.g. "David S. Miller"), it must be protected
by double quotes in the From: email header, but that is usually not the case
in the Sob line.

> If the name and email address don't exactly match,
> why shouldn't it be reported?

It's still the same email address.

> >  # Check if MAINTAINERS is being updated.  If so, there's probably no need 
> > to
> > @@ -6487,9 +6503,14 @@ sub process {
> >   ERROR("NOT_UNIFIED_DIFF",
> > "Does not appear to be a unified-diff format patch\n");
> >   }
> > - if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
> > - ERROR("MISSING_SIGN_OFF",
> > -   "Missing Signed-off-by: line(s)\n");
> > + if ($is_patch && $has_commit_log && $chk_signoff) {
> > + if ($signoff == 0) {
> > + ERROR("MISSING_SIGN_OFF",
> > +   "Missing Signed-off-by: line(s)\n");
> > + } elsif (!$authorsignoff) {
> > + WARN("NO_AUTHOR_SIGN_OFF",
> > +  "Missing Signed-off-by: line by patch author\n");
>
> Perhaps better to show the From: line author
>
> "Missing 'Signed-off-by:' from nomimal patch author 
> '$author'\n");

OK.

> Another somewhat frequent Signed-off-by: defect pattern
> is to have a lower-case name or no name at all used.
>
> Perhaps it'd be useful to add some checks like
> a single word for a name and all lower-case names:
>
> e.g.:
> Signed-off-by: joe perches 
>
> emits
>
> Unusual lower case name: 'joe perches '
>
> and
> Signed-off-by: root 
> and
> Signed-off-by: Root 
> and
> Signed-off-by: r...@mydomain.net
>
> all emit that a single or missing name is unusual.

Perhaps. But adding email addresses is not the topic of this patch.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Geert Uytterhoeven
Hi Joe,

On Wed, Jul 11, 2018 at 6:20 PM Joe Perches  wrote:
> On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> > Print a warning if none of the Signed-off-by lines cover the patch
> > author.
> >
> > Non-ASCII quoted printable encoding in From: headers and (lack of)
> > double quotes are handled.
> > Split From: headers are not fully handled: only the first part is
> > compared.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > +# Check the patch for a From:
> > + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> > + $author = encode("utf8", $1);
> > + $author =~ s/"//g;
> > + }
> > +
> >  # Check the patch for a signoff:
> >   if ($line =~ /^\s*signed-off-by:/i) {
> >   $signoff++;
> >   $in_commit_log = 0;
> > + if ($author ne '') {
> > + my $l = $line;
> > + $l =~ s/"//g;
> > + if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
> > + $authorsignoff = 1;
> > + }
> > + }
> >   }
>
> I don't see the point of removing the quotes.

If the name contains a dot (e.g. "David S. Miller"), it must be protected
by double quotes in the From: email header, but that is usually not the case
in the Sob line.

> If the name and email address don't exactly match,
> why shouldn't it be reported?

It's still the same email address.

> >  # Check if MAINTAINERS is being updated.  If so, there's probably no need 
> > to
> > @@ -6487,9 +6503,14 @@ sub process {
> >   ERROR("NOT_UNIFIED_DIFF",
> > "Does not appear to be a unified-diff format patch\n");
> >   }
> > - if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
> > - ERROR("MISSING_SIGN_OFF",
> > -   "Missing Signed-off-by: line(s)\n");
> > + if ($is_patch && $has_commit_log && $chk_signoff) {
> > + if ($signoff == 0) {
> > + ERROR("MISSING_SIGN_OFF",
> > +   "Missing Signed-off-by: line(s)\n");
> > + } elsif (!$authorsignoff) {
> > + WARN("NO_AUTHOR_SIGN_OFF",
> > +  "Missing Signed-off-by: line by patch author\n");
>
> Perhaps better to show the From: line author
>
> "Missing 'Signed-off-by:' from nomimal patch author 
> '$author'\n");

OK.

> Another somewhat frequent Signed-off-by: defect pattern
> is to have a lower-case name or no name at all used.
>
> Perhaps it'd be useful to add some checks like
> a single word for a name and all lower-case names:
>
> e.g.:
> Signed-off-by: joe perches 
>
> emits
>
> Unusual lower case name: 'joe perches '
>
> and
> Signed-off-by: root 
> and
> Signed-off-by: Root 
> and
> Signed-off-by: r...@mydomain.net
>
> all emit that a single or missing name is unusual.

Perhaps. But adding email addresses is not the topic of this patch.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Joe Perches
On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> Print a warning if none of the Signed-off-by lines cover the patch
> author.
> 
> Non-ASCII quoted printable encoding in From: headers and (lack of)
> double quotes are handled.
> Split From: headers are not fully handled: only the first part is
> compared.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +# Check the patch for a From:
> + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> + $author = encode("utf8", $1);
> + $author =~ s/"//g;
> + }
> +
>  # Check the patch for a signoff:
>   if ($line =~ /^\s*signed-off-by:/i) {
>   $signoff++;
>   $in_commit_log = 0;
> + if ($author ne '') {
> + my $l = $line;
> + $l =~ s/"//g;
> + if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
> + $authorsignoff = 1;
> + }
> + }
>   }

I don't see the point of removing the quotes.

If the name and email address don't exactly match,
why shouldn't it be reported?

>  # Check if MAINTAINERS is being updated.  If so, there's probably no need to
> @@ -6487,9 +6503,14 @@ sub process {
>   ERROR("NOT_UNIFIED_DIFF",
> "Does not appear to be a unified-diff format patch\n");
>   }
> - if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
> - ERROR("MISSING_SIGN_OFF",
> -   "Missing Signed-off-by: line(s)\n");
> + if ($is_patch && $has_commit_log && $chk_signoff) {
> + if ($signoff == 0) {
> + ERROR("MISSING_SIGN_OFF",
> +   "Missing Signed-off-by: line(s)\n");
> + } elsif (!$authorsignoff) {
> + WARN("NO_AUTHOR_SIGN_OFF",
> +  "Missing Signed-off-by: line by patch author\n");

Perhaps better to show the From: line author

"Missing 'Signed-off-by:' from nomimal patch author 
'$author'\n");

Another somewhat frequent Signed-off-by: defect pattern
is to have a lower-case name or no name at all used.

Perhaps it'd be useful to add some checks like
a single word for a name and all lower-case names:

e.g.:
Signed-off-by: joe perches 

emits

Unusual lower case name: 'joe perches '

and
Signed-off-by: root 
and
Signed-off-by: Root 
and
Signed-off-by: r...@mydomain.net

all emit that a single or missing name is unusual.



Re: [PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Joe Perches
On Wed, 2018-07-11 at 17:10 +0200, Geert Uytterhoeven wrote:
> Print a warning if none of the Signed-off-by lines cover the patch
> author.
> 
> Non-ASCII quoted printable encoding in From: headers and (lack of)
> double quotes are handled.
> Split From: headers are not fully handled: only the first part is
> compared.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +# Check the patch for a From:
> + if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> + $author = encode("utf8", $1);
> + $author =~ s/"//g;
> + }
> +
>  # Check the patch for a signoff:
>   if ($line =~ /^\s*signed-off-by:/i) {
>   $signoff++;
>   $in_commit_log = 0;
> + if ($author ne '') {
> + my $l = $line;
> + $l =~ s/"//g;
> + if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
> + $authorsignoff = 1;
> + }
> + }
>   }

I don't see the point of removing the quotes.

If the name and email address don't exactly match,
why shouldn't it be reported?

>  # Check if MAINTAINERS is being updated.  If so, there's probably no need to
> @@ -6487,9 +6503,14 @@ sub process {
>   ERROR("NOT_UNIFIED_DIFF",
> "Does not appear to be a unified-diff format patch\n");
>   }
> - if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
> - ERROR("MISSING_SIGN_OFF",
> -   "Missing Signed-off-by: line(s)\n");
> + if ($is_patch && $has_commit_log && $chk_signoff) {
> + if ($signoff == 0) {
> + ERROR("MISSING_SIGN_OFF",
> +   "Missing Signed-off-by: line(s)\n");
> + } elsif (!$authorsignoff) {
> + WARN("NO_AUTHOR_SIGN_OFF",
> +  "Missing Signed-off-by: line by patch author\n");

Perhaps better to show the From: line author

"Missing 'Signed-off-by:' from nomimal patch author 
'$author'\n");

Another somewhat frequent Signed-off-by: defect pattern
is to have a lower-case name or no name at all used.

Perhaps it'd be useful to add some checks like
a single word for a name and all lower-case names:

e.g.:
Signed-off-by: joe perches 

emits

Unusual lower case name: 'joe perches '

and
Signed-off-by: root 
and
Signed-off-by: Root 
and
Signed-off-by: r...@mydomain.net

all emit that a single or missing name is unusual.



[PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Geert Uytterhoeven
Print a warning if none of the Signed-off-by lines cover the patch
author.

Non-ASCII quoted printable encoding in From: headers and (lack of)
double quotes are handled.
Split From: headers are not fully handled: only the first part is
compared.

Signed-off-by: Geert Uytterhoeven 
---
Tested using a set of ca. 4000 real world commits.

Most common offenders are people using:
  - different email addresses for author and Sob,
  - different firstname/lastname order, or other different name
spelling,
  - suse.de vs. suse.com.

v2:
  - Use "Encode" instead of "MIME::Words", as the former is a Perl core
module,
  - Reduce level from error to warning.
---
 scripts/checkpatch.pl | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8d0bad190c25e2e0..9ad674516502c7e8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -13,6 +13,7 @@ use POSIX;
 use File::Basename;
 use Cwd 'abs_path';
 use Term::ANSIColor qw(:constants);
+use Encode qw(decode encode);
 
 my $P = $0;
 my $D = dirname(abs_path($P));
@@ -2236,6 +2237,8 @@ sub process {
 
our $clean = 1;
my $signoff = 0;
+   my $author = '';
+   my $authorsignoff = 0;
my $is_patch = 0;
my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0;  #Scanning lines before patch
@@ -2518,10 +2521,23 @@ sub process {
}
}
 
+# Check the patch for a From:
+   if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
+   $author = encode("utf8", $1);
+   $author =~ s/"//g;
+   }
+
 # Check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) {
$signoff++;
$in_commit_log = 0;
+   if ($author ne '') {
+   my $l = $line;
+   $l =~ s/"//g;
+   if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
+   $authorsignoff = 1;
+   }
+   }
}
 
 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
@@ -6487,9 +6503,14 @@ sub process {
ERROR("NOT_UNIFIED_DIFF",
  "Does not appear to be a unified-diff format patch\n");
}
-   if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
-   ERROR("MISSING_SIGN_OFF",
- "Missing Signed-off-by: line(s)\n");
+   if ($is_patch && $has_commit_log && $chk_signoff) {
+   if ($signoff == 0) {
+   ERROR("MISSING_SIGN_OFF",
+ "Missing Signed-off-by: line(s)\n");
+   } elsif (!$authorsignoff) {
+   WARN("NO_AUTHOR_SIGN_OFF",
+"Missing Signed-off-by: line by patch author\n");
+   }
}
 
print report_dump();
-- 
2.17.1



[PATCH v2] checkpatch: Warn if missing author Signed-off-by

2018-07-11 Thread Geert Uytterhoeven
Print a warning if none of the Signed-off-by lines cover the patch
author.

Non-ASCII quoted printable encoding in From: headers and (lack of)
double quotes are handled.
Split From: headers are not fully handled: only the first part is
compared.

Signed-off-by: Geert Uytterhoeven 
---
Tested using a set of ca. 4000 real world commits.

Most common offenders are people using:
  - different email addresses for author and Sob,
  - different firstname/lastname order, or other different name
spelling,
  - suse.de vs. suse.com.

v2:
  - Use "Encode" instead of "MIME::Words", as the former is a Perl core
module,
  - Reduce level from error to warning.
---
 scripts/checkpatch.pl | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8d0bad190c25e2e0..9ad674516502c7e8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -13,6 +13,7 @@ use POSIX;
 use File::Basename;
 use Cwd 'abs_path';
 use Term::ANSIColor qw(:constants);
+use Encode qw(decode encode);
 
 my $P = $0;
 my $D = dirname(abs_path($P));
@@ -2236,6 +2237,8 @@ sub process {
 
our $clean = 1;
my $signoff = 0;
+   my $author = '';
+   my $authorsignoff = 0;
my $is_patch = 0;
my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0;  #Scanning lines before patch
@@ -2518,10 +2521,23 @@ sub process {
}
}
 
+# Check the patch for a From:
+   if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
+   $author = encode("utf8", $1);
+   $author =~ s/"//g;
+   }
+
 # Check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) {
$signoff++;
$in_commit_log = 0;
+   if ($author ne '') {
+   my $l = $line;
+   $l =~ s/"//g;
+   if ($l =~ /^\s*signed-off-by: \Q$author\E/i) {
+   $authorsignoff = 1;
+   }
+   }
}
 
 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
@@ -6487,9 +6503,14 @@ sub process {
ERROR("NOT_UNIFIED_DIFF",
  "Does not appear to be a unified-diff format patch\n");
}
-   if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
-   ERROR("MISSING_SIGN_OFF",
- "Missing Signed-off-by: line(s)\n");
+   if ($is_patch && $has_commit_log && $chk_signoff) {
+   if ($signoff == 0) {
+   ERROR("MISSING_SIGN_OFF",
+ "Missing Signed-off-by: line(s)\n");
+   } elsif (!$authorsignoff) {
+   WARN("NO_AUTHOR_SIGN_OFF",
+"Missing Signed-off-by: line by patch author\n");
+   }
}
 
print report_dump();
-- 
2.17.1