From: Daniel Stenberg Date: Mon, 28 Oct 2024 16:26:19 +0000 (+0100) Subject: src/lib: remove redundant ternary operators X-Git-Tag: curl-8_11_0~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd2b45201a99bf0c22d7c67ad0e61eb2a88abd00;p=thirdparty%2Fcurl.git src/lib: remove redundant ternary operators Closes #15435 --- diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index a9fd21fa4d..6b7f9831bc 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -299,7 +299,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf, (checkprefix("Proxy-authenticate:", header) && (407 == k->httpcode))) { - bool proxy = (k->httpcode == 407) ? TRUE : FALSE; + bool proxy = (k->httpcode == 407); char *auth = Curl_copy_header_value(header); if(!auth) return CURLE_OUT_OF_MEMORY; diff --git a/lib/cf-socket.c b/lib/cf-socket.c index a3e3d52697..b4840f7ebc 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -1643,7 +1643,7 @@ static void cf_socket_active(struct Curl_cfilter *cf, struct Curl_easy *data) cf->conn->primary = ctx->ip; cf->conn->remote_addr = &ctx->addr; #ifdef USE_IPV6 - cf->conn->bits.ipv6 = (ctx->addr.family == AF_INET6) ? TRUE : FALSE; + cf->conn->bits.ipv6 = (ctx->addr.family == AF_INET6); #endif } else { @@ -1751,7 +1751,7 @@ static CURLcode cf_socket_query(struct Curl_cfilter *cf, } case CF_QUERY_IP_INFO: #ifdef USE_IPV6 - *pres1 = (ctx->addr.family == AF_INET6) ? TRUE : FALSE; + *pres1 = (ctx->addr.family == AF_INET6); #else *pres1 = FALSE; #endif diff --git a/lib/cookie.c b/lib/cookie.c index 34e4292d17..ca8c3c5967 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -855,7 +855,7 @@ parse_netscape(struct Cookie *co, * domain can access the variable. Set TRUE when the cookie says * .domain.com and to false when the domain is complete www.domain.com */ - co->tailmatch = strcasecompare(ptr, "TRUE") ? TRUE : FALSE; + co->tailmatch = !!strcasecompare(ptr, "TRUE"); break; case 2: /* The file format allows the path field to remain not filled in */ diff --git a/lib/ftp.c b/lib/ftp.c index 49b490b1ae..16ab0af0de 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -2042,10 +2042,10 @@ static CURLcode client_write_header(struct Curl_easy *data, * headers from CONNECT should not automatically be part of the * output. */ CURLcode result; - int save = data->set.include_header; + bool save = data->set.include_header; data->set.include_header = TRUE; result = Curl_client_write(data, CLIENTWRITE_HEADER, buf, blen); - data->set.include_header = save ? TRUE : FALSE; + data->set.include_header = save; return result; } @@ -2793,7 +2793,7 @@ static CURLcode ftp_statemachine(struct Curl_easy *data, if(ftpcode/100 == 2) /* We have enabled SSL for the data connection! */ conn->bits.ftp_use_data_ssl = - (data->set.use_ssl != CURLUSESSL_CONTROL) ? TRUE : FALSE; + (data->set.use_ssl != CURLUSESSL_CONTROL); /* FTP servers typically responds with 500 if they decide to reject our 'P' request */ else if(data->set.use_ssl > CURLUSESSL_CONTROL) @@ -3110,7 +3110,7 @@ static CURLcode ftp_multi_statemach(struct Curl_easy *data, /* Check for the state outside of the Curl_socket_check() return code checks since at times we are in fact already in this state when this function gets called. */ - *done = (ftpc->state == FTP_STOP) ? TRUE : FALSE; + *done = (ftpc->state == FTP_STOP); return result; } diff --git a/lib/hostip.c b/lib/hostip.c index fae5541921..fe8cc5cb97 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -630,7 +630,7 @@ bool Curl_ipv6works(struct Curl_easy *data) ipv6_works = 1; sclose(s); } - return (ipv6_works > 0) ? TRUE : FALSE; + return (ipv6_works > 0); } } #endif /* USE_IPV6 */ diff --git a/lib/http.c b/lib/http.c index 5f5ea20472..a94edd61c2 100644 --- a/lib/http.c +++ b/lib/http.c @@ -677,7 +677,7 @@ output_auth_headers(struct Curl_easy *data, auth, data->state.aptr.user ? data->state.aptr.user : ""); #endif - authstatus->multipass = (!authstatus->done) ? TRUE : FALSE; + authstatus->multipass = !authstatus->done; } else authstatus->multipass = FALSE; @@ -2259,7 +2259,7 @@ CURLcode Curl_http_cookies(struct Curl_easy *data, conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) || strcasecompare("localhost", host) || !strcmp(host, "127.0.0.1") || - !strcmp(host, "::1") ? TRUE : FALSE; + !strcmp(host, "::1"); Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); rc = Curl_cookie_getlist(data, data->cookies, host, data->state.up.path, secure_context, &list); @@ -3041,8 +3041,7 @@ CURLcode Curl_http_header(struct Curl_easy *data, char *persistentauth = Curl_copy_header_value(hd); if(!persistentauth) return CURLE_OUT_OF_MEMORY; - negdata->noauthpersist = checkprefix("false", persistentauth) ? - TRUE : FALSE; + negdata->noauthpersist = !!checkprefix("false", persistentauth); negdata->havenoauthpersist = TRUE; infof(data, "Negotiate: noauthpersist -> %d, header part: %s", negdata->noauthpersist, persistentauth); @@ -3083,7 +3082,7 @@ CURLcode Curl_http_header(struct Curl_easy *data, conn->handler->protocol&(CURLPROTO_HTTPS|CURLPROTO_WSS) || strcasecompare("localhost", host) || !strcmp(host, "127.0.0.1") || - !strcmp(host, "::1") ? TRUE : FALSE; + !strcmp(host, "::1"); Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); @@ -4544,7 +4543,7 @@ static void http_exp100_send_anyway(struct Curl_easy *data) bool Curl_http_exp100_is_selected(struct Curl_easy *data) { struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); - return r ? TRUE : FALSE; + return !!r; } #endif /* CURL_DISABLE_HTTP */ diff --git a/lib/http_digest.c b/lib/http_digest.c index 2db3125a8e..a3ba17a51f 100644 --- a/lib/http_digest.c +++ b/lib/http_digest.c @@ -121,9 +121,9 @@ CURLcode Curl_output_digest(struct Curl_easy *data, passwdp = ""; #if defined(USE_WINDOWS_SSPI) - have_chlg = digest->input_token ? TRUE : FALSE; + have_chlg = !!digest->input_token; #else - have_chlg = digest->nonce ? TRUE : FALSE; + have_chlg = !!digest->nonce; #endif if(!have_chlg) { diff --git a/lib/imap.c b/lib/imap.c index 77e527aaf1..e424cdb056 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -1399,7 +1399,7 @@ static CURLcode imap_multi_statemach(struct Curl_easy *data, bool *done) } result = Curl_pp_statemach(data, &imapc->pp, FALSE, FALSE); - *done = (imapc->state == IMAP_STOP) ? TRUE : FALSE; + *done = (imapc->state == IMAP_STOP); return result; } diff --git a/lib/krb5.c b/lib/krb5.c index d586498640..c953da6050 100644 --- a/lib/krb5.c +++ b/lib/krb5.c @@ -623,7 +623,7 @@ static void do_sec_send(struct Curl_easy *data, struct connectdata *conn, size_t cmd_size = 0; CURLcode error; enum protection_level prot_level = conn->data_prot; - bool iscmd = (prot_level == PROT_CMD) ? TRUE : FALSE; + bool iscmd = (prot_level == PROT_CMD); DEBUGASSERT(prot_level > PROT_NONE && prot_level < PROT_LAST); diff --git a/lib/multi.c b/lib/multi.c index 5db8b495b5..9bf338e404 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -80,7 +80,7 @@ * are not NULL, but no longer have the MAGIC touch. This gives * us early warning on things only discovered by valgrind otherwise. */ #define GOOD_MULTI_HANDLE(x) \ - (((x) && (x)->magic == CURL_MULTI_HANDLE)? TRUE: \ + (((x) && (x)->magic == CURL_MULTI_HANDLE)? TRUE: \ (DEBUGASSERT(!(x)), FALSE)) #else #define GOOD_MULTI_HANDLE(x) \ @@ -801,7 +801,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) if(multi->in_callback) return CURLM_RECURSIVE_API_CALL; - premature = (data->mstate < MSTATE_COMPLETED) ? TRUE : FALSE; + premature = (data->mstate < MSTATE_COMPLETED); /* If the 'state' is not INIT or COMPLETED, we might need to do something nice to put the easy_handle in a good known state when this returns. */ @@ -2161,7 +2161,7 @@ static CURLMcode state_performing(struct Curl_easy *data, */ CURLcode ret = Curl_retry_request(data, &newurl); if(!ret) - retry = (newurl) ? TRUE : FALSE; + retry = !!newurl; else if(!result) result = ret; diff --git a/lib/pop3.c b/lib/pop3.c index 5df59be3e9..db6ec04c7b 100644 --- a/lib/pop3.c +++ b/lib/pop3.c @@ -1119,7 +1119,7 @@ static CURLcode pop3_multi_statemach(struct Curl_easy *data, bool *done) } result = Curl_pp_statemach(data, &pop3c->pp, FALSE, FALSE); - *done = (pop3c->state == POP3_STOP) ? TRUE : FALSE; + *done = (pop3c->state == POP3_STOP); return result; } diff --git a/lib/smtp.c b/lib/smtp.c index 3c5893284b..d854d364f8 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -1100,12 +1100,11 @@ static CURLcode smtp_state_rcpt_resp(struct Curl_easy *data, (void)instate; /* no use for this yet */ - is_smtp_err = (smtpcode/100 != 2) ? TRUE : FALSE; + is_smtp_err = (smtpcode/100 != 2); /* If there is multiple RCPT TO to be issued, it is possible to ignore errors and proceed with only the valid addresses. */ - is_smtp_blocking_err = - (is_smtp_err && !data->set.mail_rcpt_allowfails) ? TRUE : FALSE; + is_smtp_blocking_err = (is_smtp_err && !data->set.mail_rcpt_allowfails); if(is_smtp_err) { /* Remembering the last failure which we can report if all "RCPT TO" have @@ -1296,7 +1295,7 @@ static CURLcode smtp_multi_statemach(struct Curl_easy *data, bool *done) } result = Curl_pp_statemach(data, &smtpc->pp, FALSE, FALSE); - *done = (smtpc->state == SMTP_STOP) ? TRUE : FALSE; + *done = (smtpc->state == SMTP_STOP); return result; } diff --git a/lib/socks.c b/lib/socks.c index 733d047eb2..d16a30b90a 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -286,7 +286,7 @@ static CURLproxycode do_SOCKS4(struct Curl_cfilter *cf, { struct connectdata *conn = cf->conn; const bool protocol4a = - (conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A) ? TRUE : FALSE; + (conn->socks_proxy.proxytype == CURLPROXY_SOCKS4A); unsigned char *socksreq = sx->buffer; CURLcode result; CURLproxycode presult; @@ -583,7 +583,7 @@ static CURLproxycode do_SOCKS5(struct Curl_cfilter *cf, CURLcode result; CURLproxycode presult; bool socks5_resolve_local = - (conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE; + (conn->socks_proxy.proxytype == CURLPROXY_SOCKS5); const size_t hostname_len = strlen(sx->hostname); size_t len = 0; const unsigned char auth = data->set.socks5auth; diff --git a/lib/tftp.c b/lib/tftp.c index 07fad523c5..e92e5127a5 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -205,7 +205,7 @@ static CURLcode tftp_set_timeouts(struct tftp_state_data *state) { time_t maxtime, timeout; timediff_t timeout_ms; - bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE; + bool start = (state->state == TFTP_STATE_START); /* Compute drop-dead time */ timeout_ms = Curl_timeleft(state->data, NULL, start); @@ -1232,7 +1232,7 @@ static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done) result = tftp_state_machine(state, event); if(result) return result; - *done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE; + *done = (state->state == TFTP_STATE_FIN); if(*done) /* Tell curl we are done */ Curl_xfer_setup_nop(data); @@ -1255,7 +1255,7 @@ static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done) result = tftp_state_machine(state, state->event); if(result) return result; - *done = (state->state == TFTP_STATE_FIN) ? TRUE : FALSE; + *done = (state->state == TFTP_STATE_FIN); if(*done) /* Tell curl we are done */ Curl_xfer_setup_nop(data); diff --git a/lib/url.c b/lib/url.c index 68e96136a6..f9bb05f793 100644 --- a/lib/url.c +++ b/lib/url.c @@ -1343,22 +1343,19 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) /* note that these two proxy bits are now just on what looks to be requested, they may be altered down the road */ conn->bits.proxy = (data->set.str[STRING_PROXY] && - *data->set.str[STRING_PROXY]) ? TRUE : FALSE; + *data->set.str[STRING_PROXY]); conn->bits.httpproxy = (conn->bits.proxy && (conn->http_proxy.proxytype == CURLPROXY_HTTP || conn->http_proxy.proxytype == CURLPROXY_HTTP_1_0 || - IS_HTTPS_PROXY(conn->http_proxy.proxytype))) ? - TRUE : FALSE; - conn->bits.socksproxy = (conn->bits.proxy && - !conn->bits.httpproxy) ? TRUE : FALSE; + IS_HTTPS_PROXY(conn->http_proxy.proxytype))); + conn->bits.socksproxy = (conn->bits.proxy && !conn->bits.httpproxy); if(data->set.str[STRING_PRE_PROXY] && *data->set.str[STRING_PRE_PROXY]) { conn->bits.proxy = TRUE; conn->bits.socksproxy = TRUE; } - conn->bits.proxy_user_passwd = - (data->state.aptr.proxyuser) ? TRUE : FALSE; + conn->bits.proxy_user_passwd = !!data->state.aptr.proxyuser; conn->bits.tunnel_proxy = data->set.tunnel_thru_httpproxy; #endif /* CURL_DISABLE_PROXY */ @@ -1961,11 +1958,11 @@ static CURLcode setup_range(struct Curl_easy *data) else s->range = strdup(data->set.str[STRING_SET_RANGE]); - s->rangestringalloc = (s->range) ? TRUE : FALSE; - if(!s->range) return CURLE_OUT_OF_MEMORY; + s->rangestringalloc = TRUE; + /* tell ourselves to fetch this range */ s->use_range = TRUE; /* enable range download */ } diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index e686b0aaf9..2ae6fb30c9 100644 --- a/lib/vauth/digest_sspi.c +++ b/lib/vauth/digest_sspi.c @@ -69,7 +69,7 @@ bool Curl_auth_is_digest_supported(void) Curl_pSecFn->FreeContextBuffer(SecurityPackage); } - return (status == SEC_E_OK ? TRUE : FALSE); + return (status == SEC_E_OK); } /* diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index b168a27ad8..4af0bd1e13 100644 --- a/lib/vauth/krb5_sspi.c +++ b/lib/vauth/krb5_sspi.c @@ -64,7 +64,7 @@ bool Curl_auth_is_gssapi_supported(void) Curl_pSecFn->FreeContextBuffer(SecurityPackage); } - return (status == SEC_E_OK ? TRUE : FALSE); + return (status == SEC_E_OK); } /* diff --git a/lib/vauth/ntlm.c b/lib/vauth/ntlm.c index 0e3d98aa9c..f8f6aea0e9 100644 --- a/lib/vauth/ntlm.c +++ b/lib/vauth/ntlm.c @@ -485,7 +485,7 @@ CURLcode Curl_auth_create_ntlm_type3_message(struct Curl_easy *data, unsigned char ntresp[24]; /* fixed-size */ unsigned char *ptr_ntresp = &ntresp[0]; unsigned char *ntlmv2resp = NULL; - bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE) ? TRUE : FALSE; + bool unicode = (ntlm->flags & NTLMFLAG_NEGOTIATE_UNICODE); /* The fixed hostname we provide, in order to not leak our real local host name. Copy the name used by Firefox. */ static const char host[] = "WORKSTATION"; diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index 55ec8201d8..a2e5bc1026 100644 --- a/lib/vauth/ntlm_sspi.c +++ b/lib/vauth/ntlm_sspi.c @@ -63,7 +63,7 @@ bool Curl_auth_is_ntlm_supported(void) Curl_pSecFn->FreeContextBuffer(SecurityPackage); } - return (status == SEC_E_OK ? TRUE : FALSE); + return (status == SEC_E_OK); } /* diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 38b26ab90c..7a27c298fc 100644 --- a/lib/vauth/spnego_sspi.c +++ b/lib/vauth/spnego_sspi.c @@ -67,7 +67,7 @@ bool Curl_auth_is_spnego_supported(void) } - return (status == SEC_E_OK ? TRUE : FALSE); + return (status == SEC_E_OK); } /* diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index ace43c47d1..a7e7e17f3b 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -134,8 +134,7 @@ bool Curl_auth_user_contains_domain(const char *user) /* Check we have a domain name or UPN present */ char *p = strpbrk(user, "\\/@"); - valid = (p != NULL && p > user && p < user + strlen(user) - 1 ? TRUE : - FALSE); + valid = (p != NULL && p > user && p < user + strlen(user) - 1); } #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) else diff --git a/lib/vssh/libssh.c b/lib/vssh/libssh.c index b8319ff94b..2781365bf4 100644 --- a/lib/vssh/libssh.c +++ b/lib/vssh/libssh.c @@ -695,7 +695,7 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block) case SSH_S_STARTUP: rc = ssh_connect(sshc->ssh_session); - myssh_block2waitfor(conn, (rc == SSH_AGAIN) ? TRUE : FALSE); + myssh_block2waitfor(conn, (rc == SSH_AGAIN)); if(rc == SSH_AGAIN) { DEBUGF(infof(data, "ssh_connect -> EAGAIN")); break; @@ -2085,7 +2085,7 @@ static CURLcode myssh_multi_statemach(struct Curl_easy *data, implementation */ CURLcode result = myssh_statemach_act(data, &block); - *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; + *done = (sshc->state == SSH_STOP); myssh_block2waitfor(conn, block); return result; @@ -2415,7 +2415,7 @@ static ssize_t scp_send(struct Curl_easy *data, int sockindex, /* The following code is misleading, mostly added as wishful thinking * that libssh at some point will implement non-blocking ssh_scp_write/read. * Currently rc can only be number of bytes read or SSH_ERROR. */ - myssh_block2waitfor(conn, (rc == SSH_AGAIN) ? TRUE : FALSE); + myssh_block2waitfor(conn, (rc == SSH_AGAIN)); if(rc == SSH_AGAIN) { *err = CURLE_AGAIN; @@ -2447,7 +2447,7 @@ static ssize_t scp_recv(struct Curl_easy *data, int sockindex, * that libssh at some point will implement non-blocking ssh_scp_write/read. * Currently rc can only be SSH_OK or SSH_ERROR. */ - myssh_block2waitfor(conn, (nread == SSH_AGAIN) ? TRUE : FALSE); + myssh_block2waitfor(conn, (nread == SSH_AGAIN)); if(nread == SSH_AGAIN) { *err = CURLE_AGAIN; nread = -1; @@ -2614,7 +2614,7 @@ static ssize_t sftp_recv(struct Curl_easy *data, int sockindex, mem, (uint32_t)len, (uint32_t)conn->proto.sshc.sftp_file_index); - myssh_block2waitfor(conn, (nread == SSH_AGAIN) ? TRUE : FALSE); + myssh_block2waitfor(conn, (nread == SSH_AGAIN)); if(nread == SSH_AGAIN) { *err = CURLE_AGAIN; diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c index c41ae9f90a..e19ffefe8b 100644 --- a/lib/vssh/libssh2.c +++ b/lib/vssh/libssh2.c @@ -3067,7 +3067,7 @@ static CURLcode ssh_multi_statemach(struct Curl_easy *data, bool *done) implementation */ do { result = ssh_statemachine(data, &block); - *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; + *done = (sshc->state == SSH_STOP); /* if there is no error, it is not done and it did not EWOULDBLOCK, then try again */ } while(!result && !*done && !block); @@ -3512,7 +3512,7 @@ static ssize_t scp_send(struct Curl_easy *data, int sockindex, /* libssh2_channel_write() returns int! */ nwrite = (ssize_t) libssh2_channel_write(sshc->ssh_channel, mem, len); - ssh_block2waitfor(data, (nwrite == LIBSSH2_ERROR_EAGAIN) ? TRUE : FALSE); + ssh_block2waitfor(data, (nwrite == LIBSSH2_ERROR_EAGAIN)); if(nwrite == LIBSSH2_ERROR_EAGAIN) { *err = CURLE_AGAIN; @@ -3537,7 +3537,7 @@ static ssize_t scp_recv(struct Curl_easy *data, int sockindex, /* libssh2_channel_read() returns int */ nread = (ssize_t) libssh2_channel_read(sshc->ssh_channel, mem, len); - ssh_block2waitfor(data, (nread == LIBSSH2_ERROR_EAGAIN) ? TRUE : FALSE); + ssh_block2waitfor(data, (nread == LIBSSH2_ERROR_EAGAIN)); if(nread == LIBSSH2_ERROR_EAGAIN) { *err = CURLE_AGAIN; nread = -1; @@ -3650,7 +3650,7 @@ static ssize_t sftp_send(struct Curl_easy *data, int sockindex, nwrite = libssh2_sftp_write(sshc->sftp_handle, mem, len); - ssh_block2waitfor(data, (nwrite == LIBSSH2_ERROR_EAGAIN) ? TRUE : FALSE); + ssh_block2waitfor(data, (nwrite == LIBSSH2_ERROR_EAGAIN)); if(nwrite == LIBSSH2_ERROR_EAGAIN) { *err = CURLE_AGAIN; @@ -3678,7 +3678,7 @@ static ssize_t sftp_recv(struct Curl_easy *data, int sockindex, nread = libssh2_sftp_read(sshc->sftp_handle, mem, len); - ssh_block2waitfor(data, (nread == LIBSSH2_ERROR_EAGAIN) ? TRUE : FALSE); + ssh_block2waitfor(data, (nread == LIBSSH2_ERROR_EAGAIN)); if(nread == LIBSSH2_ERROR_EAGAIN) { *err = CURLE_AGAIN; diff --git a/lib/vssh/wolfssh.c b/lib/vssh/wolfssh.c index 2f1d556d4b..5400821129 100644 --- a/lib/vssh/wolfssh.c +++ b/lib/vssh/wolfssh.c @@ -908,7 +908,7 @@ static CURLcode wssh_multi_statemach(struct Curl_easy *data, bool *done) implementation */ do { result = wssh_statemach_act(data, &block); - *done = (sshc->state == SSH_STOP) ? TRUE : FALSE; + *done = (sshc->state == SSH_STOP); /* if there is no error, it is not done and it did not EWOULDBLOCK, then try again */ if(*done) { diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index 67c7fd0f79..b60869ddad 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -1015,7 +1015,7 @@ static int passwd_callback(char *buf, int num, int encrypting, */ static bool rand_enough(void) { - return (0 != RAND_status()) ? TRUE : FALSE; + return (0 != RAND_status()); } static CURLcode ossl_seed(struct Curl_easy *data) diff --git a/lib/vtls/vtls.c b/lib/vtls/vtls.c index 55c7141169..6d12dfd73e 100644 --- a/lib/vtls/vtls.c +++ b/lib/vtls/vtls.c @@ -2053,7 +2053,7 @@ CURLcode Curl_cf_ssl_proxy_insert_after(struct Curl_cfilter *cf_at, bool Curl_ssl_supports(struct Curl_easy *data, unsigned int ssl_option) { (void)data; - return (Curl_ssl->supports & ssl_option) ? TRUE : FALSE; + return (Curl_ssl->supports & ssl_option); } static struct Curl_cfilter *get_ssl_filter(struct Curl_cfilter *cf) diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index c636e4788e..bc383ec5cb 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -1799,7 +1799,7 @@ static bool wolfssl_data_pending(struct Curl_cfilter *cf, backend = (struct wolfssl_ctx *)ctx->backend; if(backend->handle) /* SSL is in use */ - return (0 != wolfSSL_pending(backend->handle)) ? TRUE : FALSE; + return wolfSSL_pending(backend->handle); else return FALSE; } diff --git a/src/tool_cb_dbg.c b/src/tool_cb_dbg.c index 6d2a617835..195127bd8b 100644 --- a/src/tool_cb_dbg.c +++ b/src/tool_cb_dbg.c @@ -173,7 +173,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, log_line_start(output, timebuf, idsbuf, type); (void)fwrite(data + st, i - st + 1, 1, output); } - newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE; + newl = (size && (data[size - 1] != '\n')); traced_data = FALSE; break; case CURLINFO_TEXT: @@ -181,7 +181,7 @@ int tool_debug_cb(CURL *handle, curl_infotype type, if(!newl) log_line_start(output, timebuf, idsbuf, type); (void)fwrite(data, size, 1, output); - newl = (size && (data[size - 1] != '\n')) ? TRUE : FALSE; + newl = (size && (data[size - 1] != '\n')); traced_data = FALSE; break; case CURLINFO_DATA_OUT: diff --git a/src/tool_getparam.c b/src/tool_getparam.c index f3ab493d1e..1231b3bd60 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -1218,7 +1218,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ config->disallow_username_in_url = toggle; break; case C_EPSV: /* --epsv */ - config->disable_epsv = (!toggle) ? TRUE : FALSE; + config->disable_epsv = !toggle; break; case C_DNS_SERVERS: /* --dns-servers */ if(!curlinfo->ares_num) /* c-ares is needed for this */ @@ -1248,7 +1248,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ } break; case C_ALPN: /* --alpn */ - config->noalpn = (!toggle) ? TRUE : FALSE; + config->noalpn = !toggle; break; case C_LIMIT_RATE: /* --limit-rate */ err = GetSizeParameter(global, nextarg, "rate", &value); @@ -1371,7 +1371,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ config->disable_eprt = toggle; break; case C_EPRT: /* --eprt */ - config->disable_eprt = (!toggle) ? TRUE : FALSE; + config->disable_eprt = !toggle; break; case C_XATTR: /* --xattr */ config->xattr = toggle; @@ -1552,7 +1552,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ config->ftp_ssl_reqd = toggle; break; case C_SESSIONID: /* --sessionid */ - config->disable_sessionid = (!toggle) ? TRUE : FALSE; + config->disable_sessionid = !toggle; break; case C_FTP_SSL_CONTROL: /* --ftp-ssl-control */ if(toggle && !feature_ssl) @@ -1582,7 +1582,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ config->raw = toggle; break; case C_KEEPALIVE: /* --keepalive */ - config->nokeepalive = (!toggle) ? TRUE : FALSE; + config->nokeepalive = !toggle; break; case C_KEEPALIVE_TIME: /* --keepalive-time */ err = str2unum(&config->alivetime, nextarg); @@ -2167,7 +2167,7 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */ nextarg, &config->mimeroot, &config->mimecurrent, - (cmd == C_FORM_STRING) ? TRUE : FALSE)) /* literal string */ + (cmd == C_FORM_STRING))) /* literal string */ err = PARAM_BAD_USE; else if(SetHTTPrequest(config, TOOL_HTTPREQ_MIMEPOST, &config->httpreq)) err = PARAM_BAD_USE; diff --git a/src/tool_operate.c b/src/tool_operate.c index b98ec01394..18de4e2fa4 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -2456,7 +2456,7 @@ static CURLcode add_parallel_transfers(struct GlobalConfig *global, all_added++; *addedp = TRUE; } - *morep = (per || sleeping) ? TRUE : FALSE; + *morep = (per || sleeping); return CURLE_OK; } diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index fbddb027cf..e4cdb45aa7 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -66,8 +66,7 @@ bool output_expected(const char *url, const char *uploadfile) bool stdin_upload(const char *uploadfile) { - return (!strcmp(uploadfile, "-") || - !strcmp(uploadfile, ".")) ? TRUE : FALSE; + return (!strcmp(uploadfile, "-") || !strcmp(uploadfile, ".")); } /* Convert a CURLUcode into a CURLcode */ diff --git a/src/tool_parsecfg.c b/src/tool_parsecfg.c index a267dccbe7..d79e869f02 100644 --- a/src/tool_parsecfg.c +++ b/src/tool_parsecfg.c @@ -126,7 +126,7 @@ int parseconfig(const char *filename, struct GlobalConfig *global) option = line; /* the option starts with a dash? */ - dashed_option = (option[0] == '-') ? TRUE : FALSE; + dashed_option = (option[0] == '-'); while(*line && !ISSPACE(*line) && !ISSEP(*line, dashed_option)) line++; @@ -311,7 +311,7 @@ static bool my_get_line(FILE *fp, struct curlx_dynbuf *db, occurs while no characters have been read. */ if(!fgets(buf, sizeof(buf), fp)) /* only if there is data in the line, return TRUE */ - return curlx_dyn_len(db) ? TRUE : FALSE; + return curlx_dyn_len(db); if(curlx_dyn_add(db, buf)) { *error = TRUE; /* error */ return FALSE; /* stop reading */