tidy-up: move literals to right-side of if expressions (where missing)

Closes #20535
This commit is contained in:
Viktor Szakats 2026-02-07 15:59:59 +01:00
parent c6ac2de5b3
commit 85de995208
No known key found for this signature in database
57 changed files with 115 additions and 115 deletions

View file

@ -406,7 +406,7 @@ CURLcode Curl_socket_open(struct Curl_easy *data,
static int socket_close(struct Curl_easy *data, struct connectdata *conn,
int use_callback, curl_socket_t sock)
{
if(CURL_SOCKET_BAD == sock)
if(sock == CURL_SOCKET_BAD)
return 0;
if(use_callback && conn && conn->fclosesocket) {
@ -932,7 +932,7 @@ static void cf_socket_close(struct Curl_cfilter *cf, struct Curl_easy *data)
{
struct cf_socket_ctx *ctx = cf->ctx;
if(ctx && CURL_SOCKET_BAD != ctx->sock) {
if(ctx && ctx->sock != CURL_SOCKET_BAD) {
CURL_TRC_CF(data, cf, "cf_socket_close, fd=%" FMT_SOCKET_T, ctx->sock);
if(ctx->sock == cf->conn->sock[cf->sockindex])
cf->conn->sock[cf->sockindex] = CURL_SOCKET_BAD;
@ -2065,7 +2065,7 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf,
s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *)&add, &size);
#endif
if(CURL_SOCKET_BAD == s_accepted) {
if(s_accepted == CURL_SOCKET_BAD) {
failf(data, "Error accept()ing server connect: %s",
curlx_strerror(SOCKERRNO, errbuf, sizeof(errbuf)));
return CURLE_FTP_ACCEPT_FAILED;

View file

@ -871,7 +871,7 @@ CURLcode Curl_conn_cf_cntrl(struct Curl_cfilter *cf,
CURLcode result = CURLE_OK;
for(; cf; cf = cf->next) {
if(Curl_cf_def_cntrl == cf->cft->cntrl)
if(cf->cft->cntrl == Curl_cf_def_cntrl)
continue;
result = cf->cft->cntrl(cf, data, event, arg1, arg2);
if(!ignore_result && result)

View file

@ -192,7 +192,7 @@ static CURLcode cw_out_cb_write(struct cw_out_ctx *ctx,
CURL_TRC_WRITE(data, "[OUT] wrote %zu %s bytes -> %zu",
blen, (otype == CW_OUT_HDS) ? "header" : "body",
nwritten);
if(CURL_WRITEFUNC_PAUSE == nwritten) {
if(nwritten == CURL_WRITEFUNC_PAUSE) {
if(data->conn->scheme->flags & PROTOPT_NONETWORK) {
/* Protocols that work without network cannot be paused. This is
actually only FILE:// just now, and it cannot pause since the
@ -205,7 +205,7 @@ static CURLcode cw_out_cb_write(struct cw_out_ctx *ctx,
result = Curl_xfer_pause_recv(data, TRUE);
return result ? result : CURLE_AGAIN;
}
else if(CURL_WRITEFUNC_ERROR == nwritten) {
else if(nwritten == CURL_WRITEFUNC_ERROR) {
failf(data, "client returned ERROR on write of %zu bytes", blen);
return CURLE_WRITE_ERROR;
}

View file

@ -3616,7 +3616,7 @@ static CURLcode ftp_done(struct Curl_easy *data, CURLcode status,
pp->response = *Curl_pgrs_now(data); /* timeout relative now */
result = getftpresponse(data, &nread, &ftpcode);
if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) {
if(!nread && (result == CURLE_OPERATION_TIMEDOUT)) {
failf(data, "control connection looks dead");
ftpc->ctl_valid = FALSE; /* mark control connection as bad */
connclose(conn, "Timeout or similar in FTP DONE operation"); /* close */

View file

@ -3103,7 +3103,7 @@ CURLcode Curl_http(struct Curl_easy *data, bool *done)
data->req.upload_chunky = FALSE;
out:
if(CURLE_TOO_LARGE == result)
if(result == CURLE_TOO_LARGE)
failf(data, "HTTP request too large");
/* clear userpwd and proxyuserpwd to avoid reusing old credentials

View file

@ -203,7 +203,7 @@ if2ip_result_t Curl_if2ip(int af,
return IF2IP_NOT_FOUND;
dummy = CURL_SOCKET(AF_INET, SOCK_STREAM, 0);
if(CURL_SOCKET_BAD == dummy)
if(dummy == CURL_SOCKET_BAD)
return IF2IP_NOT_FOUND;
memset(&req, 0, sizeof(req));

View file

@ -725,7 +725,7 @@ MQTT_SUBACK_COMING:
rest = sizeof(buffer);
result = Curl_xfer_recv(data, buffer, rest, &nread);
if(result) {
if(CURLE_AGAIN == result) {
if(result == CURLE_AGAIN) {
infof(data, "EEEE AAAAGAIN");
}
goto end;

View file

@ -707,7 +707,7 @@ static CURLcode multi_done(struct Curl_easy *data,
else
result = status;
if(CURLE_ABORTED_BY_CALLBACK != result) {
if(result != CURLE_ABORTED_BY_CALLBACK) {
/* avoid this if we already aborted by callback to avoid this calling
another callback */
int rc = Curl_pgrsDone(data);
@ -1956,7 +1956,7 @@ static CURLMcode state_performing(struct Curl_easy *data,
}
}
#ifndef CURL_DISABLE_HTTP
else if((CURLE_HTTP2_STREAM == result) &&
else if((result == CURLE_HTTP2_STREAM) &&
Curl_h2_http_1_1_error(data)) {
CURLcode ret = Curl_retry_request(data, &newurl);
@ -2135,7 +2135,7 @@ static CURLMcode state_do(struct Curl_easy *data,
mresult = CURLM_CALL_MULTI_PERFORM;
}
}
else if((CURLE_SEND_ERROR == result) &&
else if((result == CURLE_SEND_ERROR) &&
data->conn->bits.reuse) {
/*
* In this situation, a connection that we were trying to use may have
@ -2282,7 +2282,7 @@ static CURLMcode state_connect(struct Curl_multi *multi,
bool async;
CURLMcode mresult = CURLM_OK;
CURLcode result = Curl_connect(data, &async, &connected);
if(CURLE_NO_CONNECTION_AVAILABLE == result) {
if(result == CURLE_NO_CONNECTION_AVAILABLE) {
/* There was no connection available. We will go to the pending state and
wait for an available connection. */
multistate(data, MSTATE_PENDING);

View file

@ -648,7 +648,7 @@ static CURLcode rtp_client_write(struct Curl_easy *data, const char *ptr,
wrote = writeit((char *)CURL_UNCONST(ptr), 1, len, user_ptr);
Curl_set_in_callback(data, FALSE);
if(CURL_WRITEFUNC_PAUSE == wrote) {
if(wrote == CURL_WRITEFUNC_PAUSE) {
failf(data, "Cannot pause RTP");
return CURLE_WRITE_ERROR;
}

View file

@ -137,7 +137,7 @@ CURLcode Curl_blockread_all(struct Curl_cfilter *cf,
if(SOCKET_READABLE(cf->conn->sock[cf->sockindex], timeout_ms) <= 0)
return CURLE_OPERATION_TIMEDOUT;
result = Curl_conn_cf_recv(cf->next, data, buf, blen, &nread);
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
continue;
else if(result)
return result;

View file

@ -1082,7 +1082,7 @@ static CURLcode h3_open_stream(struct Curl_cfilter *cf,
CURLcode r2 = CURLE_OK;
r2 = cf_quiche_send_body(cf, data, stream, buf, blen, eos, &nwritten);
if(r2 && (CURLE_AGAIN != r2)) { /* real error, fail */
if(r2 && (r2 != CURLE_AGAIN)) { /* real error, fail */
result = r2;
}
else if(nwritten > 0) {

View file

@ -97,7 +97,7 @@ static ssize_t gtls_push(void *s, const void *buf, size_t blen)
if(result) {
/* !checksrc! disable ERRNOVAR 1 */
gnutls_transport_set_errno(backend->gtls.session,
(CURLE_AGAIN == result) ? EAGAIN : EINVAL);
(result == CURLE_AGAIN) ? EAGAIN : EINVAL);
return -1;
}
return (ssize_t)nwritten;
@ -130,7 +130,7 @@ static ssize_t gtls_pull(void *s, void *buf, size_t blen)
if(result) {
/* !checksrc! disable ERRNOVAR 1 */
gnutls_transport_set_errno(backend->gtls.session,
(CURLE_AGAIN == result) ? EAGAIN : EINVAL);
(result == CURLE_AGAIN) ? EAGAIN : EINVAL);
return -1;
}
else if(nread == 0)

View file

@ -141,7 +141,7 @@ static int mbedtls_bio_cf_write(void *bio,
result = Curl_conn_cf_send(cf->next, data, buf, blen, FALSE, &nwritten);
CURL_TRC_CF(data, cf, "mbedtls_bio_cf_out_write(len=%zu) -> %d, %zu",
blen, result, nwritten);
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
return MBEDTLS_ERR_SSL_WANT_WRITE;
return result ? -1 : (int)nwritten;
}
@ -163,7 +163,7 @@ static int mbedtls_bio_cf_read(void *bio, unsigned char *buf, size_t blen)
result = Curl_conn_cf_recv(cf->next, data, (char *)buf, blen, &nread);
CURL_TRC_CF(data, cf, "mbedtls_bio_cf_in_read(len=%zu) -> %d, %zu",
blen, result, nread);
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
return MBEDTLS_ERR_SSL_WANT_READ;
/* nread is never larger than int here */
return result ? -1 : (int)nread;

View file

@ -589,7 +589,7 @@ static int ossl_bio_cf_out_write(BIO *bio, const char *buf, int blen)
BIO_clear_retry_flags(bio);
octx->io_result = result;
if(result) {
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
BIO_set_retry_write(bio);
return -1;
}
@ -618,7 +618,7 @@ static int ossl_bio_cf_in_read(BIO *bio, char *buf, int blen)
BIO_clear_retry_flags(bio);
octx->io_result = result;
if(result) {
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
BIO_set_retry_read(bio);
}
else {
@ -4255,7 +4255,7 @@ static CURLcode ossl_connect_step2(struct Curl_cfilter *cf,
* (RST connection, etc.), OpenSSL gives no explanation whatsoever and
* the SO_ERROR is also lost.
*/
if(CURLE_SSL_CONNECT_ERROR == result && errdetail == 0) {
if(result == CURLE_SSL_CONNECT_ERROR && errdetail == 0) {
char extramsg[80] = "";
int sockerr = SOCKERRNO;

View file

@ -105,7 +105,7 @@ static int read_cb(void *userdata, uint8_t *buf, uintptr_t len,
if(result) {
nread = 0;
/* !checksrc! disable ERRNOVAR 4 */
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
ret = EAGAIN;
else
ret = EINVAL;
@ -130,7 +130,7 @@ static int write_cb(void *userdata, const uint8_t *buf, uintptr_t len,
buf, len, FALSE, &nwritten);
if(result) {
nwritten = 0;
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
ret = EAGAIN;
else
ret = EINVAL;
@ -355,7 +355,7 @@ static CURLcode cr_send(struct Curl_cfilter *cf, struct Curl_easy *data,
result = cr_flush_out(cf, data, rconn);
if(result) {
if(CURLE_AGAIN == result) {
if(result == CURLE_AGAIN) {
/* The TLS bytes may have been partially written, but we fail the
* complete send() and remember how much we already added to Rustls. */
backend->plain_out_buffered = plainwritten;

View file

@ -322,7 +322,7 @@ static int wssl_bio_cf_out_write(WOLFSSL_BIO *bio, const char *buf, int blen)
#ifdef USE_FULL_BIO
wolfSSL_BIO_clear_retry_flags(bio);
#endif
if(CURLE_AGAIN == result) {
if(result == CURLE_AGAIN) {
wolfSSL_BIO_set_retry_write(bio);
if(wssl->shutting_down && !wssl->io_send_blocked_len)
wssl->io_send_blocked_len = blen;
@ -367,7 +367,7 @@ static int wssl_bio_cf_in_read(WOLFSSL_BIO *bio, char *buf, int blen)
#ifdef USE_FULL_BIO
wolfSSL_BIO_clear_retry_flags(bio);
#endif
if(CURLE_AGAIN == result)
if(result == CURLE_AGAIN)
wolfSSL_BIO_set_retry_read(bio);
else if(nread == 0)
connssl->peer_closed = TRUE;