]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: check for spaces before the colon of switch labels
authorEmanuele Torre <torreemanuele6@gmail.com>
Thu, 27 Apr 2023 17:01:28 +0000 (19:01 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 27 Apr 2023 21:26:50 +0000 (23:26 +0200)
Closes #11047

lib/strerror.c
lib/urlapi.c
scripts/checksrc.pl
src/tool_dirhie.c

index 3ec10e3695e7bbdd3bf98dc4d480123c1e356091..bd9cc535c37ef5c32f7ba89dbc3f1ad654d7b7c6 100644 (file)
@@ -181,13 +181,13 @@ curl_easy_strerror(CURLcode error)
   case CURLE_INTERFACE_FAILED:
     return "Failed binding local connection end";
 
-  case CURLE_TOO_MANY_REDIRECTS :
+  case CURLE_TOO_MANY_REDIRECTS:
     return "Number of redirects hit maximum amount";
 
   case CURLE_UNKNOWN_OPTION:
     return "An unknown option was passed in to libcurl";
 
-  case CURLE_SETOPT_OPTION_SYNTAX :
+  case CURLE_SETOPT_OPTION_SYNTAX:
     return "Malformed option provided in a setopt";
 
   case CURLE_GOT_NOTHING:
index 8b95107d23f30958b4de3a5e302c9044fdab9674..83e4ceda3af8b25383c511c18d55e040c155602b 100644 (file)
@@ -679,7 +679,7 @@ static int ipv4_normalize(struct dynbuf *host)
     c = endp;
 
     switch(*c) {
-    case '.' :
+    case '.':
       if(n == 3)
         return HOST_BAD;
       n++;
index 974184bbd27ce0b5a07043e42f2eef9507a30ec8..540b22978fa59884e53c5d14c0a2b8e51fd874fc 100755 (executable)
@@ -90,6 +90,7 @@ my %warnings = (
     'SPACEBEFORECOMMA' => 'space before a comma',
     'SPACEBEFOREPAREN' => 'space before an open parenthesis',
     'SPACESEMICOLON'   => 'space before semicolon',
+    'SPACESWITCHCOLON' => 'space before colon of switch label',
     'TABS'             => 'TAB characters not allowed',
     'TRAILINGSPACE'    => 'Trailing whitespace on the line',
     'TYPEDEFSTRUCT'    => 'typedefed struct',
@@ -690,6 +691,12 @@ sub scanfile {
                       $line, length($1), $file, $ol, "no space before semicolon");
         }
 
+        # check for space before the colon in a switch label
+        if($l =~ /^( *(case .+|default)) :/) {
+            checkwarn("SPACESWITCHCOLON",
+                      $line, length($1), $file, $ol, "no space before colon of switch label");
+        }
+
         # scan for use of banned functions
         if($l =~ /^(.*\W)
                    (gmtime|localtime|
index fb1b7495018e20202751933fdb3041febf419a75..929d18e2a2d75a4ac1ae27a0866629f07ac6a554 100644 (file)
@@ -74,7 +74,7 @@ static void show_dir_errno(FILE *errors, const char *name)
             "exceeded your quota.\n", name);
     break;
 #endif
-  default :
+  default:
     fprintf(errors, "Error creating directory %s.\n", name);
     break;
   }