diff --git a/docs/examples/multithread.c b/docs/examples/multithread.c index 7978419bdc..ceee94022a 100644 --- a/docs/examples/multithread.c +++ b/docs/examples/multithread.c @@ -80,7 +80,7 @@ int main(void) NULL, /* default attributes please */ pull_one_url, (void *)urls[i]); - if(0 != error) + if(error) fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); else fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]); diff --git a/docs/examples/smooth-gtk-thread.c b/docs/examples/smooth-gtk-thread.c index c53951262a..49a412d958 100644 --- a/docs/examples/smooth-gtk-thread.c +++ b/docs/examples/smooth-gtk-thread.c @@ -130,7 +130,7 @@ void *create_thread(void *progress_bar) NULL, /* default attributes please */ pull_one_url, NULL); - if(0 != error) + if(error) fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); else fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]); diff --git a/docs/examples/threaded-ssl.c b/docs/examples/threaded-ssl.c index 263400afd8..9668129055 100644 --- a/docs/examples/threaded-ssl.c +++ b/docs/examples/threaded-ssl.c @@ -83,7 +83,7 @@ int main(int argc, char **argv) NULL, /* default attributes please */ pull_one_url, (void *)urls[i]); - if(0 != error) + if(error) fprintf(stderr, "Couldn't run thread number %d, errno %d\n", i, error); else fprintf(stderr, "Thread %d, gets %s\n", i, urls[i]); diff --git a/docs/internals/CODE_STYLE.md b/docs/internals/CODE_STYLE.md index 24e669c35b..dadec934dd 100644 --- a/docs/internals/CODE_STYLE.md +++ b/docs/internals/CODE_STYLE.md @@ -253,7 +253,7 @@ If no parenthesis, use the default indent: ```c data->set.http_disable_hostname_check_before_authentication = - (0 != va_arg(param, long)) ? TRUE : FALSE; + va_arg(param, long) ? TRUE : FALSE; ``` Function invoke with an open parenthesis: diff --git a/lib/cf-socket.c b/lib/cf-socket.c index 273258feaf..8e6806cc41 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -844,7 +844,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error) #endif - if(0 != getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize)) + if(getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void *)&err, &errSize)) err = SOCKERRNO; #ifdef UNDER_CE /* Old Windows CE versions do not support SO_ERROR */ diff --git a/lib/curl_sha512_256.c b/lib/curl_sha512_256.c index d730c59a1b..cb0a486d64 100644 --- a/lib/curl_sha512_256.c +++ b/lib/curl_sha512_256.c @@ -633,7 +633,7 @@ static CURLcode Curl_sha512_256_update(void *context, ctx->count_bits_hi += ctx->count >> 61; ctx->count &= CURL_UINT64_C(0x1FFFFFFFFFFFFFFF); - if(0 != bytes_have) { + if(bytes_have) { unsigned int bytes_left = CURL_SHA512_256_BLOCK_SIZE - bytes_have; if(length >= bytes_left) { /* Combine new data with data in the buffer and process the full @@ -656,7 +656,7 @@ static CURLcode Curl_sha512_256_update(void *context, length -= CURL_SHA512_256_BLOCK_SIZE; } - if(0 != length) { + if(length) { /* Copy incomplete block of new data (if any) to the buffer. */ memcpy(((unsigned char *) ctx_buf) + bytes_have, data, length); diff --git a/lib/setopt.c b/lib/setopt.c index 1380c33db6..cb3d539186 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -441,7 +441,7 @@ static void set_ssl_options(struct ssl_config_data *ssl, static CURLcode setopt_long(struct Curl_easy *data, CURLoption option, long arg) { - bool enabled = (0 != arg); + bool enabled = !!arg; unsigned long uarg = (unsigned long)arg; switch(option) { case CURLOPT_DNS_CACHE_TIMEOUT: diff --git a/lib/strerror.c b/lib/strerror.c index 90694882c3..f0f36ed1b7 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -809,7 +809,7 @@ const char *Curl_strerror(int err, char *buf, size_t buflen) * storage is supplied via 'strerrbuf' and 'buflen' to hold the generated * message string, or EINVAL if 'errnum' is not a valid error number. */ - if(0 != strerror_r(err, buf, buflen)) { + if(strerror_r(err, buf, buflen)) { if('\0' == buf[0]) curl_msnprintf(buf, buflen, "Unknown error %d", err); } diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index 8d16d70392..5e1a2fa7f2 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -379,7 +379,7 @@ set_ssl_ciphers(SCHANNEL_CRED *schannel_cred, char *ciphers, { const char *startCur = ciphers; int algCount = 0; - while(startCur && (0 != *startCur) && (algCount < NUM_CIPHERS)) { + while(startCur && *startCur && (algCount < NUM_CIPHERS)) { curl_off_t alg; if(curlx_str_number(&startCur, &alg, INT_MAX) || !alg) alg = get_alg_id_by_name(startCur); diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 942224feff..838cc24266 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -670,7 +670,7 @@ static CURLcode pubkey_pem_to_der(const char *pem, pem_count = begin_pos - pem; /* Invalid if not at beginning AND not directly following \n */ - if(0 != pem_count && '\n' != pem[pem_count - 1]) + if(pem_count && '\n' != pem[pem_count - 1]) return CURLE_BAD_CONTENT_ENCODING; /* 26 is length of "-----BEGIN PUBLIC KEY-----" */ diff --git a/tests/server/rtspd.c b/tests/server/rtspd.c index 7f1ce81022..f8a992f700 100644 --- a/tests/server/rtspd.c +++ b/tests/server/rtspd.c @@ -784,7 +784,7 @@ static int rtspd_send_doc(curl_socket_t sock, struct rtspd_httprequest *req) else { FILE *stream = test2fopen(req->testno, logdir); char partbuf[80]="data"; - if(0 != req->partno) + if(req->partno) snprintf(partbuf, sizeof(partbuf), "data%ld", req->partno); if(!stream) { error = errno; @@ -1099,8 +1099,8 @@ static int test_rtspd(int argc, char *argv[]) } flag = 1; - if(0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, sstrerror(error)); diff --git a/tests/server/sws.c b/tests/server/sws.c index f49f22339d..860de6977f 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -1243,8 +1243,8 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) if(socket_domain_is_ip()) { /* Disable the Nagle algorithm */ curl_socklen_t flag = 1; - if(0 != setsockopt(serverfd, IPPROTO_TCP, TCP_NODELAY, - (void *)&flag, sizeof(flag))) + if(setsockopt(serverfd, IPPROTO_TCP, TCP_NODELAY, + (void *)&flag, sizeof(flag))) logmsg("====> TCP_NODELAY for server connection failed"); } #endif @@ -1252,7 +1252,7 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) /* We want to do the connect() in a non-blocking mode, since * Windows has an internal retry logic that may lead to long * timeouts if the peer is not listening. */ - if(0 != curlx_nonblock(serverfd, TRUE)) { + if(curlx_nonblock(serverfd, TRUE)) { error = SOCKERRNO; logmsg("curlx_nonblock(TRUE) failed with error (%d) %s", error, sstrerror(error)); @@ -1321,8 +1321,8 @@ static curl_socket_t connect_to(const char *ipaddr, unsigned short port) goto error; else if(rc > 0) { curl_socklen_t errSize = sizeof(error); - if(0 != getsockopt(serverfd, SOL_SOCKET, SO_ERROR, - (void *)&error, &errSize)) + if(getsockopt(serverfd, SOL_SOCKET, SO_ERROR, + (void *)&error, &errSize)) error = SOCKERRNO; if((0 == error) || (SOCKEISCONN == error)) goto success; @@ -1346,7 +1346,7 @@ success: logmsg("connected fine to %s%s%s:%hu, now tunnel", op_br, ipaddr, cl_br, port); - if(0 != curlx_nonblock(serverfd, FALSE)) { + if(curlx_nonblock(serverfd, FALSE)) { error = SOCKERRNO; logmsg("curlx_nonblock(FALSE) failed with error (%d) %s", error, sstrerror(error)); @@ -1549,8 +1549,8 @@ static void http_connect(curl_socket_t *infdp, if(socket_domain_is_ip()) { /* Disable the Nagle algorithm */ curl_socklen_t flag = 1; - if(0 != setsockopt(datafd, IPPROTO_TCP, TCP_NODELAY, - (void *)&flag, sizeof(flag))) + if(setsockopt(datafd, IPPROTO_TCP, TCP_NODELAY, + (void *)&flag, sizeof(flag))) logmsg("====> TCP_NODELAY for client DATA connection failed"); } #endif @@ -1839,7 +1839,7 @@ static curl_socket_t accept_connection(curl_socket_t sock) return CURL_SOCKET_BAD; } - if(0 != curlx_nonblock(msgsock, TRUE)) { + if(curlx_nonblock(msgsock, TRUE)) { error = SOCKERRNO; logmsg("curlx_nonblock failed with error (%d) %s", error, sstrerror(error)); @@ -1847,8 +1847,8 @@ static curl_socket_t accept_connection(curl_socket_t sock) return CURL_SOCKET_BAD; } - if(0 != setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, - (void *)&flag, sizeof(flag))) { + if(setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, + (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_KEEPALIVE) failed with error (%d) %s", error, sstrerror(error)); @@ -1877,8 +1877,8 @@ static curl_socket_t accept_connection(curl_socket_t sock) * Disable the Nagle algorithm to make it easier to send out a large * response in many small segments to torture the clients more. */ - if(0 != setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY, - (void *)&flag, sizeof(flag))) + if(setsockopt(msgsock, IPPROTO_TCP, TCP_NODELAY, + (void *)&flag, sizeof(flag))) logmsg("====> TCP_NODELAY failed"); } #endif @@ -2162,14 +2162,14 @@ static int test_sws(int argc, char *argv[]) } flag = 1; - if(0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, sstrerror(error)); goto sws_cleanup; } - if(0 != curlx_nonblock(sock, TRUE)) { + if(curlx_nonblock(sock, TRUE)) { error = SOCKERRNO; logmsg("curlx_nonblock failed with error (%d) %s", error, sstrerror(error)); diff --git a/tests/server/tftpd.c b/tests/server/tftpd.c index bd2d42bd6f..203bbb2598 100644 --- a/tests/server/tftpd.c +++ b/tests/server/tftpd.c @@ -662,8 +662,8 @@ static int test_tftpd(int argc, char **argv) } flag = 1; - if(0 != setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (void *)&flag, sizeof(flag))) { + if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, + (void *)&flag, sizeof(flag))) { error = SOCKERRNO; logmsg("setsockopt(SO_REUSEADDR) failed with error (%d) %s", error, sstrerror(error)); @@ -1118,7 +1118,7 @@ static int validate_access(struct testcase *test, stream = test2fopen(testno, logdir); - if(0 != partno) + if(partno) snprintf(partbuf, sizeof(partbuf), "data%ld", partno); if(!stream) {