From: Daniel Stenberg Date: Wed, 23 Nov 2016 07:48:42 +0000 (+0100) Subject: checksrc: detect wrongly placed open braces in func declarations X-Git-Tag: curl-7_52_0~88 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80e7cfeb87c18a7552933ff43a96bd1b709eec22;p=thirdparty%2Fcurl.git checksrc: detect wrongly placed open braces in func declarations --- diff --git a/lib/checksrc.pl b/lib/checksrc.pl index 9a74a6f46b..479a5dbdeb 100755 --- a/lib/checksrc.pl +++ b/lib/checksrc.pl @@ -485,6 +485,19 @@ sub scanfile { $line, length($1)-1, $file, $ol, "no space before asterisk"); } + + # check for 'void func() {', but avoid false positives by requiring + # both an open and closed parentheses before the open brace + if($l =~ /^((\w).*){\z/) { + my $k = $1; + $k =~ s/const *//; + $k =~ s/static *//; + if($k =~ /\(.*\)/) { + checkwarn("BRACEPOS", + $line, length($l)-1, $file, $ol, + "wrongly placed open brace"); + } + } $line++; $prevl = $ol; }