Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1365206
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] checkpatch: Improve CONSTANT_COMPARISON test for structure members |
| Date | 2016-03-28 00:20 +0200 |
| Message-ID | <rhrcm-6ht-21@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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 <joe@perches.com>
---
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d574d13..b7bce45 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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) &&
--
2.7.4
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH] checkpatch: Improve CONSTANT_COMPARISON test for structure members Joe Perches <joe@perches.com> - 2016-03-28 00:20 +0200
csiph-web