From bc72ca01e96e072ac1a715eefc2a1ebab9e575d5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 9 Jul 2025 19:58:33 +0200 Subject: [PATCH] tidy-up: replace `(0 == ` expressions --- lib/cf-socket.c | 4 ++-- lib/cookie.c | 2 +- lib/curl_addrinfo.c | 2 +- lib/curl_sha512_256.c | 4 ++-- lib/curlx/timeval.c | 6 +++--- lib/http.c | 2 +- lib/http_chunks.c | 6 +++--- lib/memdebug.c | 2 +- lib/progress.c | 2 +- lib/strequal.c | 2 +- lib/transfer.c | 2 +- lib/vtls/openssl.c | 2 +- lib/vtls/schannel.c | 2 +- lib/vtls/vtls.c | 2 +- src/tool_msgs.c | 2 +- src/tool_operate.c | 2 +- tests/server/sws.c | 2 +- 17 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 8e6806cc41..91d07eb86b 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -860,7 +860,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) err = 0; } #endif - if((0 == err) || (SOCKEISCONN == err)) + if((err == 0) || (SOCKEISCONN == err)) /* we are connected, awesome! */ rc = TRUE; else @@ -2111,7 +2111,7 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf, return CURLE_OK; } - if(0 == getsockname(ctx->sock, (struct sockaddr *) &add, &size)) { + if(!getsockname(ctx->sock, (struct sockaddr *) &add, &size)) { size = sizeof(add); #ifdef HAVE_ACCEPT4 s_accepted = accept4(ctx->sock, (struct sockaddr *) &add, &size, diff --git a/lib/cookie.c b/lib/cookie.c index 1c7fd60f41..60b2d15cb5 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -173,7 +173,7 @@ static bool pathmatch(const char *cookie_path, const char *uri_path) } /* #-fragments are already cut off! */ - if(0 == strlen(uri_path) || uri_path[0] != '/') + if(strlen(uri_path) == 0 || uri_path[0] != '/') uri_path = "/"; /* diff --git a/lib/curl_addrinfo.c b/lib/curl_addrinfo.c index b131c747b1..6d5a3296a6 100644 --- a/lib/curl_addrinfo.c +++ b/lib/curl_addrinfo.c @@ -552,7 +552,7 @@ curl_dbg_getaddrinfo(const char *hostname, #else int res = getaddrinfo(hostname, service, hints, result); #endif - if(0 == res) + if(res == 0) /* success */ curl_dbg_log("ADDR %s:%d getaddrinfo() = %p\n", source, line, (void *)*result); diff --git a/lib/curl_sha512_256.c b/lib/curl_sha512_256.c index cb0a486d64..fad43d2a33 100644 --- a/lib/curl_sha512_256.c +++ b/lib/curl_sha512_256.c @@ -317,7 +317,7 @@ static CURL_FORCEINLINE curl_uint64_t Curl_rotr64(curl_uint64_t value, unsigned int bits) { bits %= 64; - if(0 == bits) + if(bits == 0) return value; /* Defined in a form which modern compiler could optimize. */ return (value >> bits) | (value << (64 - bits)); @@ -621,7 +621,7 @@ static CURLcode Curl_sha512_256_update(void *context, DEBUGASSERT((data != NULL) || (length == 0)); - if(0 == length) + if(length == 0) return CURLE_OK; /* Shortcut, do nothing */ /* Note: (count & (CURL_SHA512_256_BLOCK_SIZE-1)) diff --git a/lib/curlx/timeval.c b/lib/curlx/timeval.c index 01393bd528..bd8b9bcee2 100644 --- a/lib/curlx/timeval.c +++ b/lib/curlx/timeval.c @@ -115,7 +115,7 @@ struct curltime curlx_now(void) (HAVE_BUILTIN_AVAILABLE == 1) have_clock_gettime && #endif - (0 == clock_gettime(CLOCK_MONOTONIC_RAW, &tsnow))) { + (clock_gettime(CLOCK_MONOTONIC_RAW, &tsnow) == 0)) { cnow.tv_sec = tsnow.tv_sec; cnow.tv_usec = (int)(tsnow.tv_nsec / 1000); } @@ -127,7 +127,7 @@ struct curltime curlx_now(void) (HAVE_BUILTIN_AVAILABLE == 1) have_clock_gettime && #endif - (0 == clock_gettime(CLOCK_MONOTONIC, &tsnow))) { + (clock_gettime(CLOCK_MONOTONIC, &tsnow) == 0)) { cnow.tv_sec = tsnow.tv_sec; cnow.tv_usec = (int)(tsnow.tv_nsec / 1000); } @@ -168,7 +168,7 @@ struct curltime curlx_now(void) struct curltime cnow; uint64_t usecs; - if(0 == timebase.denom) + if(timebase.denom == 0) (void)mach_timebase_info(&timebase); usecs = mach_absolute_time(); diff --git a/lib/http.c b/lib/http.c index 890b0fb5a1..ac780c1095 100644 --- a/lib/http.c +++ b/lib/http.c @@ -3949,7 +3949,7 @@ static CURLcode http_on_response(struct Curl_easy *data, like to call http2_handle_stream_close to properly close a stream. In order to do this, we keep reading until we close the stream. */ - if((0 == k->maxdownload) && (k->httpversion_sent < 20)) + if((k->maxdownload == 0) && (k->httpversion_sent < 20)) k->download_done = TRUE; /* final response without error, prepare to receive the body */ diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 63e477c48a..f014a256ab 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -159,7 +159,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, } else { const char *p; - if(0 == ch->hexindex) { + if(ch->hexindex == 0) { /* This is illegal data, we received junk where we expected a hexadecimal digit. */ failf(data, "chunk hex-length char not a hex digit: 0x%x", *buf); @@ -184,7 +184,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, /* waiting for the LF after a chunk size */ if(*buf == 0x0a) { /* we are now expecting data to come, unless size was zero! */ - if(0 == ch->datasize) { + if(ch->datasize == 0) { ch->state = CHUNK_TRAILER; /* now check for trailers */ } else { @@ -229,7 +229,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, FMT_OFF_T " bytes in chunk remain", piece, ch->datasize); - if(0 == ch->datasize) + if(ch->datasize == 0) /* end of data this round, we now expect a trailing CRLF */ ch->state = CHUNK_POSTLF; break; diff --git a/lib/memdebug.c b/lib/memdebug.c index bdcdcbb907..d063f94c32 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -356,7 +356,7 @@ int curl_dbg_socketpair(int domain, int type, int protocol, { int res = (socketpair)(domain, type, protocol, socket_vector); - if(source && (0 == res)) + if(source && (res == 0)) curl_dbg_log("FD %s:%d socketpair() = " "%" FMT_SOCKET_T " %" FMT_SOCKET_T "\n", source, line, socket_vector[0], socket_vector[1]); diff --git a/lib/progress.c b/lib/progress.c index 746805f20f..1a3f4334ca 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -449,7 +449,7 @@ static bool progress_calc(struct Curl_easy *data, struct curltime now) /* Figure out the exact time for the time span */ span_ms = curlx_timediff(now, p->speeder_time[checkindex]); - if(0 == span_ms) + if(span_ms == 0) span_ms = 1; /* at least one millisecond MUST have passed */ /* Calculate the average speed the last 'span_ms' milliseconds */ diff --git a/lib/strequal.c b/lib/strequal.c index fb6be51dd5..17dd34b7f3 100644 --- a/lib/strequal.c +++ b/lib/strequal.c @@ -59,7 +59,7 @@ static int ncasecompare(const char *first, const char *second, size_t max) first++; second++; } - if(0 == max) + if(max == 0) return 1; /* they are equal this far */ return Curl_raw_toupper(*first) == Curl_raw_toupper(*second); diff --git a/lib/transfer.c b/lib/transfer.c index 15a61f6997..84e4c5e927 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -481,7 +481,7 @@ CURLcode Curl_sendrecv(struct Curl_easy *data, struct curltime *nowp) } /* If there is nothing more to send/recv, the request is done */ - if(0 == (k->keepon&(KEEP_RECVBITS|KEEP_SENDBITS))) + if((k->keepon & (KEEP_RECVBITS|KEEP_SENDBITS)) == 0) data->req.done = TRUE; out: diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 4e951d11e8..eda19de8aa 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -958,7 +958,7 @@ static char *ossl_strerror(unsigned long error, char *buf, size_t size) static int passwd_callback(char *buf, int num, int encrypting, void *password) { - DEBUGASSERT(0 == encrypting); + DEBUGASSERT(encrypting == 0); if(!encrypting && num >= 0 && password) { int klen = curlx_uztosi(strlen((char *)password)); diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 5e1a2fa7f2..fe997ee200 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -1816,7 +1816,7 @@ schannel_send(struct Curl_cfilter *cf, struct Curl_easy *data, result = CURLE_SEND_ERROR; break; } - else if(0 == what) { + else if(what == 0) { failf(data, "schannel: timed out sending data " "(bytes sent: %zu)", *pnwritten); result = CURLE_OPERATION_TIMEDOUT; diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 838cc24266..e4d20e2123 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -1790,7 +1790,7 @@ static CURLcode vtls_shutdown_blocking(struct Curl_cfilter *cf, result = CURLE_RECV_ERROR; goto out; } - else if(0 == what) { + else if(what == 0) { /* timeout */ failf(data, "SSL shutdown timeout"); result = CURLE_OPERATION_TIMEDOUT; diff --git a/src/tool_msgs.c b/src/tool_msgs.c index 294e27ad43..8c954cced0 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -66,7 +66,7 @@ static void voutf(struct GlobalConfig *global, while(!ISBLANK(ptr[cut]) && cut) { cut--; } - if(0 == cut) + if(cut == 0) /* not a single cutting position was found, just cut it at the max text width then! */ cut = width-1; diff --git a/src/tool_operate.c b/src/tool_operate.c index 7abad907bc..764c98b587 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1009,7 +1009,7 @@ static CURLcode setup_outfile(struct OperationConfig *config, of the file as it is now and open it for append instead */ struct_stat fileinfo; /* VMS -- Danger, the filesize is only valid for stream files */ - if(0 == stat(per->outfile, &fileinfo)) + if(stat(per->outfile, &fileinfo) == 0) /* set offset to current file size: */ config->resume_from = fileinfo.st_size; else diff --git a/tests/server/sws.c b/tests/server/sws.c index 1ef9af9f24..22bb5fd920 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -1324,7 +1324,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) if(getsockopt(serverfd, SOL_SOCKET, SO_ERROR, (void *)&error, &errSize)) error = SOCKERRNO; - if((0 == error) || (SOCKEISCONN == error)) + if((error == 0) || (SOCKEISCONN == error)) goto success; else if((error != SOCKEINPROGRESS) && (error != SOCKEWOULDBLOCK)) goto error;