From a2d6e2ef6ed7d2d4c5cbdb857e38ecf6ccb9766c Mon Sep 17 00:00:00 2001 From: David Keitel Date: Wed, 23 Mar 2016 20:57:21 -0700 Subject: [PATCH 1/2] checkpatch: warn on subject line not followed by blank line Fixed case when no warning generated for long subject line that is wrapped to more than one line, and all lines are less than line limit. New warning message added: "non-blank line after summary line" Now there are two warnings possible for the subject line, the original line over limit and the new one. Depending on the error(s) any combination of the two warnings are possible. Commit text requirements now: 1) Must be less than 75 characters 2) Must be followed by blank line. Change-Id: Id28d7a2eee561a1b1f45e51e346be3868c1fbad5 Signed-off-by: David Keitel --- scripts/checkpatch.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 47cc17673b85..7552c7837a35 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -18,6 +18,7 @@ use Encode qw(decode encode); use constant BEFORE_SHORTTEXT => 0; use constant IN_SHORTTEXT => 1; use constant AFTER_SHORTTEXT => 2; +use constant CHECK_NEXT_SHORTTEXT => 3; use constant SHORTTEXT_LIMIT => 75; my $P = $0; @@ -2279,6 +2280,8 @@ sub process { my $prevrawline=""; my $stashline=""; my $stashrawline=""; + my $subjectline=""; + my $sublinenr=""; my $length; my $indent; @@ -2578,8 +2581,21 @@ sub process { SHORTTEXT_LIMIT . " characters\n" . $herecurr); } - } elsif ($line=~/^Subject: \[[^\]]*\] (.*)/) { + } elsif ($shorttext == CHECK_NEXT_SHORTTEXT) { $shorttext = IN_SHORTTEXT; +# Check for Subject line followed by a blank line. + if (length($line) != 0) { + WARN("NONBLANK_AFTER_SUMMARY", + "non-blank line after summary " . + "line\n" . $sublinenr . $here . + "\n" . $subjectline . "\n" . + $line . "\n"); + } + } elsif ($line=~/^Subject: \[[^\]]*\] (.*)/) { + $shorttext = CHECK_NEXT_SHORTTEXT; + $subjectline = $line; + $sublinenr = "#$linenr & "; +# Check for Subject line less than line limit if (length($1) > SHORTTEXT_LIMIT) { WARN("LONG_SUMMARY_LINE", "summary line over " . From a8c5a946e90aa5d0f566538ff8c8c40fed66e03e Mon Sep 17 00:00:00 2001 From: Gregory Bean Date: Thu, 3 Mar 2011 13:46:41 -0800 Subject: [PATCH 2/2] checkpatch: Don't complain about MIME headers. When patches contain extended character sets, patches will contain MIME headers after the subject line, which should not be confused for a too-long summary line. Change-Id: I66f70b465ef804444a3bdb49867654b5613b13a7 Signed-off-by: Gregory Bean (cherry picked from commit 8e6b9d3790595198a34320f1c3f4504cd258fed1) Signed-off-by: Stepan Moskovchenko Signed-off-by: Rishabh Bhatnagar --- scripts/checkpatch.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7552c7837a35..0ddcbf0f56c0 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2582,14 +2582,21 @@ sub process { " characters\n" . $herecurr); } } elsif ($shorttext == CHECK_NEXT_SHORTTEXT) { - $shorttext = IN_SHORTTEXT; +# The Subject line doesn't have to be the last header in the patch. +# Avoid moving to the IN_SHORTTEXT state until clear of all headers. +# Per RFC5322, continuation lines must be folded, so any left-justified +# text which looks like a header is definitely a header. + if ($line!~/^[\x21-\x39\x3b-\x7e]+:/) { + $shorttext = IN_SHORTTEXT; # Check for Subject line followed by a blank line. - if (length($line) != 0) { - WARN("NONBLANK_AFTER_SUMMARY", - "non-blank line after summary " . - "line\n" . $sublinenr . $here . - "\n" . $subjectline . "\n" . - $line . "\n"); + if (length($line) != 0) { + WARN("NONBLANK_AFTER_SUMMARY", + "non-blank line after " . + "summary line\n" . + $sublinenr . $here . + "\n" . $subjectline . + "\n" . $line . "\n"); + } } } elsif ($line=~/^Subject: \[[^\]]*\] (.*)/) { $shorttext = CHECK_NEXT_SHORTTEXT;