Skip to content

Commit

Permalink
checkpatch: improve CONSTANT_COMPARISON test for structure members
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and torvalds committed May 21, 2016
1 parent 2d63274 commit f39e176
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4291,7 +4291,7 @@ sub process {
my $comp = $3;
my $to = $4;
my $newcomp = $comp;
if ($lead !~ /$Operators\s*$/ &&
if ($lead !~ /(?:$Operators|\.)\s*$/ &&
$to !~ /^(?:Constant|[A-Z_][A-Z0-9_]*)$/ &&
WARN("CONSTANT_COMPARISON",
"Comparisons should place the constant on the right side of the test\n" . $herecurr) &&
Expand Down

0 comments on commit f39e176

Please sign in to comment.