From ba82673dac3e8d00a76aa5e3779a0cb80e7442af Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Thu, 28 Nov 2019 14:16:02 +0100 Subject: checksrc: fix regexp for ASSIGNWITHINCONDITION MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The regexp looking for assignments within conditions was too greedy and matched a too long string in the case of multiple conditionals on the same line. This is basically only a problem in single line macros, and the code which exemplified this was essentially: do { if((x) != NULL) { x = NULL; } } while(0) ..where the final parenthesis of while(0) matched the regexp, and the legal assignment in the block triggered the warning. Fix by making the regexp less greedy by matching for the tell-tale signs of the if statement ending. Also remove the one occurrence where the warning was disabled due to a construction like the above, where the warning didn't apply when fixed. Closes #4647 Reviewed-by: Daniel Stenberg --- lib/checksrc.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/checksrc.pl') diff --git a/lib/checksrc.pl b/lib/checksrc.pl index 834364561..db9a45dff 100755 --- a/lib/checksrc.pl +++ b/lib/checksrc.pl @@ -457,7 +457,7 @@ sub scanfile { } } - if($nostr =~ /^((.*)(if) *\()(.*)\)/) { + if($nostr =~ /^((.*)(if) *\()(.*)\) [{\n]/) { my $pos = length($1); if($4 =~ / = /) { checkwarn("ASSIGNWITHINCONDITION", -- cgit v1.2.3