tidy-up: replace (0 == expressions

This commit is contained in:
Viktor Szakats 2025-07-09 19:58:33 +02:00
parent 2530adcf4d
commit bc72ca01e9
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
17 changed files with 23 additions and 23 deletions

View file

@ -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,

View file

@ -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 = "/";
/*

View file

@ -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);

View file

@ -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))

View file

@ -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();

View file

@ -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 */

View file

@ -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;

View file

@ -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]);

View file

@ -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 */

View file

@ -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);

View file

@ -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:

View file

@ -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));

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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;