Skip to content

Commit 270c49a

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: update signature "might be better as" warning
email header lines can look like signature tags. It's valid to have multiple email recipients on a single line but not valid to have multiple signatures on a single line. Validate signatures only when not in the email headers. Clear the $in_commit_log flag when the patch filename appears. Add '-' to the valid chars in a message header for headers like "Message-Id:" and "In-Reply-To:". Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 96b6206 commit 270c49a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

scripts/checkpatch.pl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,9 +1504,11 @@ sub process {
15041504
if ($line =~ /^diff --git.*?(\S+)$/) {
15051505
$realfile = $1;
15061506
$realfile =~ s@^([^/]*)/@@;
1507+
$in_commit_log = 0;
15071508
} elsif ($line =~ /^\+\+\+\s+(\S+)/) {
15081509
$realfile = $1;
15091510
$realfile =~ s@^([^/]*)/@@;
1511+
$in_commit_log = 0;
15101512

15111513
$p1_prefix = $1;
15121514
if (!$file && $tree && $p1_prefix ne '' &&
@@ -1546,7 +1548,8 @@ sub process {
15461548
}
15471549

15481550
# Check signature styles
1549-
if ($line =~ /^(\s*)($signature_tags)(\s*)(.*)/) {
1551+
if (!$in_header_lines &&
1552+
$line =~ /^(\s*)($signature_tags)(\s*)(.*)/) {
15501553
my $space_before = $1;
15511554
my $sign_off = $2;
15521555
my $space_after = $3;
@@ -1623,7 +1626,7 @@ sub process {
16231626
# Check if it's the start of a commit log
16241627
# (not a header line and we haven't seen the patch filename)
16251628
if ($in_header_lines && $realfile =~ /^$/ &&
1626-
$rawline !~ /^(commit\b|from\b|\w+:).+$/i) {
1629+
$rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) {
16271630
$in_header_lines = 0;
16281631
$in_commit_log = 1;
16291632
}

0 commit comments

Comments
 (0)