From 80e7cfeb87c18a7552933ff43a96bd1b709eec22 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 23 Nov 2016 08:48:42 +0100 Subject: checksrc: detect wrongly placed open braces in func declarations --- lib/checksrc.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/checksrc.pl b/lib/checksrc.pl index 9a74a6f46..479a5dbde 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; } -- cgit v1.2.3