Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932828AbdCUQbo (ORCPT ); Tue, 21 Mar 2017 12:31:44 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:52790 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757892AbdCUQak (ORCPT ); Tue, 21 Mar 2017 12:30:40 -0400 From: "John 'Warthog9' Hawley (VMware)" To: linux-kernel@vger.kernel.org Cc: Joe Perches , Andy Whitcroft , "Darren Hart (VMware)" , "John 'Warthog9' Hawley (VMware)" Subject: [PATCH] checkpatch: Flag spam header (X-Spam-Report) to prevent spurious warnings Date: Tue, 21 Mar 2017 09:30:05 -0700 Message-Id: <1490113805-9295-1-git-send-email-warthog9@eaglescrag.net> X-Mailer: git-send-email 2.5.5 X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 21 Mar 2017 09:30:39 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2231 Lines: 61 Spamassassin sticks a long (~79 character) long string after a line that has a single space in it. The line with space causes checkpatch to erroniously think that it's in the content body, as opposed to headers and thus flag a mail header as an unwrapped long comment line. This flags when X-Spam-Report is found, till an e-mail body indicator (blank line, /^[/n/r]*/) is found, blocking setting $in_commit_log. When found, unsets itself allowing the rest of the detection to function normally. Reported-by: Darren Hart (VMware) Signed-off-by: John 'Warthog9' Hawley (VMware) --- scripts/checkpatch.pl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index baa3c7b..d2ce89a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2134,6 +2134,7 @@ sub process { my $signoff = 0; my $is_patch = 0; my $in_header_lines = $file ? 0 : 1; + my $found_spam_header = 0; my $in_commit_log = 0; #Scanning lines before patch my $has_commit_log = 0; #Encountered lines before patch my $commit_log_possible_stack_dump = 0; @@ -2279,6 +2280,12 @@ sub process { my $rawline = $rawlines[$linenr - 1]; +#if we encounter a spamassassin mail header, mark it + if ($in_header_lines == 1 && $line =~ /^X-Spam-Report:/) { + #mail header found, this needs to be flagged + $found_spam_header = 1; + } + #extract the line range in the file after the patch is applied if (!$in_commit_log && $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@/) { @@ -2627,9 +2634,15 @@ 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 && $found_spam_header && $line =~ /^[\n\r]*$/) { + # we are now past the header info that could be confusing + $found_spam_header = 0; + } + if ($in_header_lines && $realfile =~ /^$/ && !($rawline =~ /^\s+\S/ || - $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) { + $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i) && + !$found_spam_header) { $in_header_lines = 0; $in_commit_log = 1; $has_commit_log = 1; -- 2.5.5