History

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

Joe Perches committed 11 years ago

Commit 369c8dd1 parent 9f029f51 file · +26 −25Browse files

Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all

Unified · Split

scripts/checkpatch.pl+26−25
@@ -2313,42 +2313,43 @@ sub process { · 2312 unmodified lines
23132313 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
23142314 }
23152315
2316+# Check if the commit log is in a possible stack dump
2317+ if ($in_commit_log && !$commit_log_possible_stack_dump &&
2318+ ($line =~ /^\s*(?:WARNING:|BUG:)/ ||
2319+ $line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
2320+ # timestamp
2321+ $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/)) {
2322+ # stack dump address
2323+ $commit_log_possible_stack_dump = 1;
2324+ }
2325+
23162326 # Check for line lengths > 75 in commit log, warn once
23172327 if ($in_commit_log && !$commit_log_long_line &&
2318− length($line) > 75 &&
2319− !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
2320− # file delta changes
2321− $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
2322− # filename then :
2323− $line =~ /^\s*(?:Fixes:|Link:)/i ||
2324− # A Fixes: or Link: line
2325− $commit_log_possible_stack_dump)) {
2328+ length($line) > 75 &&
2329+ !($line =~ /^\s*[a-zA-Z0-9_\/\.]+\s+\|\s+\d+/ ||
2330+ # file delta changes
2331+ $line =~ /^\s*(?:[\w\.\-]+\/)++[\w\.\-]+:/ ||
2332+ # filename then :
2333+ $line =~ /^\s*(?:Fixes:|Link:)/i ||
2334+ # A Fixes: or Link: line
2335+ $commit_log_possible_stack_dump)) {
23262336 WARN("COMMIT_LOG_LONG_LINE",
23272337 "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
23282338 $commit_log_long_line = 1;
23292339 }
23302340
2331−# Check if the commit log is in a possible stack dump
2332− if ($in_commit_log && !$commit_log_possible_stack_dump &&
2333− ($line =~ /^\s*(?:WARNING:|BUG:)/ ||
2334− $line =~ /^\s*\[\s*\d+\.\d{6,6}\s*\]/ ||
2335− # timestamp
2336− $line =~ /^\s*\[\<[0-9a-fA-F]{8,}\>\]/)) {
2337− # stack dump address
2338− $commit_log_possible_stack_dump = 1;
2339− }
2340−
23412341 # Reset possible stack dump if a blank line is found
2342− if ($in_commit_log && $commit_log_possible_stack_dump &&
2343− $line =~ /^\s*$/) {
2344− $commit_log_possible_stack_dump = 0;
2345− }
2342+ if ($in_commit_log && $commit_log_possible_stack_dump &&
2343+ $line =~ /^\s*$/) {
2344+ $commit_log_possible_stack_dump = 0;
2345+ }
23462346
23472347 # Check for git id commit length and improperly formed commit descriptions
2348− if ($in_commit_log &&
2348+ if ($in_commit_log && !$commit_log_possible_stack_dump &&
23492349 ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i ||
2350− ($line =~ /\b[0-9a-f]{12,40}\b/i &&
2351− $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
2350+ ($line =~ /\b[0-9a-f]{12,40}\b/i &&
2351+ $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i &&
2352+ $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) {
23522353 my $init_char = "c";
23532354 my $orig_commit = "";
23542355 my $short = 1;