Commit 369c8dd3 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

checkpatch: improve tests for fixes:, long lines and stack dumps in commit log

Including BUG and stack dumps in commit logs makes checkpatch produce some
false positive warning messages.

checkpatch has multiple types of false positives:

o Commit message lines > 75 chars
o Stack dump address are mistaken for git commit IDs
o Link: and Fixes: lines are allowed to be > 75 chars.
o Fixes: style doesn't require ("<commit_description>")
  parentheses and double quotes like other uses of
  git commit ID and description.

Fix these.

Miscellanea:

o Move the test for checking $commit_log_possible_stack_dump
  above the test for a long line commit message
o Add test for hex address surrounded by square or angle brackets
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Reported-by: default avatarStephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9f029f54
...@@ -2313,6 +2313,16 @@ sub process { ...@@ -2313,6 +2313,16 @@ sub process {
"Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
} }
# Check if the commit log is in a possible stack dump
if ($in_commit_log && !$commit_log_possible_stack_dump &&
($line =~ /^\s*(?:WARNING:|BUG:)/ ||
$line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
# timestamp
$line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/)) {
# stack dump address
$commit_log_possible_stack_dump = 1;
}
# Check for line lengths > 75 in commit log, warn once # Check for line lengths > 75 in commit log, warn once
if ($in_commit_log && !$commit_log_long_line && if ($in_commit_log && !$commit_log_long_line &&
length($line) > 75 && length($line) > 75 &&
...@@ -2328,16 +2338,6 @@ sub process { ...@@ -2328,16 +2338,6 @@ sub process {
$commit_log_long_line = 1; $commit_log_long_line = 1;
} }
# Check if the commit log is in a possible stack dump
if ($in_commit_log && !$commit_log_possible_stack_dump &&
($line =~ /^\s*(?:WARNING:|BUG:)/ ||
$line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
# timestamp
$line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/)) {
# stack dump address
$commit_log_possible_stack_dump = 1;
}
# Reset possible stack dump if a blank line is found # Reset possible stack dump if a blank line is found
if ($in_commit_log && $commit_log_possible_stack_dump && if ($in_commit_log && $commit_log_possible_stack_dump &&
$line =~ /^\s*$/) { $line =~ /^\s*$/) {
...@@ -2345,9 +2345,10 @@ sub process { ...@@ -2345,9 +2345,10 @@ sub process {
} }
# Check for git id commit length and improperly formed commit descriptions # Check for git id commit length and improperly formed commit descriptions
if ($in_commit_log && if ($in_commit_log && !$commit_log_possible_stack_dump &&
($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
($line =~ /\b[0-9a-f]{12,40}\b/i && ($line =~ /\b[0-9a-f]{12,40}\b/i &&
$line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
$line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) { $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
my $init_char = "c"; my $init_char = "c";
my $orig_commit = ""; my $orig_commit = "";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment