]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: fix the return() checker
authorDaniel Stenberg <daniel@haxx.se>
Tue, 17 Dec 2024 10:08:13 +0000 (11:08 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 17 Dec 2024 10:27:55 +0000 (11:27 +0100)
It would previously wrongly also catch function calls to function names
ending with 'return'

Amended test1185.

Reported-by: Stefan Eissing
Closes #15764

scripts/checksrc.pl
tests/data/test1185

index 4e3e05050fa734582e43b278076eac55ec7ddb75..d17f95314425234e9cfe71b9c52cf74010ba49d3 100755 (executable)
@@ -714,7 +714,7 @@ sub scanfile {
         }
 
         # check for "return(" without space
-        if($l =~ /^(.*)return\(/) {
+        if($l =~ /^(.*\W)return\(/) {
             if($1 =~ / *\#/) {
                 # this is a #if, treat it differently
             }
index c3133aa23b5f89bf0830be96d954d17ea618be6e..daea3101c848faf0de3f380d61cef7778bdd8969 100644 (file)
@@ -46,7 +46,7 @@ if(a == 2){ /* followed by comment */
   ;
 }
 
-func() ;
+func_return() ;
 
 a = sprintf(buffer, "%s", moo);
 
@@ -120,9 +120,9 @@ void startfunc(int a, int b) {
 ./%LOGDIR/code1185.c:24:11: warning: missing space after close paren (PARENBRACE)
  if(a == 2){  
            ^
-./%LOGDIR/code1185.c:28:7: warning: no space before semicolon (SPACESEMICOLON)
- func() ;
-       ^
+./%LOGDIR/code1185.c:28:14: warning: no space before semicolon (SPACESEMICOLON)
+ func_return() ;
+              ^
 ./%LOGDIR/code1185.c:30:5: warning: use of sprintf is banned (BANNEDFUNC)
  a = sprintf(buffer, "%s", moo);
      ^