mirror of
https://github.com/curl/curl.git
synced 2026-08-25 01:33:31 +03:00
tidy-up: syntax and code nits
- cmp-pkg-config.sh: replace `-r -f` with `-rf` to match rest of repo. - configure.ac: add double quotes for robustness (not a bug). - curl-openssl.m4: merge nested `if`s. - CurlTests.c: drop `!= 0`, also to sync with m4. - CurlTests.c: replace `example.com` with `localhost` in `gethostbyname()` feature test code. (compile-only, not a bug) - GHA/http3-linux: drop literal `true` from bool expression. - lib650: drop redundant `&`. - move variable/call to left-hand side of equality checks, where missing. - perl: detach `<`/`>` from filename in `open()`, where missing. - schannel: apply two nit fixes lost in rebase. - scripts/verify-release: drop redundant double quotes. - scripts/verify-release: exit with error code on error. - synctime: replace magic numbers with `sizeof()`. - telnet: add missing parentheses to macro value. - tests/Makefile.am: use single quotes. - tool_operate: drop redundant `break` after `return` in VMS code. - unit2413: drop unused NULL pointer + free call. - unit2413: fix duplicate test case name. - urlapi: drop redundant parentheses. - urlapi: drop `CURL_UNCONST()` that became redundant. Closes #22186
This commit is contained in:
parent
a36384ab94
commit
84c5dcdb05
31 changed files with 100 additions and 102 deletions
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
#define SUBBUFSIZE 512
|
||||
|
||||
#define CURL_SB_CLEAR(x) x->subpointer = (x)->subbuffer
|
||||
#define CURL_SB_CLEAR(x) (x)->subpointer = (x)->subbuffer
|
||||
#define CURL_SB_TERM(x) \
|
||||
do { \
|
||||
(x)->subend = (x)->subpointer; \
|
||||
|
|
|
|||
16
lib/urlapi.c
16
lib/urlapi.c
|
|
@ -584,7 +584,7 @@ UNITTEST int ipv4_normalize(struct dynbuf *host)
|
|||
return HOST_NAME;
|
||||
curlx_dyn_reset(host);
|
||||
result = curlx_dyn_addf(host, "%u.%u.%u.%u",
|
||||
(parts[0]),
|
||||
parts[0],
|
||||
((parts[1] >> 16) & 0xff),
|
||||
((parts[1] >> 8) & 0xff),
|
||||
(parts[1] & 0xff));
|
||||
|
|
@ -594,8 +594,8 @@ UNITTEST int ipv4_normalize(struct dynbuf *host)
|
|||
return HOST_NAME;
|
||||
curlx_dyn_reset(host);
|
||||
result = curlx_dyn_addf(host, "%u.%u.%u.%u",
|
||||
(parts[0]),
|
||||
(parts[1]),
|
||||
parts[0],
|
||||
parts[1],
|
||||
((parts[2] >> 8) & 0xff),
|
||||
(parts[2] & 0xff));
|
||||
break;
|
||||
|
|
@ -605,10 +605,10 @@ UNITTEST int ipv4_normalize(struct dynbuf *host)
|
|||
return HOST_NAME;
|
||||
curlx_dyn_reset(host);
|
||||
result = curlx_dyn_addf(host, "%u.%u.%u.%u",
|
||||
(parts[0]),
|
||||
(parts[1]),
|
||||
(parts[2]),
|
||||
(parts[3]));
|
||||
parts[0],
|
||||
parts[1],
|
||||
parts[2],
|
||||
parts[3]);
|
||||
break;
|
||||
}
|
||||
if(result)
|
||||
|
|
@ -1961,7 +1961,7 @@ static CURLUcode url_sethost(CURLU *u, struct dynbuf *encp,
|
|||
bad = TRUE;
|
||||
curlx_free(decoded);
|
||||
}
|
||||
else if(hostname_check(u, (char *)CURL_UNCONST(newp), n))
|
||||
else if(hostname_check(u, newp, n))
|
||||
bad = TRUE;
|
||||
if(bad) {
|
||||
curlx_dyn_free(encp);
|
||||
|
|
|
|||
|
|
@ -1468,19 +1468,19 @@ static CURLcode mbedtls_connect(struct Curl_cfilter *cf,
|
|||
*done = FALSE;
|
||||
connssl->io_need = CURL_SSL_IO_NEED_NONE;
|
||||
|
||||
if(ssl_connect_1 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_1) {
|
||||
result = mbed_connect_step1(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(ssl_connect_2 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_2) {
|
||||
result = mbed_connect_step2(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(ssl_connect_3 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_3) {
|
||||
/* For tls1.3 we get notified about new sessions */
|
||||
struct ssl_connect_data *ctx = cf->ctx;
|
||||
struct mbed_ssl_backend_data *backend =
|
||||
|
|
@ -1495,7 +1495,7 @@ static CURLcode mbedtls_connect(struct Curl_cfilter *cf,
|
|||
connssl->connecting_state = ssl_connect_done;
|
||||
}
|
||||
|
||||
if(ssl_connect_done == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_done) {
|
||||
connssl->state = ssl_connection_complete;
|
||||
*done = TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1898,7 +1898,7 @@ static CURLcode ossl_shutdown(struct Curl_cfilter *cf,
|
|||
*done = TRUE;
|
||||
goto out;
|
||||
}
|
||||
if(SSL_ERROR_WANT_WRITE == SSL_get_error(octx->ssl, rc)) {
|
||||
if(SSL_get_error(octx->ssl, rc) == SSL_ERROR_WANT_WRITE) {
|
||||
CURL_TRC_CF(data, cf, "SSL shutdown still wants to send");
|
||||
connssl->io_need = CURL_SSL_IO_NEED_SEND;
|
||||
goto out;
|
||||
|
|
@ -4014,7 +4014,7 @@ static CURLcode ossl_connect_step1(struct Curl_cfilter *cf,
|
|||
BIO *bio;
|
||||
CURLcode result;
|
||||
|
||||
DEBUGASSERT(ssl_connect_1 == connssl->connecting_state);
|
||||
DEBUGASSERT(connssl->connecting_state == ssl_connect_1);
|
||||
DEBUGASSERT(octx);
|
||||
DEBUGASSERT(connssl->peer.origin);
|
||||
|
||||
|
|
@ -4129,7 +4129,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
|
|||
struct ssl_connect_data *connssl = cf->ctx;
|
||||
struct ossl_ctx *octx = (struct ossl_ctx *)connssl->backend;
|
||||
struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
|
||||
DEBUGASSERT(ssl_connect_2 == connssl->connecting_state);
|
||||
DEBUGASSERT(connssl->connecting_state == ssl_connect_2);
|
||||
DEBUGASSERT(octx);
|
||||
|
||||
connssl->io_need = CURL_SSL_IO_NEED_NONE;
|
||||
|
|
@ -4161,25 +4161,25 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
|
|||
int detail = SSL_get_error(octx->ssl, err);
|
||||
CURL_TRC_CF(data, cf, "SSL_connect() -> err=%d, detail=%d", err, detail);
|
||||
|
||||
if(SSL_ERROR_WANT_READ == detail) {
|
||||
if(detail == SSL_ERROR_WANT_READ) {
|
||||
CURL_TRC_CF(data, cf, "SSL_connect() -> want recv");
|
||||
connssl->io_need = CURL_SSL_IO_NEED_RECV;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
if(SSL_ERROR_WANT_WRITE == detail) {
|
||||
if(detail == SSL_ERROR_WANT_WRITE) {
|
||||
CURL_TRC_CF(data, cf, "SSL_connect() -> want send");
|
||||
connssl->io_need = CURL_SSL_IO_NEED_SEND;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
#ifdef SSL_ERROR_WANT_ASYNC
|
||||
if(SSL_ERROR_WANT_ASYNC == detail) {
|
||||
if(detail == SSL_ERROR_WANT_ASYNC) {
|
||||
CURL_TRC_CF(data, cf, "SSL_connect() -> want async");
|
||||
connssl->io_need = CURL_SSL_IO_NEED_RECV;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
#endif
|
||||
#ifdef SSL_ERROR_WANT_RETRY_VERIFY
|
||||
if(SSL_ERROR_WANT_RETRY_VERIFY == detail) {
|
||||
if(detail == SSL_ERROR_WANT_RETRY_VERIFY) {
|
||||
CURL_TRC_CF(data, cf, "SSL_connect() -> want retry_verify");
|
||||
Curl_xfer_pause_recv(data, TRUE);
|
||||
return CURLE_AGAIN;
|
||||
|
|
@ -4856,7 +4856,7 @@ static CURLcode ossl_connect_step3(struct Curl_cfilter *cf,
|
|||
struct ssl_connect_data *connssl = cf->ctx;
|
||||
struct ossl_ctx *octx = (struct ossl_ctx *)connssl->backend;
|
||||
|
||||
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
|
||||
DEBUGASSERT(connssl->connecting_state == ssl_connect_3);
|
||||
|
||||
/*
|
||||
* We check certificates to authenticate the server; otherwise we risk
|
||||
|
|
@ -4968,7 +4968,7 @@ static CURLcode ossl_connect(struct Curl_cfilter *cf,
|
|||
*done = FALSE;
|
||||
connssl->io_need = CURL_SSL_IO_NEED_NONE;
|
||||
|
||||
if(ssl_connect_1 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_1) {
|
||||
if(Curl_ossl_need_httpsrr(data) &&
|
||||
!Curl_conn_dns_resolved_https(data, cf->sockindex,
|
||||
connssl->peer.peer)) {
|
||||
|
|
@ -4981,7 +4981,7 @@ static CURLcode ossl_connect(struct Curl_cfilter *cf,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if(ssl_connect_2 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_2) {
|
||||
CURL_TRC_CF(data, cf, "ossl_connect, step2");
|
||||
#ifdef HAVE_OPENSSL_EARLYDATA
|
||||
if(connssl->earlydata_state == ssl_earlydata_await) {
|
||||
|
|
@ -5002,7 +5002,7 @@ static CURLcode ossl_connect(struct Curl_cfilter *cf,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if(ssl_connect_3 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_3) {
|
||||
CURL_TRC_CF(data, cf, "ossl_connect, step3");
|
||||
result = ossl_connect_step3(cf, data);
|
||||
if(result)
|
||||
|
|
@ -5020,7 +5020,7 @@ static CURLcode ossl_connect(struct Curl_cfilter *cf,
|
|||
#endif
|
||||
}
|
||||
|
||||
if(ssl_connect_done == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_done) {
|
||||
CURL_TRC_CF(data, cf, "ossl_connect, done");
|
||||
connssl->state = ssl_connection_complete;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,8 +452,7 @@ static CURLcode get_client_cert(struct Curl_cfilter *cf,
|
|||
continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
|
||||
if(continue_reading && (certsize < CURL_MAX_INPUT_LENGTH))
|
||||
certdata = curlx_malloc(certsize + 1);
|
||||
if((!certdata) ||
|
||||
((int) fread(certdata, certsize, 1, fInCert) != 1))
|
||||
if(!certdata || ((int)fread(certdata, certsize, 1, fInCert) != 1))
|
||||
continue_reading = FALSE;
|
||||
curlx_fclose(fInCert);
|
||||
if(!continue_reading) {
|
||||
|
|
@ -1596,7 +1595,7 @@ static CURLcode schannel_connect_step3(struct Curl_cfilter *cf,
|
|||
SecPkgContext_ApplicationProtocol alpn_result;
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(ssl_connect_3 == connssl->connecting_state);
|
||||
DEBUGASSERT(connssl->connecting_state == ssl_connect_3);
|
||||
DEBUGASSERT(backend);
|
||||
|
||||
DEBUGF(infof(data, "schannel: SSL/TLS connection with %s port %d (step 3/3)",
|
||||
|
|
@ -1721,25 +1720,25 @@ static CURLcode schannel_connect(struct Curl_cfilter *cf,
|
|||
|
||||
*done = FALSE;
|
||||
|
||||
if(ssl_connect_1 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_1) {
|
||||
result = schannel_connect_step1(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(ssl_connect_2 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_2) {
|
||||
result = schannel_connect_step2(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(ssl_connect_3 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_3) {
|
||||
result = schannel_connect_step3(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
if(ssl_connect_done == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_done) {
|
||||
connssl->state = ssl_connection_complete;
|
||||
|
||||
#ifdef SECPKG_ATTR_ENDPOINT_BINDINGS /* mingw-w64 v9+, MS SDK 7.0A/VS2010+ */
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ CURLcode Curl_pin_peer_pubkey(struct Curl_easy *data,
|
|||
do {
|
||||
char buffer[1024];
|
||||
size_t want = left > sizeof(buffer) ? sizeof(buffer) : left;
|
||||
if(want != fread(buffer, 1, want, fp))
|
||||
if(fread(buffer, 1, want, fp) != want)
|
||||
goto end;
|
||||
if(curlx_dyn_addn(&buf, buffer, want))
|
||||
goto end;
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ static CURLcode wssl_populate_x509_store(struct Curl_cfilter *cf,
|
|||
ssl_cafile,
|
||||
ssl_capath,
|
||||
WOLFSSL_LOAD_FLAG_IGNORE_ERR);
|
||||
if(WOLFSSL_SUCCESS != rc) {
|
||||
if(rc != WOLFSSL_SUCCESS) {
|
||||
if(conn_config->verifypeer &&
|
||||
!imported_native_ca && !imported_ca_info_blob) {
|
||||
/* Fail if we insist on successfully verifying the server. */
|
||||
|
|
@ -1723,15 +1723,15 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
return CURLE_OK;
|
||||
}
|
||||
else {
|
||||
if(WOLFSSL_ERROR_WANT_READ == detail) {
|
||||
if(detail == WOLFSSL_ERROR_WANT_READ) {
|
||||
connssl->io_need = CURL_SSL_IO_NEED_RECV;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
else if(WOLFSSL_ERROR_WANT_WRITE == detail) {
|
||||
else if(detail == WOLFSSL_ERROR_WANT_WRITE) {
|
||||
connssl->io_need = CURL_SSL_IO_NEED_SEND;
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
else if(DOMAIN_NAME_MISMATCH == detail) {
|
||||
else if(detail == DOMAIN_NAME_MISMATCH) {
|
||||
/* There is no easy way to override only the CN matching.
|
||||
* This enables the override of both mismatching SubjectAltNames
|
||||
* as also mismatching CN fields */
|
||||
|
|
@ -1739,7 +1739,7 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
connssl->peer.origin->hostname);
|
||||
return CURLE_PEER_FAILED_VERIFICATION;
|
||||
}
|
||||
else if(ASN_NO_SIGNER_E == detail) {
|
||||
else if(detail == ASN_NO_SIGNER_E) {
|
||||
if(conn_config->verifypeer) {
|
||||
failf(data, " CA signer not available for verification");
|
||||
return CURLE_SSL_CACERT_BADFILE;
|
||||
|
|
@ -1750,11 +1750,11 @@ static CURLcode wssl_handshake(struct Curl_cfilter *cf, struct Curl_easy *data)
|
|||
"continuing anyway");
|
||||
return CURLE_OK;
|
||||
}
|
||||
else if(ASN_AFTER_DATE_E == detail) {
|
||||
else if(detail == ASN_AFTER_DATE_E) {
|
||||
failf(data, "server verification failed: certificate has expired.");
|
||||
return CURLE_PEER_FAILED_VERIFICATION;
|
||||
}
|
||||
else if(ASN_BEFORE_DATE_E == detail) {
|
||||
else if(detail == ASN_BEFORE_DATE_E) {
|
||||
failf(data, "server verification failed: certificate not valid yet.");
|
||||
return CURLE_PEER_FAILED_VERIFICATION;
|
||||
}
|
||||
|
|
@ -1923,7 +1923,7 @@ static CURLcode wssl_shutdown(struct Curl_cfilter *cf,
|
|||
*done = TRUE;
|
||||
goto out;
|
||||
}
|
||||
if(WOLFSSL_ERROR_WANT_WRITE == wolfSSL_get_error(wctx->ssl, nread)) {
|
||||
if(wolfSSL_get_error(wctx->ssl, nread) == WOLFSSL_ERROR_WANT_WRITE) {
|
||||
CURL_TRC_CF(data, cf, "SSL shutdown still wants to send");
|
||||
connssl->io_need = CURL_SSL_IO_NEED_SEND;
|
||||
goto out;
|
||||
|
|
@ -2116,7 +2116,7 @@ static CURLcode wssl_connect(struct Curl_cfilter *cf,
|
|||
*done = FALSE;
|
||||
connssl->io_need = CURL_SSL_IO_NEED_NONE;
|
||||
|
||||
if(ssl_connect_1 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_1) {
|
||||
#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG
|
||||
/* if we do ECH and need the HTTPS-RR information for it,
|
||||
* we delay the connect until it arrives or DNS resolve fails. */
|
||||
|
|
@ -2133,7 +2133,7 @@ static CURLcode wssl_connect(struct Curl_cfilter *cf,
|
|||
connssl->connecting_state = ssl_connect_2;
|
||||
}
|
||||
|
||||
if(ssl_connect_2 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_2) {
|
||||
if(connssl->earlydata_state == ssl_earlydata_await) {
|
||||
/* We defer the handshake until request data arrives. */
|
||||
DEBUGASSERT(connssl->state == ssl_connection_deferred);
|
||||
|
|
@ -2146,7 +2146,7 @@ static CURLcode wssl_connect(struct Curl_cfilter *cf,
|
|||
connssl->connecting_state = ssl_connect_3;
|
||||
}
|
||||
|
||||
if(ssl_connect_3 == connssl->connecting_state) {
|
||||
if(connssl->connecting_state == ssl_connect_3) {
|
||||
/* Once the handshake has errored, it stays in that state and
|
||||
* errors again on every call. */
|
||||
if(wssl->hs_result) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue