All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check
@ 2018-04-19  9:11 Stefan Hajnoczi
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs Stefan Hajnoczi
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

This series cherry picks checkpatch UTF-8 fixes and the MAINTAINERS file check
from Linux.  Thomas Huth original did the backport in January 2017 but the
series was forgotten (<1485436265-12573-1-git-send-email-thuth@redhat.com>).  I
did the cherry pick again from scratch.

The MAINTAINERS file check prints a warning when new files are added without a
modification to ./MAINTAINERS.  It is easy to forget to update ./MAINTAINERS
and this check should help us stay on top of new source files.

Joe Perches (4):
  checkpatch: add a --strict check for utf-8 in commit logs
  checkpatch: ignore email headers better
  checkpatch: emit a warning on file add/move/delete
  checkpatch: reduce MAINTAINERS update message frequency

Pasi Savanainen (1):
  checkpatch: check utf-8 content from a commit log when it's missing
    from charset

 scripts/checkpatch.pl | 58 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)

-- 
2.14.3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
@ 2018-04-19  9:11 ` Stefan Hajnoczi
  2018-04-19 10:04   ` Thomas Huth
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset Stefan Hajnoczi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

From: Joe Perches <joe@perches.com>

Some find using utf-8 in commit logs inappropriate.

Some patch commit logs contain unintended utf-8 characters when doing
things like copy/pasting compilation output.

Look for the start of any commit log by skipping initial lines that look
like email headers and "From: " lines.

Stop looking for utf-8 at the first signature line.

Signed-off-by: Joe Perches <joe@perches.com>
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Whitcroft <apw@shadowen.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 15662b3e8644905032c2e26808401a487d4e90c1)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/checkpatch.pl | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d52207a3cc..2d28db03a0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -224,9 +224,8 @@ our $NonptrType;
 our $Type;
 our $Declare;
 
-our $UTF8	= qr {
-	[\x09\x0A\x0D\x20-\x7E]              # ASCII
-	| [\xC2-\xDF][\x80-\xBF]             # non-overlong 2-byte
+our $NON_ASCII_UTF8	= qr{
+	[\xC2-\xDF][\x80-\xBF]               # non-overlong 2-byte
 	|  \xE0[\xA0-\xBF][\x80-\xBF]        # excluding overlongs
 	| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}  # straight 3-byte
 	|  \xED[\x80-\x9F][\x80-\xBF]        # excluding surrogates
@@ -235,6 +234,11 @@ our $UTF8	= qr {
 	|  \xF4[\x80-\x8F][\x80-\xBF]{2}     # plane 16
 }x;
 
+our $UTF8	= qr{
+	[\x09\x0A\x0D\x20-\x7E]              # ASCII
+	| $NON_ASCII_UTF8
+}x;
+
 # There are still some false positives, but this catches most
 # common cases.
 our $typeTypedefs = qr{(?x:
@@ -1178,6 +1182,9 @@ sub process {
 	my $signoff = 0;
 	my $is_patch = 0;
 
+	my $in_header_lines = 1;
+	my $in_commit_log = 0;		#Scanning lines before patch
+
 	our @report = ();
 	our $cnt_lines = 0;
 	our $cnt_error = 0;
@@ -1330,7 +1337,6 @@ sub process {
 		if ($line =~ /^diff --git.*?(\S+)$/) {
 			$realfile = $1;
 			$realfile =~ s@^([^/]*)/@@;
-
 		} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
 			$realfile = $1;
 			$realfile =~ s@^([^/]*)/@@;
@@ -1369,6 +1375,8 @@ sub process {
 		if ($line =~ /^\s*signed-off-by:/i) {
 			# This is a signoff, if ugly, so do not double report.
 			$signoff++;
+			$in_commit_log = 0;
+
 			if (!($line =~ /^\s*Signed-off-by:/)) {
 				ERROR("The correct form is \"Signed-off-by\"\n" .
 					$herecurr);
@@ -1397,6 +1405,21 @@ sub process {
 			ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
 		}
 
+# Check if it's the start of a commit log
+# (not a header line and we haven't seen the patch filename)
+		if ($in_header_lines && $realfile =~ /^$/ &&
+		    $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
+			$in_header_lines = 0;
+			$in_commit_log = 1;
+		}
+
+# Still not yet in a patch, check for any UTF-8
+		if ($in_commit_log && $realfile =~ /^$/ &&
+		    $rawline =~ /$NON_ASCII_UTF8/) {
+			CHK("UTF8_BEFORE_PATCH",
+			    "8-bit UTF-8 used in possible commit log\n" . $herecurr);
+		}
+
 # ignore non-hunk lines and lines being removed
 		next if (!$hunk_line || $line =~ /^-/);
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs Stefan Hajnoczi
@ 2018-04-19  9:11 ` Stefan Hajnoczi
  2018-04-19 10:12   ` Thomas Huth
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better Stefan Hajnoczi
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

From: Pasi Savanainen <pasi.savanainen@nixu.com>

Check that a commit log doesn't contain UTF-8 when a mail header
explicitly defines a different charset, like

'Content-Type: text/plain; charset="us-ascii"'

Signed-off-by: Pasi Savanainen <pasi.savanainen@nixu.com>
Cc: Joe Perches <joe@perches.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit fa64205df9dfd7b7662cc64a7e82115c00e428e5)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/checkpatch.pl | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2d28db03a0..b2b088bab7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1185,6 +1185,8 @@ sub process {
 	my $in_header_lines = 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 
+	my $non_utf8_charset = 0;
+
 	our @report = ();
 	our $cnt_lines = 0;
 	our $cnt_error = 0;
@@ -1413,10 +1415,17 @@ sub process {
 			$in_commit_log = 1;
 		}
 
-# Still not yet in a patch, check for any UTF-8
-		if ($in_commit_log && $realfile =~ /^$/ &&
+# Check if there is UTF-8 in a commit log when a mail header has explicitly
+# declined it, i.e defined some charset where it is missing.
+		if ($in_header_lines &&
+		    $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&
+		    $1 !~ /utf-8/i) {
+			$non_utf8_charset = 1;
+		}
+
+		if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
 		    $rawline =~ /$NON_ASCII_UTF8/) {
-			CHK("UTF8_BEFORE_PATCH",
+			WARN("UTF8_BEFORE_PATCH",
 			    "8-bit UTF-8 used in possible commit log\n" . $herecurr);
 		}
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs Stefan Hajnoczi
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset Stefan Hajnoczi
@ 2018-04-19  9:11 ` Stefan Hajnoczi
  2018-04-19 10:14   ` Thomas Huth
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete Stefan Hajnoczi
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

From: Joe Perches <joe@perches.com>

There are some patches created by git format-patch that when scanned by
checkpatch report errors on lines like

To:	address.tld

This is a checkpatch false positive.

Improve the logic a bit to ignore folded email headers to avoid emitting
these messages.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 29ee1b0c67e0dd7dea8dd718e8326076bce5b6fe)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/checkpatch.pl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b2b088bab7..f3b166d5e2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1182,7 +1182,7 @@ sub process {
 	my $signoff = 0;
 	my $is_patch = 0;
 
-	my $in_header_lines = 1;
+	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
 
 	my $non_utf8_charset = 0;
@@ -1410,7 +1410,8 @@ sub process {
 # Check if it's the start of a commit log
 # (not a header line and we haven't seen the patch filename)
 		if ($in_header_lines && $realfile =~ /^$/ &&
-		    $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
+		    !($rawline =~ /^\s+\S/ ||
+		      $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) {
 			$in_header_lines = 0;
 			$in_commit_log = 1;
 		}
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
                   ` (2 preceding siblings ...)
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better Stefan Hajnoczi
@ 2018-04-19  9:11 ` Stefan Hajnoczi
  2018-04-19 10:15   ` Thomas Huth
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency Stefan Hajnoczi
  2018-04-19  9:21 ` [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check no-reply
  5 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

From: Joe Perches <joe@perches.com>

Whenever files are added, moved, or deleted, the MAINTAINERS file
patterns can be out of sync or outdated.

To try to keep MAINTAINERS more up-to-date, add a one-time warning
whenever a patch does any of those.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 13f1937ef33950b1112049972249e6191b82e6c9)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/checkpatch.pl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f3b166d5e2..95ba64f3a5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1184,7 +1184,7 @@ sub process {
 
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
-
+	my $reported_maintainer_file = 0;
 	my $non_utf8_charset = 0;
 
 	our @report = ();
@@ -1389,6 +1389,17 @@ sub process {
 			}
 		}
 
+# Check for added, moved or deleted files
+		if (!$reported_maintainer_file && !$in_commit_log &&
+		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
+		     $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ ||
+		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&
+		      (defined($1) || defined($2))))) {
+			$reported_maintainer_file = 1;
+			WARN("FILE_PATH_CHANGES",
+			     "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);
+		}
+
 # Check for wrappage within a valid hunk of the file
 		if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
 			ERROR("patch seems to be corrupt (line wrapped?)\n" .
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
                   ` (3 preceding siblings ...)
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete Stefan Hajnoczi
@ 2018-04-19  9:11 ` Stefan Hajnoczi
  2018-04-19 10:16   ` Thomas Huth
  2018-04-19  9:21 ` [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check no-reply
  5 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2018-04-19  9:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster,
	Thomas Huth, Fam Zheng

From: Joe Perches <joe@perches.com>

When files are being added/moved/deleted and a patch contains an update to
the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly
and do not emit the "does MAINTAINERS need updating?" message.

Reported by many people.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from e0d975b1b439c4fef58fbc306c542c94f48bb849)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 95ba64f3a5..1c20c683e8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1389,6 +1389,12 @@ sub process {
 			}
 		}
 
+# Check if MAINTAINERS is being updated.  If so, there's probably no need to
+# emit the "does MAINTAINERS need updating?" message on file add/move/delete
+		if ($line =~ /^\s*MAINTAINERS\s*\|/) {
+			$reported_maintainer_file = 1;
+		}
+
 # Check for added, moved or deleted files
 		if (!$reported_maintainer_file && !$in_commit_log &&
 		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check
  2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
                   ` (4 preceding siblings ...)
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency Stefan Hajnoczi
@ 2018-04-19  9:21 ` no-reply
  5 siblings, 0 replies; 12+ messages in thread
From: no-reply @ 2018-04-19  9:21 UTC (permalink / raw)
  To: stefanha; +Cc: famz, qemu-devel

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180419091105.3943-1-stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180419091105.3943-1-stefanha@redhat.com -> patchew/20180419091105.3943-1-stefanha@redhat.com
Switched to a new branch 'test'
77f2922cd7 checkpatch: reduce MAINTAINERS update message frequency
c5660effcb checkpatch: emit a warning on file add/move/delete
4f224ba569 checkpatch: ignore email headers better
8524202abe checkpatch: check utf-8 content from a commit log when it's missing from charset
dab42b2f0d checkpatch: add a --strict check for utf-8 in commit logs

=== OUTPUT BEGIN ===
Checking PATCH 1/5: checkpatch: add a --strict check for utf-8 in commit logs...
WARNING: line over 80 characters
#96: FILE: scripts/checkpatch.pl:1420:
+			    "8-bit UTF-8 used in possible commit log\n" . $herecurr);

total: 0 errors, 1 warnings, 67 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 2/5: checkpatch: check utf-8 content from a commit log when it's missing from charset...
Checking PATCH 3/5: checkpatch: ignore email headers better...
Checking PATCH 4/5: checkpatch: emit a warning on file add/move/delete...
WARNING: line over 80 characters
#41: FILE: scripts/checkpatch.pl:1396:
+		     ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ &&

ERROR: line over 90 characters
#45: FILE: scripts/checkpatch.pl:1400:
+			     "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr);

total: 1 errors, 1 warnings, 25 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 5/5: checkpatch: reduce MAINTAINERS update message frequency...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs Stefan Hajnoczi
@ 2018-04-19 10:04   ` Thomas Huth
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2018-04-19 10:04 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster, Fam Zheng

On 19.04.2018 11:11, Stefan Hajnoczi wrote:
> From: Joe Perches <joe@perches.com>
> 
> Some find using utf-8 in commit logs inappropriate.
> 
> Some patch commit logs contain unintended utf-8 characters when doing
> things like copy/pasting compilation output.
> 
> Look for the start of any commit log by skipping initial lines that look
> like email headers and "From: " lines.
> 
> Stop looking for utf-8 at the first signature line.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andy Whitcroft <apw@shadowen.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from commit 15662b3e8644905032c2e26808401a487d4e90c1)
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/checkpatch.pl | 31 +++++++++++++++++++++++++++----
>  1 file changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d52207a3cc..2d28db03a0 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
[...]
> @@ -1397,6 +1405,21 @@ sub process {
>  			ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr);
>  		}
>  
> +# Check if it's the start of a commit log
> +# (not a header line and we haven't seen the patch filename)
> +		if ($in_header_lines && $realfile =~ /^$/ &&
> +		    $rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
> +			$in_header_lines = 0;
> +			$in_commit_log = 1;
> +		}
> +
> +# Still not yet in a patch, check for any UTF-8
> +		if ($in_commit_log && $realfile =~ /^$/ &&
> +		    $rawline =~ /$NON_ASCII_UTF8/) {
> +			CHK("UTF8_BEFORE_PATCH",
> +			    "8-bit UTF-8 used in possible commit log\n" . $herecurr);
> +		}

As far as I can see, we don't have that CHK() function in our version of
checkpatch.pl yet, so you'd either have to turn that into a WARN or port
the CHK() function, too?

 Thomas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset Stefan Hajnoczi
@ 2018-04-19 10:12   ` Thomas Huth
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2018-04-19 10:12 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster, Fam Zheng

On 19.04.2018 11:11, Stefan Hajnoczi wrote:
> From: Pasi Savanainen <pasi.savanainen@nixu.com>
> 
> Check that a commit log doesn't contain UTF-8 when a mail header
> explicitly defines a different charset, like
> 
> 'Content-Type: text/plain; charset="us-ascii"'
> 
> Signed-off-by: Pasi Savanainen <pasi.savanainen@nixu.com>
> Cc: Joe Perches <joe@perches.com>
> Cc: Andy Whitcroft <apw@canonical.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from commit fa64205df9dfd7b7662cc64a7e82115c00e428e5)
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/checkpatch.pl | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 2d28db03a0..b2b088bab7 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1185,6 +1185,8 @@ sub process {
>  	my $in_header_lines = 1;
>  	my $in_commit_log = 0;		#Scanning lines before patch
>  
> +	my $non_utf8_charset = 0;
> +
>  	our @report = ();
>  	our $cnt_lines = 0;
>  	our $cnt_error = 0;
> @@ -1413,10 +1415,17 @@ sub process {
>  			$in_commit_log = 1;
>  		}
>  
> -# Still not yet in a patch, check for any UTF-8
> -		if ($in_commit_log && $realfile =~ /^$/ &&
> +# Check if there is UTF-8 in a commit log when a mail header has explicitly
> +# declined it, i.e defined some charset where it is missing.
> +		if ($in_header_lines &&
> +		    $rawline =~ /^Content-Type:.+charset="(.+)".*$/ &&

In my version of the patch, I removed the quotes:

https://patchwork.kernel.org/patch/9539231/

... but I guess I should likely follow up on that change with the kernel
folks first ...


> +		    $1 !~ /utf-8/i) {
> +			$non_utf8_charset = 1;
> +		}
> +
> +		if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ &&
>  		    $rawline =~ /$NON_ASCII_UTF8/) {
> -			CHK("UTF8_BEFORE_PATCH",
> +			WARN("UTF8_BEFORE_PATCH",
>  			    "8-bit UTF-8 used in possible commit log\n" . $herecurr);

Ah, here's the WARN instead of CHK ... in case you respin, you should do
that in the first patch already, I think.

In either case:

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better Stefan Hajnoczi
@ 2018-04-19 10:14   ` Thomas Huth
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2018-04-19 10:14 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster, Fam Zheng

On 19.04.2018 11:11, Stefan Hajnoczi wrote:
> From: Joe Perches <joe@perches.com>
> 
> There are some patches created by git format-patch that when scanned by
> checkpatch report errors on lines like
> 
> To:	address.tld
> 
> This is a checkpatch false positive.
> 
> Improve the logic a bit to ignore folded email headers to avoid emitting
> these messages.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from commit 29ee1b0c67e0dd7dea8dd718e8326076bce5b6fe)
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/checkpatch.pl | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete Stefan Hajnoczi
@ 2018-04-19 10:15   ` Thomas Huth
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2018-04-19 10:15 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster, Fam Zheng

On 19.04.2018 11:11, Stefan Hajnoczi wrote:
> From: Joe Perches <joe@perches.com>
> 
> Whenever files are added, moved, or deleted, the MAINTAINERS file
> patterns can be out of sync or outdated.
> 
> To try to keep MAINTAINERS more up-to-date, add a one-time warning
> whenever a patch does any of those.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Acked-by: Andy Whitcroft <apw@canonical.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from commit 13f1937ef33950b1112049972249e6191b82e6c9)
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/checkpatch.pl | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency
  2018-04-19  9:11 ` [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency Stefan Hajnoczi
@ 2018-04-19 10:16   ` Thomas Huth
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Huth @ 2018-04-19 10:16 UTC (permalink / raw)
  To: Stefan Hajnoczi, qemu-devel
  Cc: Marc-André Lureau, Peter Maydell, Markus Armbruster, Fam Zheng

On 19.04.2018 11:11, Stefan Hajnoczi wrote:
> From: Joe Perches <joe@perches.com>
> 
> When files are being added/moved/deleted and a patch contains an update to
> the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly
> and do not emit the "does MAINTAINERS need updating?" message.
> 
> Reported by many people.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> (cherry picked from e0d975b1b439c4fef58fbc306c542c94f48bb849)
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  scripts/checkpatch.pl | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 95ba64f3a5..1c20c683e8 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1389,6 +1389,12 @@ sub process {
>  			}
>  		}
>  
> +# Check if MAINTAINERS is being updated.  If so, there's probably no need to
> +# emit the "does MAINTAINERS need updating?" message on file add/move/delete
> +		if ($line =~ /^\s*MAINTAINERS\s*\|/) {
> +			$reported_maintainer_file = 1;
> +		}
> +
>  # Check for added, moved or deleted files
>  		if (!$reported_maintainer_file && !$in_commit_log &&
>  		    ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ ||
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-04-19 10:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-19  9:11 [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check Stefan Hajnoczi
2018-04-19  9:11 ` [Qemu-devel] [PATCH 1/5] checkpatch: add a --strict check for utf-8 in commit logs Stefan Hajnoczi
2018-04-19 10:04   ` Thomas Huth
2018-04-19  9:11 ` [Qemu-devel] [PATCH 2/5] checkpatch: check utf-8 content from a commit log when it's missing from charset Stefan Hajnoczi
2018-04-19 10:12   ` Thomas Huth
2018-04-19  9:11 ` [Qemu-devel] [PATCH 3/5] checkpatch: ignore email headers better Stefan Hajnoczi
2018-04-19 10:14   ` Thomas Huth
2018-04-19  9:11 ` [Qemu-devel] [PATCH 4/5] checkpatch: emit a warning on file add/move/delete Stefan Hajnoczi
2018-04-19 10:15   ` Thomas Huth
2018-04-19  9:11 ` [Qemu-devel] [PATCH 5/5] checkpatch: reduce MAINTAINERS update message frequency Stefan Hajnoczi
2018-04-19 10:16   ` Thomas Huth
2018-04-19  9:21 ` [Qemu-devel] [PATCH 0/5] checkpatch: backport UTF-8 fixes and MAINTAINERS check no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.