summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Torre <torreemanuele6@gmail.com>2023-04-27 19:01:28 +0200
committerDaniel Stenberg <daniel@haxx.se>2023-04-27 23:26:50 +0200
commit7f712399d5338a2dd838a8bb16ca1548b491dfb3 (patch)
treea8d7f5e8c2eb84a53976527af1067e5370187592
parent5cdff4f5a92797ce49a3cd01e27388cce35aab7a (diff)
downloadcurl-7f712399d5338a2dd838a8bb16ca1548b491dfb3.tar.gz
checksrc: check for spaces before the colon of switch labels
Closes #11047
-rw-r--r--lib/strerror.c4
-rw-r--r--lib/urlapi.c2
-rwxr-xr-xscripts/checksrc.pl7
-rw-r--r--src/tool_dirhie.c2
4 files changed, 11 insertions, 4 deletions
diff --git a/lib/strerror.c b/lib/strerror.c
index 3ec10e369..bd9cc535c 100644
--- a/lib/strerror.c
+++ b/lib/strerror.c
@@ -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:
diff --git a/lib/urlapi.c b/lib/urlapi.c
index 8b95107d2..83e4ceda3 100644
--- a/lib/urlapi.c
+++ b/lib/urlapi.c
@@ -679,7 +679,7 @@ static int ipv4_normalize(struct dynbuf *host)
c = endp;
switch(*c) {
- case '.' :
+ case '.':
if(n == 3)
return HOST_BAD;
n++;
diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl
index 974184bbd..540b22978 100755
--- a/scripts/checksrc.pl
+++ b/scripts/checksrc.pl
@@ -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|
diff --git a/src/tool_dirhie.c b/src/tool_dirhie.c
index fb1b74950..929d18e2a 100644
--- a/src/tool_dirhie.c
+++ b/src/tool_dirhie.c
@@ -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;
}