History

checkpatch: improve CONSTANT_COMPARISON test for structure members

A "." dereference to an all uppercase structure member can be incorrectly reported as a CONSTANT_COMPARISON. ie: "if (table[i].PANELID == tempdx)" Fix it by checking for "." before the constant test.

Joe Perches committed 10 years ago

Commit f39e1761 parent 2d632741 file · +1 −1Browse files

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

Unified · Split

scripts/checkpatch.pl+1−1
@@ -4291,7 +4291,7 @@ sub process { · 4290 unmodified lines
42914291 my $comp = $3;
42924292 my $to = $4;
42934293 my $newcomp = $comp;
4294− if ($lead !~ /$Operators\s*$/ &&
4294+ if ($lead !~ /(?:$Operators|\.)\s*$/ &&
42954295 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
42964296 WARN("CONSTANT_COMPARISON",
42974297 "Comparisons should place the constant on the right side of the test\n" . $herecurr) &&