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
4291 my $comp = $3;4291 my $comp = $3;
4292 my $to = $4;4292 my $to = $4;
4293 my $newcomp = $comp;4293 my $newcomp = $comp;
4294 if ($lead !~ /$Operators\s*$/ &&4294 if ($lead !~ /(?:$Operators|\.)\s*$/ &&
4295 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&4295 $to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
4296 WARN("CONSTANT_COMPARISON",4296 WARN("CONSTANT_COMPARISON",
4297 "Comparisons should place the constant on the right side of the test\n" . $herecurr) &&4297 "Comparisons should place the constant on the right side of the test\n" . $herecurr) &&