]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: verify ASTERISKNOSPACE
authorDaniel Stenberg <daniel@haxx.se>
Wed, 23 Nov 2016 07:29:42 +0000 (08:29 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 24 Nov 2016 22:58:22 +0000 (23:58 +0100)
Detects (char*) and 'char*foo' uses.

lib/checksrc.pl

index 9eb76f47ef3866a29baa9e8dac38ac56cbf69ea0..9a74a6f46b302e24587f07c6067fae4ccf4de09d 100755 (executable)
@@ -56,7 +56,8 @@ my %warnings = (
     'BADCOMMAND'       => 'bad !checksrc! instruction',
     'UNUSEDIGNORE'     => 'a warning ignore was not used',
     'OPENCOMMENT'      => 'file ended with a /* comment still "open"',
-    'ASTERISKSPACE'    => 'pointer declared with space after asterisk'
+    'ASTERISKSPACE'    => 'pointer declared with space after asterisk',
+    'ASTERISKNOSPACE'  => 'pointer declared without space before asterisk'
     );
 
 sub readwhitelist {
@@ -473,11 +474,17 @@ sub scanfile {
         }
 
         # check for 'char * name'
-        if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *\*) (\w+)/) && ($3 ne "const")) {
-            checkwarn("ASTERISKSPACE",
+        if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost) *(\*+)) (\w+)/) && ($4 ne "const")) {
+            checkwarn("ASTERISKNOSPACE",
                       $line, length($1), $file, $ol,
                       "no space after declarative asterisk");
         }
+        # check for 'char*'
+        if(($l =~ /(^.*(char|int|long|void|curl_slist|CURL|CURLM|CURLMsg|curl_httppost|sockaddr_in|FILE)\*)/)) {
+            checkwarn("ASTERISKNOSPACE",
+                      $line, length($1)-1, $file, $ol,
+                      "no space before asterisk");
+        }
         $line++;
         $prevl = $ol;
     }