summaryrefslogtreecommitdiff
path: root/lib/checksrc.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-12-14 01:29:44 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-12-14 01:29:44 +0100
commit1c3e8bbfedcd3822aeb1bab22fb56c5ecff4295b (patch)
treec1606588aeae4535f0faa7942fcbe50e6e340f8b /lib/checksrc.pl
parentb228d2952b6762b5c9b851fba0cf391e80c6761a (diff)
downloadcurl-1c3e8bbfedcd3822aeb1bab22fb56c5ecff4295b.tar.gz
checksrc: warn for assignments within if() expressions
... they're already frowned upon in our source code style guide, this now enforces the rule harder.
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-xlib/checksrc.pl8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index 022b193aa..c56e9c841 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -356,6 +356,14 @@ sub scanfile {
}
}
+ if($nostr =~ /^((.*)(if) *\()(.*)\)/) {
+ my $pos = length($1);
+ if($4 =~ / = /) {
+ checkwarn("ASSIGNWITHINCONDITION",
+ $line, $pos+1, $file, $l,
+ "assignment within conditional expression");
+ }
+ }
# check spaces after open parentheses
if($l =~ /^(.*[a-z])\( /i) {
checkwarn("SPACEAFTERPAREN",