Skip to content

Commit

Permalink
checksrc: check for spaces before the colon of switch labels
Browse files Browse the repository at this point in the history
Closes #11047
  • Loading branch information
emanuele6 authored and bagder committed Apr 27, 2023
1 parent 5cdff4f commit 7f71239
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/strerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/urlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ static int ipv4_normalize(struct dynbuf *host)
c = endp;

switch(*c) {
case '.' :
case '.':
if(n == 3)
return HOST_BAD;
n++;
Expand Down
7 changes: 7 additions & 0 deletions scripts/checksrc.pl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
'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',
Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion src/tool_dirhie.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 7f71239

Please sign in to comment.