checksrc: disallow spaces before labels

Out of 415 labels throughout the code base, 86 of those labels were
not at the start of the line. Which means labels always at the start of
the line is the favoured style overall with 329 instances.

Out of the 86 labels not at the start of the line:
* 75 were indented with the same indentation level of the following line
* 8 were indented with exactly one space
* 2 were indented with one fewer indentation level then the following
  line
* 1 was indented with the indentation level of the following line minus
  three space (probably unintentional)

Co-Authored-By: Viktor Szakats

Closes #11134
This commit is contained in:
Emanuele Torre 2023-05-18 06:54:18 +02:00 committed by Daniel Stenberg
parent d334b02924
commit f198d33e8d
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
55 changed files with 92 additions and 86 deletions

View File

@ -74,7 +74,7 @@ int main(void)
curl_free(path);
}
fail:
fail:
curl_url_cleanup(h); /* free url handle */
return 0;
}

View File

@ -67,7 +67,7 @@ int main(void)
goto cleanup;
}
cleanup:
cleanup:
curl_url_cleanup(urlp);
curl_easy_cleanup(curl);
return 0;

View File

@ -117,7 +117,7 @@ static struct altsvc *altsvc_createid(const char *srchost,
as->dst.port = curlx_ultous(dstport);
return as;
error:
error:
altsvc_free(as);
return NULL;
}
@ -217,7 +217,7 @@ static CURLcode altsvc_load(struct altsvcinfo *asi, const char *file)
}
return result;
fail:
fail:
Curl_safefree(asi->filename);
free(line);
fclose(fp);

View File

@ -251,7 +251,7 @@ int init_thread_sync_data(struct thread_data *td,
return 1;
err_exit:
err_exit:
#ifndef CURL_DISABLE_SOCKETPAIR
if(tsd->sock_pair[0] != CURL_SOCKET_BAD) {
sclose(tsd->sock_pair[0]);
@ -469,10 +469,10 @@ static bool init_resolve_thread(struct Curl_easy *data,
return TRUE;
err_exit:
err_exit:
destroy_async_data(asp);
errno_exit:
errno_exit:
errno = err;
return FALSE;
}

View File

@ -178,7 +178,7 @@ CURLcode Curl_base64_decode(const char *src,
*outlen = rawlen;
return CURLE_OK;
bad:
bad:
free(newstr);
return CURLE_BAD_CONTENT_ENCODING;
}

View File

@ -1212,7 +1212,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
Curl_safefree(data->state.aptr.userpwd);
Curl_safefree(data->state.aptr.proxyuserpwd);
return CURLE_OK;
error:
error:
DEBUGASSERT(result);
if(io)
hyper_io_free(io);

View File

@ -246,7 +246,7 @@ CURLcode Curl_conncache_add_conn(struct Curl_easy *data)
"The cache now contains %zu members",
conn->connection_id, connc->num_conn));
unlock:
unlock:
CONNCACHE_UNLOCK(data);
return result;

View File

@ -1387,7 +1387,7 @@ static struct Cookie *dup_cookie(struct Cookie *src)
}
return d;
fail:
fail:
freecookie(d);
return NULL;
}

View File

@ -191,7 +191,7 @@ CURLcode Curl_get_pathname(const char **cpp, char **path, char *homedir)
}
return CURLE_OK;
fail:
fail:
Curl_safefree(*path);
return CURLE_QUOTE_ERROR;
}

View File

@ -312,7 +312,7 @@ static CURLcode dict_do(struct Curl_easy *data, bool *done)
}
}
error:
error:
free(eword);
free(path);
return result;

View File

@ -347,7 +347,7 @@ static CURLcode dohprobe(struct Curl_easy *data,
free(nurl);
return CURLE_OK;
error:
error:
free(nurl);
Curl_close(&doh);
return result;
@ -409,7 +409,7 @@ struct Curl_addrinfo *Curl_doh(struct Curl_easy *data,
#endif
return NULL;
error:
error:
curl_slist_free_all(dohp->headers);
data->req.doh->headers = NULL;
for(slot = 0; slot < DOH_PROBE_SLOTS; slot++) {

View File

@ -209,7 +209,7 @@ static CURLcode global_init(long flags, bool memoryfuncs)
return CURLE_OK;
fail:
fail:
initialized--; /* undo the increase */
return CURLE_FAILED_INIT;
}
@ -993,7 +993,7 @@ struct Curl_easy *curl_easy_duphandle(struct Curl_easy *data)
return outcurl;
fail:
fail:
if(outcurl) {
#ifndef CURL_DISABLE_COOKIES

View File

@ -3838,7 +3838,7 @@ static CURLcode init_wc_data(struct Curl_easy *data)
infof(data, "Wildcard - Parsing started");
return CURLE_OK;
fail:
fail:
if(ftpwc) {
Curl_ftp_parselist_data_free(&ftpwc->parser);
free(ftpwc);

View File

@ -325,7 +325,7 @@ CURLcode Curl_headers_push(struct Curl_easy *data, const char *header,
hs, &hs->node);
data->state.prevhead = hs;
return CURLE_OK;
fail:
fail:
free(hs);
return result;
}

View File

@ -1238,7 +1238,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
goto err;
error = false;
err:
err:
if(error) {
failf(data, "Couldn't parse CURLOPT_RESOLVE entry '%s'",
hostp->data);

View File

@ -390,7 +390,7 @@ CURLcode Curl_hsts_save(struct Curl_easy *data, struct hsts *h,
unlink(tempstore);
}
free(tempstore);
skipsave:
skipsave:
if(data->set.hsts_write) {
/* if there's a write callback */
struct curl_index i; /* count */
@ -534,7 +534,7 @@ static CURLcode hsts_load(struct hsts *h, const char *file)
}
return result;
fail:
fail:
Curl_safefree(h->filename);
fclose(fp);
return CURLE_OUT_OF_MEMORY;

View File

@ -398,7 +398,7 @@ static CURLcode http_output_basic(struct Curl_easy *data, bool proxy)
goto fail;
}
fail:
fail:
free(out);
return result;
}
@ -424,7 +424,7 @@ static CURLcode http_output_bearer(struct Curl_easy *data)
goto fail;
}
fail:
fail:
return result;
}

View File

@ -806,7 +806,7 @@ static int set_transfer_url(struct Curl_easy *data,
uc = curl_url_get(u, CURLUPART_URL, &url, 0);
if(uc)
rc = 4;
fail:
fail:
curl_url_cleanup(u);
if(rc)
return rc;
@ -930,7 +930,7 @@ static int push_promise(struct Curl_cfilter *cf,
DEBUGF(LOG_CF(data, cf, "Got PUSH_PROMISE, ignore it"));
rv = CURL_PUSH_DENY;
}
fail:
fail:
return rv;
}

View File

@ -743,11 +743,11 @@ static int dprintf_formatf(
goto number;
unsigned_number:
unsigned_number:
/* Unsigned number of base BASE. */
is_neg = 0;
number:
number:
/* Number of base BASE. */
/* Supply a default precision if none was given. */

View File

@ -605,7 +605,7 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done)
unsigned char packet;
switch(mqtt->state) {
MQTT_SUBACK_COMING:
MQTT_SUBACK_COMING:
case MQTT_SUBACK_COMING:
result = mqtt_verify_suback(data);
if(result)
@ -688,7 +688,7 @@ static CURLcode mqtt_read_publish(struct Curl_easy *data, bool *done)
result = CURLE_WEIRD_SERVER_REPLY;
goto end;
}
end:
end:
return result;
}

View File

@ -448,7 +448,7 @@ struct Curl_multi *Curl_multi_handle(int hashsize, /* socket hash */
return multi;
error:
error:
sockhash_destroy(&multi->sockhash);
Curl_hash_destroy(&multi->hostcache);
@ -2625,7 +2625,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
multi_handle_timeout(data, nowp, &stream_error, &result, TRUE);
}
statemachine_end:
statemachine_end:
if(data->mstate < MSTATE_COMPLETED) {
if(result) {

View File

@ -244,7 +244,7 @@ static int parsenetrc(const char *host,
}
} /* while Curl_get_line() */
out:
out:
if(!retcode) {
/* success */
if(login_alloc) {

View File

@ -332,7 +332,7 @@ static bool match_time(const char *date,
}
}
return FALSE; /* not a time string */
match:
match:
*h = hh;
*m = mm;
*s = ss;

View File

@ -183,7 +183,7 @@ int Curl_socketpair(int domain, int type, int protocol,
sclose(listener);
return 0;
error:
error:
sclose(listener);
sclose(socks[0]);
sclose(socks[1]);

View File

@ -354,7 +354,7 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf,
}
}
/* FALLTHROUGH */
CONNECT_RESOLVED:
CONNECT_RESOLVED:
case CONNECT_RESOLVED: {
struct Curl_addrinfo *hp = NULL;
/*
@ -394,7 +394,7 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf,
return CURLPX_RESOLVE_HOST;
}
/* FALLTHROUGH */
CONNECT_REQ_INIT:
CONNECT_REQ_INIT:
case CONNECT_REQ_INIT:
/*
* This is currently not supporting "Identification Protocol (RFC1413)".
@ -638,7 +638,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
return CURLPX_OK;
}
/* FALLTHROUGH */
CONNECT_SOCKS_READ_INIT:
CONNECT_SOCKS_READ_INIT:
case CONNECT_SOCKS_READ_INIT:
sx->outstanding = 2; /* expect two bytes */
sx->outp = socksreq; /* store it here */
@ -700,7 +700,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
default: /* do nothing! */
break;
CONNECT_AUTH_INIT:
CONNECT_AUTH_INIT:
case CONNECT_AUTH_INIT: {
/* Needs user name and password */
size_t proxy_user_len, proxy_password_len;
@ -779,7 +779,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
/* Everything is good so far, user was authenticated! */
sxstate(sx, data, CONNECT_REQ_INIT);
/* FALLTHROUGH */
CONNECT_REQ_INIT:
CONNECT_REQ_INIT:
case CONNECT_REQ_INIT:
if(socks5_resolve_local) {
enum resolve_t rc = Curl_resolv(data, sx->hostname, sx->remote_port,
@ -818,7 +818,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
}
}
/* FALLTHROUGH */
CONNECT_RESOLVED:
CONNECT_RESOLVED:
case CONNECT_RESOLVED: {
struct Curl_addrinfo *hp = NULL;
size_t destlen;
@ -873,7 +873,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
Curl_resolv_unlock(data, dns); /* not used anymore from now on */
goto CONNECT_REQ_SEND;
}
CONNECT_RESOLVE_REMOTE:
CONNECT_RESOLVE_REMOTE:
case CONNECT_RESOLVE_REMOTE:
/* Authentication is complete, now specify destination to the proxy */
len = 0;
@ -913,7 +913,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf,
}
/* FALLTHROUGH */
CONNECT_REQ_SEND:
CONNECT_REQ_SEND:
case CONNECT_REQ_SEND:
/* PORT MSB */
socksreq[len++] = (unsigned char)((sx->remote_port >> 8) & 0xff);

View File

@ -1110,7 +1110,7 @@ CURLcode telrcv(struct Curl_easy *data,
break;
case CURL_TS_IAC:
process_iac:
process_iac:
DEBUGASSERT(startwrite < 0);
switch(c) {
case CURL_WILL:

View File

@ -1587,7 +1587,7 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
conn->gssapi_delegation = data->set.gssapi_delegation;
return conn;
error:
error:
free(conn->localdev);
free(conn);
@ -2301,7 +2301,7 @@ static CURLcode parse_proxy(struct Curl_easy *data,
}
#endif
error:
error:
free(proxyuser);
free(proxypasswd);
free(host);
@ -2898,7 +2898,7 @@ static CURLcode parse_connect_to_host_port(struct Curl_easy *data,
*port_result = port;
error:
error:
free(host_dup);
return result;
}

View File

@ -481,7 +481,7 @@ static CURLUcode parse_hostname_login(struct Curl_URL *u,
*offset = ptr - login;
return CURLUE_OK;
out:
out:
free(userp);
free(passwdp);
@ -1317,7 +1317,7 @@ static CURLUcode parseurl(const char *url, CURLU *u, unsigned int flags)
u->host = Curl_dyn_ptr(&host);
return result;
fail:
fail:
Curl_dyn_free(&host);
free_urlhandle(u);
return result;
@ -1380,7 +1380,7 @@ CURLU *curl_url_dup(const CURLU *in)
u->portnum = in->portnum;
}
return u;
fail:
fail:
curl_url_cleanup(u);
return NULL;
}
@ -1876,7 +1876,7 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
free(*storep);
*storep = Curl_dyn_ptr(&enc);
return CURLUE_OK;
nomem:
nomem:
free((char *)newp);
return CURLUE_OUT_OF_MEMORY;
}

View File

@ -1305,7 +1305,7 @@ static int init_ngh3_conn(struct Curl_cfilter *cf)
}
return CURLE_OK;
fail:
fail:
return result;
}

View File

@ -425,7 +425,7 @@ static CURLcode wssh_connect(struct Curl_easy *data, bool *done)
state(data, SSH_SFTP_INIT);
return wssh_multi_statemach(data, done);
error:
error:
wolfSSH_free(sshc->ssh_session);
wolfSSH_CTX_free(sshc->ctx);
return CURLE_FAILED_INIT;

View File

@ -831,7 +831,7 @@ mbed_connect_step2(struct Curl_cfilter *cf, struct Curl_easy *data)
result = Curl_pin_peer_pubkey(data,
pinnedpubkey,
&pubkey[PUB_DER_MAX_BYTES - size], size);
pinnedpubkey_error:
pinnedpubkey_error:
mbedtls_x509_crt_free(p);
free(p);
free(pubkey);

View File

@ -1496,7 +1496,7 @@ int cert_stuff(struct Curl_easy *data,
}
cert_done = 1;
fail:
fail:
EVP_PKEY_free(pri);
X509_free(x509);
sk_X509_pop_free(ca, X509_free);
@ -4501,7 +4501,7 @@ static ssize_t ossl_send(struct Curl_cfilter *cf,
}
*curlcode = CURLE_OK;
out:
out:
return (ssize_t)rc; /* number of bytes */
}
@ -4603,7 +4603,7 @@ static ssize_t ossl_recv(struct Curl_cfilter *cf,
}
}
out:
out:
return nread;
}

View File

@ -2358,7 +2358,7 @@ schannel_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
"schannel: decrypted data buffer: offset %zu length %zu",
backend->decdata_offset, backend->decdata_length));
cleanup:
cleanup:
/* Warning- there is no guarantee the encdata state is valid at this point */
DEBUGF(infof(data, "schannel: schannel_recv cleanup"));

View File

@ -3376,7 +3376,7 @@ static ssize_t sectransp_recv(struct Curl_cfilter *cf,
DEBUGASSERT(backend);
again:
again:
*curlcode = CURLE_OK;
err = SSLRead(backend->ssl_ctx, buf, buffersize, &processed);

View File

@ -75,6 +75,7 @@ my %warnings = (
'INCLUDEDUP', => 'same file is included again',
'INDENTATION' => 'wrong start column for code',
'LONGLINE' => "Line longer than $max_column",
'SPACEBEFORELABEL' => 'labels not at the start of the line',
'MULTISPACE' => 'multiple spaces used when not suitable',
'NOSPACEEQUALS' => 'equals sign without preceding space',
'NOTEQUALSZERO', => 'if/while comparison with != 0',
@ -697,6 +698,11 @@ sub scanfile {
$line, length($1), $file, $ol, "no space before colon of switch label");
}
if($prevl !~ /\?\z/ && $l =~ /^ +([A-Za-z_][A-Za-z0-9_]*):$/ && $1 ne 'default') {
checkwarn("SPACEBEFORELABEL",
$line, length($1), $file, $ol, "no space before label");
}
# scan for use of banned functions
if($l =~ /^(.*\W)
(gmtime|localtime|

View File

@ -900,7 +900,7 @@ int formparse(struct OperationConfig *config,
goto fail;
}
err = 0;
fail:
fail:
Curl_safefree(contents);
curl_slist_free_all(headers);
return err;

View File

@ -624,7 +624,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
return CURLE_OK;
}
} /* if retry_numretries */
noretry:
noretry:
if((global->progressmode == CURL_PROGRESS_BAR) &&
per->progressbar.calls)

View File

@ -170,7 +170,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename)
/* nothing to do */
result = CURLE_OK;
}
fail:
fail:
curl_url_cleanup(uh);
curl_free(path);
return result;

View File

@ -296,7 +296,7 @@ CURLcode tool_setopt_enum(CURL *curl, struct GlobalConfig *config,
if(ret)
warnf(config, "option %s returned error (%d)\n", name, (int)ret);
#endif
nomem:
nomem:
return ret;
}
@ -338,7 +338,7 @@ CURLcode tool_setopt_flags(CURL *curl, struct GlobalConfig *config,
CODE2("%s%ldL);", preamble, rest);
}
nomem:
nomem:
return ret;
}
@ -381,7 +381,7 @@ CURLcode tool_setopt_bitmask(CURL *curl, struct GlobalConfig *config,
CODE2("%s%luUL);", preamble, rest);
}
nomem:
nomem:
return ret;
}
@ -407,7 +407,7 @@ static CURLcode libcurl_generate_slist(struct curl_slist *slist, int *slistno)
*slistno, *slistno, escaped);
}
nomem:
nomem:
Curl_safefree(escaped);
return ret;
}
@ -590,7 +590,7 @@ CURLcode tool_setopt_slist(CURL *curl, struct GlobalConfig *config,
CODE2("curl_easy_setopt(hnd, %s, slist%d);", name, i);
}
nomem:
nomem:
return ret;
}
@ -704,7 +704,7 @@ CURLcode tool_setopt(CURL *curl, bool str, struct GlobalConfig *global,
}
}
nomem:
nomem:
Curl_safefree(escaped);
return ret;
}

View File

@ -295,7 +295,7 @@ static CURLcode glob_range(struct URLGlob *glob, char **patternp,
}
}
fail:
fail:
*posp += (pattern - *patternp);
if(!endp || !step_n ||

View File

@ -75,7 +75,7 @@ char *stripcredentials(const char *url)
return nurl;
}
error:
error:
curl_url_cleanup(u);
return NULL;
}

View File

@ -123,7 +123,7 @@ static int onetest(CURL *curl, const char *url, const struct testparams *p,
}
return 0;
test_cleanup:
test_cleanup:
return 1;
}
@ -164,7 +164,7 @@ int test(char *URL)
printf("%d\n", status);
return status;
test_cleanup:
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();

View File

@ -92,7 +92,7 @@ int test(char *URL)
else {
printf("curl_easy_perform() failed. e = %d\n", code);
}
test_cleanup:
test_cleanup:
curl_slist_free_all(pHeaderList);
curl_easy_cleanup(curl);
curl_global_cleanup();

View File

@ -107,7 +107,7 @@ int test(char *URL)
printf("Tested %u strings\n", i);
res = (int)result;
test_cleanup:
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();

View File

@ -47,7 +47,7 @@ int test(char *URL)
curl_easy_setopt(ch, CURLOPT_COOKIEFILE, libtest_arg2);
curl_easy_perform(ch);
cleanup:
cleanup:
curl_easy_cleanup(ch);
curl_global_cleanup();

View File

@ -90,7 +90,7 @@ int test(char *URL)
curl_easy_setopt(ch, CURLOPT_SHARE, NULL);
curl_multi_remove_handle(cm, ch);
cleanup:
cleanup:
curl_easy_cleanup(ch);
curl_share_cleanup(sh);
curl_multi_cleanup(cm);

View File

@ -64,7 +64,7 @@ int test(char *URL)
res = curl_easy_perform(curl);
test_cleanup:
test_cleanup:
curl_easy_cleanup(curl);
curl_global_cleanup();

View File

@ -112,7 +112,7 @@ int test(char *URL)
}
curl_multi_remove_handle(mcurl, curl);
fail:
fail:
curl_easy_cleanup(curl);
curl_multi_cleanup(mcurl);

View File

@ -702,7 +702,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
}
} while(1);
end:
end:
if(buffer)
free(buffer);
if(dump)

View File

@ -1172,7 +1172,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
if(num > 20)
num = 20;
retry:
retry:
written = swrite(sock, buffer, num);
if(written < 0) {
if((EWOULDBLOCK == SOCKERRNO) || (EAGAIN == SOCKERRNO)) {

View File

@ -500,7 +500,7 @@ static ssize_t write_behind(struct testcase *test, int convert)
putc(c, file); */
if(1 != write(test->ofile, &c, 1))
break;
skipit:
skipit:
prevchar = c;
}
return count;
@ -1201,7 +1201,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf)
wait_ms(1000*test->writedelay);
}
send_data:
send_data:
logmsg("write");
if(swrite(peer, sdp, size + 4) != size + 4) {
logmsg("write: fail");

View File

@ -227,7 +227,7 @@ UNITTEST_START
continue;
}
}
error:
error:
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_slist_free_all(list);

View File

@ -212,7 +212,7 @@ UNITTEST_START
}
}
goto unit_test_abort;
error:
error:
curl_easy_cleanup(easy);
curl_multi_cleanup(multi);
curl_slist_free_all(list);

View File

@ -224,7 +224,7 @@ UNITTEST_START
goto fail;
ret = parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "parse_port did wrong");
fail:
fail:
free(ipv6port);
curl_url_cleanup(u);

View File

@ -106,7 +106,7 @@ UNITTEST_START
Curl_altsvc_save(curl, asi, outname);
curl_easy_cleanup(curl);
fail:
fail:
Curl_altsvc_cleanup(&asi);
}
#endif