]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: detect wrongly placed open braces in func declarations
authorDaniel Stenberg <daniel@haxx.se>
Wed, 23 Nov 2016 07:48:42 +0000 (08:48 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 24 Nov 2016 22:58:22 +0000 (23:58 +0100)
lib/checksrc.pl

index 9a74a6f46b302e24587f07c6067fae4ccf4de09d..479a5dbdeb38847c161ff29119b220090b5f29e2 100755 (executable)
@@ -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;
     }