From: Viktor Szakats Date: Mon, 13 Jan 2025 17:52:32 +0000 (+0100) Subject: tidy-up: drop parenthesis around `return` expression X-Git-Tag: curl-8_12_0~121 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5474d70c3e1184669e6333b15f31cc2966277aa5;p=thirdparty%2Fcurl.git tidy-up: drop parenthesis around `return` expression Closes #15990 --- diff --git a/docs/examples/cacertinmem.c b/docs/examples/cacertinmem.c index b095b46166..d95f0ef21a 100644 --- a/docs/examples/cacertinmem.c +++ b/docs/examples/cacertinmem.c @@ -34,7 +34,7 @@ static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) { fwrite(ptr, size, nmemb, (FILE *)stream); - return (nmemb*size); + return nmemb * size; } static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c index 7683e9bf80..109ae0361b 100644 --- a/docs/examples/synctime.c +++ b/docs/examples/synctime.c @@ -119,7 +119,7 @@ static size_t SyncTime_CURL_WriteOutput(void *ptr, size_t size, size_t nmemb, void *stream) { fwrite(ptr, size, nmemb, stream); - return (nmemb*size); + return nmemb * size; } static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb, @@ -171,7 +171,7 @@ static size_t SyncTime_CURL_WriteHeader(void *ptr, size_t size, size_t nmemb, " Server Date is no longer valid.\n"); AutoSyncTime = 0; } - return (nmemb*size); + return nmemb * size; } static void SyncTime_CURL_Init(CURL *curl, const char *proxy_port, diff --git a/docs/examples/usercertinmem.c b/docs/examples/usercertinmem.c index 02c53c82c6..e8c78fe79e 100644 --- a/docs/examples/usercertinmem.c +++ b/docs/examples/usercertinmem.c @@ -44,7 +44,7 @@ static size_t writefunction(void *ptr, size_t size, size_t nmemb, void *stream) { fwrite(ptr, size, nmemb, stream); - return (nmemb*size); + return nmemb * size; } static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) diff --git a/lib/cf-h1-proxy.c b/lib/cf-h1-proxy.c index 943b10cfdb..2e13f39295 100644 --- a/lib/cf-h1-proxy.c +++ b/lib/cf-h1-proxy.c @@ -203,7 +203,7 @@ static void tunnel_free(struct Curl_cfilter *cf, static bool tunnel_want_send(struct h1_tunnel_state *ts) { - return (ts->tunnel_state == H1_TUNNEL_CONNECT); + return ts->tunnel_state == H1_TUNNEL_CONNECT; } static CURLcode start_CONNECT(struct Curl_cfilter *cf, diff --git a/lib/cf-socket.c b/lib/cf-socket.c index f8dbf416cd..cbbe80fd1c 100644 --- a/lib/cf-socket.c +++ b/lib/cf-socket.c @@ -1459,7 +1459,7 @@ static bool cf_socket_data_pending(struct Curl_cfilter *cf, (void)data; readable = SOCKET_READABLE(ctx->sock, 0); - return (readable > 0 && (readable & CURL_CSELECT_IN)); + return readable > 0 && (readable & CURL_CSELECT_IN); } #ifdef USE_WINSOCK diff --git a/lib/cookie.c b/lib/cookie.c index 48a200dc6d..6fe949b56f 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -469,7 +469,7 @@ static bool invalid_octets(const char *p) size_t len; /* scan for all the octets that are *not* in cookie-octet */ len = strcspn(p, badoctets); - return (p[len] != '\0'); + return p[len] != '\0'; } #define CERR_OK 0 @@ -1335,14 +1335,14 @@ static int cookie_sort(const void *p1, const void *p2) l2 = c2->path ? strlen(c2->path) : 0; if(l1 != l2) - return (l2 > l1) ? 1 : -1 ; /* avoid size_t <=> int conversions */ + return (l2 > l1) ? 1 : -1; /* avoid size_t <=> int conversions */ /* 2 - compare cookie domain lengths */ l1 = c1->domain ? strlen(c1->domain) : 0; l2 = c2->domain ? strlen(c2->domain) : 0; if(l1 != l2) - return (l2 > l1) ? 1 : -1 ; /* avoid size_t <=> int conversions */ + return (l2 > l1) ? 1 : -1; /* avoid size_t <=> int conversions */ /* 3 - compare cookie name lengths */ l1 = c1->name ? strlen(c1->name) : 0; diff --git a/lib/curl_multibyte.c b/lib/curl_multibyte.c index 9102c972bc..220b2fa3f6 100644 --- a/lib/curl_multibyte.c +++ b/lib/curl_multibyte.c @@ -237,7 +237,7 @@ cleanup: free(ibuf); free(obuf); #endif - return (*out ? true : false); + return *out ? true : false; } int curlx_win32_open(const char *filename, int oflag, ...) diff --git a/lib/easyoptions.c b/lib/easyoptions.c index 81091c405a..f2ced2cb50 100644 --- a/lib/easyoptions.c +++ b/lib/easyoptions.c @@ -377,6 +377,6 @@ struct curl_easyoption Curl_easyopts[] = { */ int Curl_easyopts_check(void) { - return ((CURLOPT_LASTENTRY%10000) != (326 + 1)); + return (CURLOPT_LASTENTRY % 10000) != (326 + 1); } #endif diff --git a/lib/hostip.c b/lib/hostip.c index 509b9d4867..110595c9e6 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -632,7 +632,7 @@ bool Curl_ipv6works(struct Curl_easy *data) ipv6_works = 1; sclose(s); } - return (ipv6_works > 0); + return ipv6_works > 0; } } #endif /* USE_IPV6 */ diff --git a/lib/http.c b/lib/http.c index fc06a6f561..59ee15b7f6 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1234,8 +1234,8 @@ static bool use_http_1_1plus(const struct Curl_easy *data, if((data->state.httpwant == CURL_HTTP_VERSION_1_0) && (conn->httpversion <= 10)) return FALSE; - return ((data->state.httpwant == CURL_HTTP_VERSION_NONE) || - (data->state.httpwant >= CURL_HTTP_VERSION_1_1)); + return (data->state.httpwant == CURL_HTTP_VERSION_NONE) || + (data->state.httpwant >= CURL_HTTP_VERSION_1_1); } static const char *get_http_string(const struct Curl_easy *data, @@ -4379,7 +4379,7 @@ static bool http_exp100_is_waiting(struct Curl_easy *data) struct Curl_creader *r = Curl_creader_get_by_type(data, &cr_exp100); if(r) { struct cr_exp100_ctx *ctx = r->ctx; - return (ctx->state == EXP100_AWAITING_CONTINUE); + return ctx->state == EXP100_AWAITING_CONTINUE; } return FALSE; } diff --git a/lib/http2.c b/lib/http2.c index 2e8708c453..87df2a9249 100644 --- a/lib/http2.c +++ b/lib/http2.c @@ -2955,7 +2955,7 @@ bool Curl_h2_http_1_1_error(struct Curl_easy *data) { if(Curl_conn_is_http2(data, data->conn, FIRSTSOCKET)) { int err = Curl_conn_get_stream_error(data, data->conn, FIRSTSOCKET); - return (err == NGHTTP2_HTTP_1_1_REQUIRED); + return err == NGHTTP2_HTTP_1_1_REQUIRED; } return FALSE; } diff --git a/lib/ldap.c b/lib/ldap.c index ff44e79a11..97484a2b4d 100644 --- a/lib/ldap.c +++ b/lib/ldap.c @@ -805,7 +805,7 @@ static int str2scope(const char *p) return LDAP_SCOPE_SUBTREE; if(strcasecompare(p, "subtree")) return LDAP_SCOPE_SUBTREE; - return (-1); + return -1; } /* diff --git a/lib/memdebug.c b/lib/memdebug.c index 02612c2a23..9c284ede51 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -153,7 +153,7 @@ ALLOC_FUNC void *curl_dbg_malloc(size_t wantedsize, source, line, wantedsize, mem ? (void *)mem->mem : (void *)0); - return (mem ? mem->mem : NULL); + return mem ? mem->mem : NULL; } ALLOC_FUNC void *curl_dbg_calloc(size_t wanted_elements, size_t wanted_size, @@ -181,7 +181,7 @@ ALLOC_FUNC void *curl_dbg_calloc(size_t wanted_elements, size_t wanted_size, source, line, wanted_elements, wanted_size, mem ? (void *)mem->mem : (void *)0); - return (mem ? mem->mem : NULL); + return mem ? mem->mem : NULL; } ALLOC_FUNC char *curl_dbg_strdup(const char *str, diff --git a/lib/mime.c b/lib/mime.c index cc93e07851..d4488913dd 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -2179,7 +2179,7 @@ static bool cr_mime_is_paused(struct Curl_easy *data, { struct cr_mime_ctx *ctx = reader->ctx; (void)data; - return (ctx->part && ctx->part->lastreadstatus == CURL_READFUNC_PAUSE); + return ctx->part && ctx->part->lastreadstatus == CURL_READFUNC_PAUSE; } static const struct Curl_crtype cr_mime = { diff --git a/lib/multi.c b/lib/multi.c index 6fcb4a099e..bb9ccd03f9 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -933,7 +933,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) /* Return TRUE if the application asked for multiplexing */ bool Curl_multiplex_wanted(const struct Curl_multi *multi) { - return (multi && (multi->multiplexing)); + return multi && multi->multiplexing; } /* @@ -4150,7 +4150,7 @@ void Curl_set_in_callback(struct Curl_easy *data, bool value) bool Curl_is_in_callback(struct Curl_easy *data) { - return (data && data->multi && data->multi->in_callback); + return data && data->multi && data->multi->in_callback; } unsigned int Curl_multi_max_concurrent_streams(struct Curl_multi *multi) diff --git a/lib/noproxy.c b/lib/noproxy.c index dbfafc93eb..78cc06fa01 100644 --- a/lib/noproxy.c +++ b/lib/noproxy.c @@ -71,7 +71,7 @@ UNITTEST bool Curl_cidr4_match(const char *ipv4, /* 1.2.3.4 address */ return FALSE; return TRUE; } - return (address == check); + return address == check; } UNITTEST bool Curl_cidr6_match(const char *ipv6, diff --git a/lib/optiontable.pl b/lib/optiontable.pl index 2727784e7b..350262c70f 100755 --- a/lib/optiontable.pl +++ b/lib/optiontable.pl @@ -145,7 +145,7 @@ print <sendleft && Curl_dyn_len(&pp->recvbuf) > pp->nfinal); + return !pp->sendleft && Curl_dyn_len(&pp->recvbuf) > pp->nfinal; } #endif diff --git a/lib/progress.c b/lib/progress.c index 91fae30fdf..82cbeb3770 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -312,7 +312,7 @@ timediff_t Curl_pgrsLimitWaitTime(struct pgrs_dir *d, if(actual < minimum) { /* if it downloaded the data faster than the limit, make it wait the difference */ - return (minimum - actual); + return minimum - actual; } return 0; diff --git a/lib/strcase.c b/lib/strcase.c index b22dd31fc8..112aedb193 100644 --- a/lib/strcase.c +++ b/lib/strcase.c @@ -113,7 +113,7 @@ int curl_strequal(const char *first, const char *second) return casecompare(first, second); /* if both pointers are NULL then treat them as equal */ - return (NULL == first && NULL == second); + return NULL == first && NULL == second; } static int ncasecompare(const char *first, const char *second, size_t max) @@ -139,7 +139,7 @@ int curl_strnequal(const char *first, const char *second, size_t max) return ncasecompare(first, second, max); /* if both pointers are NULL then treat them as equal if max is non-zero */ - return (NULL == first && NULL == second && max); + return NULL == first && NULL == second && max; } /* Copy an upper case version of the string from src to dest. The * strings may overlap. No more than n characters of the string are copied diff --git a/lib/strerror.c b/lib/strerror.c index 32449c9fa1..20495c9791 100644 --- a/lib/strerror.c +++ b/lib/strerror.c @@ -808,7 +808,7 @@ get_winapi_error(int err, char *buf, size_t buflen) *p = '\0'; } - return (*buf ? buf : NULL); + return *buf ? buf : NULL; } #endif /* _WIN32 || _WIN32_WCE */ diff --git a/lib/transfer.c b/lib/transfer.c index 0407613f08..4e0454fe83 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -973,9 +973,9 @@ bool Curl_xfer_is_blocked(struct Curl_easy *data) bool want_send = ((data)->req.keepon & KEEP_SEND); bool want_recv = ((data)->req.keepon & KEEP_RECV); if(!want_send) - return (want_recv && Curl_cwriter_is_paused(data)); + return want_recv && Curl_cwriter_is_paused(data); else if(!want_recv) - return (want_send && Curl_creader_is_paused(data)); + return want_send && Curl_creader_is_paused(data); else return Curl_creader_is_paused(data) && Curl_cwriter_is_paused(data); } diff --git a/lib/url.c b/lib/url.c index 001989d186..843f504a1a 100644 --- a/lib/url.c +++ b/lib/url.c @@ -837,8 +837,8 @@ CURLcode Curl_conn_upkeep(struct Curl_easy *data, static bool ssh_config_matches(struct connectdata *one, struct connectdata *two) { - return (Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) && - Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub)); + return Curl_safecmp(one->proto.sshc.rsa, two->proto.sshc.rsa) && + Curl_safecmp(one->proto.sshc.rsa_pub, two->proto.sshc.rsa_pub); } #else #define ssh_config_matches(x,y) FALSE diff --git a/lib/vauth/digest_sspi.c b/lib/vauth/digest_sspi.c index 2ae6fb30c9..c06ee1064f 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); + return status == SEC_E_OK; } /* diff --git a/lib/vauth/krb5_sspi.c b/lib/vauth/krb5_sspi.c index 4af0bd1e13..00a5db125d 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); + return status == SEC_E_OK; } /* diff --git a/lib/vauth/ntlm_sspi.c b/lib/vauth/ntlm_sspi.c index a2e5bc1026..6421c6ac1b 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); + return status == SEC_E_OK; } /* diff --git a/lib/vauth/spnego_sspi.c b/lib/vauth/spnego_sspi.c index 7a27c298fc..2439e7319f 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); + return status == SEC_E_OK; } /* diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c index a7e7e17f3b..171e53fb13 100644 --- a/lib/vauth/vauth.c +++ b/lib/vauth/vauth.c @@ -153,10 +153,10 @@ bool Curl_auth_user_contains_domain(const char *user) bool Curl_auth_allowed_to_host(struct Curl_easy *data) { struct connectdata *conn = data->conn; - return (!data->state.this_is_a_follow || - data->set.allow_auth_to_other_hosts || - (data->state.first_host && - strcasecompare(data->state.first_host, conn->host.name) && - (data->state.first_remote_port == conn->remote_port) && - (data->state.first_remote_protocol == conn->handler->protocol))); + return !data->state.this_is_a_follow || + data->set.allow_auth_to_other_hosts || + (data->state.first_host && + strcasecompare(data->state.first_host, conn->host.name) && + (data->state.first_remote_port == conn->remote_port) && + (data->state.first_remote_protocol == conn->handler->protocol)); } diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 0970891580..bb06b76ab7 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -708,8 +708,8 @@ bool Curl_conn_is_http3(const struct Curl_easy *data, #elif defined(USE_MSH3) return Curl_conn_is_msh3(data, conn, sockindex); #else - return ((conn->handler->protocol & PROTO_FAMILY_HTTP) && - (conn->httpversion == 30)); + return (conn->handler->protocol & PROTO_FAMILY_HTTP) && + (conn->httpversion == 30); #endif } diff --git a/lib/vtls/openssl.c b/lib/vtls/openssl.c index be77eeb353..382ac244a9 100644 --- a/lib/vtls/openssl.c +++ b/lib/vtls/openssl.c @@ -746,7 +746,7 @@ static long ossl_bio_cf_ctrl(BIO *bio, int cmd, long num, void *ptr) #ifdef BIO_CTRL_EOF case BIO_CTRL_EOF: /* EOF has been reached on input? */ - return (!cf->next || !cf->next->connected); + return !cf->next || !cf->next->connected; #endif default: ret = 0; @@ -1020,7 +1020,7 @@ static int passwd_callback(char *buf, int num, int encrypting, */ static bool rand_enough(void) { - return (0 != RAND_status()); + return 0 != RAND_status(); } static CURLcode ossl_seed(struct Curl_easy *data) @@ -1076,8 +1076,8 @@ static CURLcode ossl_seed(struct Curl_easy *data) } infof(data, "libcurl is now using a weak random seed"); - return (rand_enough() ? CURLE_OK : - CURLE_SSL_CONNECT_ERROR /* confusing error code */); + return rand_enough() ? CURLE_OK : + CURLE_SSL_CONNECT_ERROR; /* confusing error code */ #endif } @@ -1155,7 +1155,7 @@ static int ssl_ui_writer(UI *ui, UI_STRING *uis) */ static bool is_pkcs11_uri(const char *string) { - return (string && strncasecompare(string, "pkcs11:", 7)); + return string && strncasecompare(string, "pkcs11:", 7); } #endif @@ -5454,7 +5454,7 @@ static CURLcode ossl_random(struct Curl_easy *data, } /* RAND_bytes() returns 1 on success, 0 otherwise. */ rc = RAND_bytes(entropy, (ossl_valsize_t)curlx_uztosi(length)); - return (rc == 1 ? CURLE_OK : CURLE_FAILED_INIT); + return rc == 1 ? CURLE_OK : CURLE_FAILED_INIT; } #if (OPENSSL_VERSION_NUMBER >= 0x0090800fL) && !defined(OPENSSL_NO_SHA256) diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c index e8ce9b7df3..93348f05e2 100644 --- a/lib/vtls/schannel.c +++ b/lib/vtls/schannel.c @@ -2273,11 +2273,11 @@ static bool schannel_data_pending(struct Curl_cfilter *cf, DEBUGASSERT(backend); if(backend->ctxt) /* SSL/TLS is in use */ - return (backend->decdata_offset > 0 || - (backend->encdata_offset > 0 && !backend->encdata_is_incomplete) || - backend->recv_connection_closed || - backend->recv_sspi_close_notify || - backend->recv_unrecoverable_err); + return backend->decdata_offset > 0 || + (backend->encdata_offset > 0 && !backend->encdata_is_incomplete) || + backend->recv_connection_closed || + backend->recv_sspi_close_notify || + backend->recv_unrecoverable_err; else return FALSE; } @@ -2467,7 +2467,7 @@ static void schannel_close(struct Curl_cfilter *cf, struct Curl_easy *data) static int schannel_init(void) { - return (Curl_sspi_global_init() == CURLE_OK ? 1 : 0); + return Curl_sspi_global_init() == CURLE_OK ? 1 : 0; } static void schannel_cleanup(void) diff --git a/lib/vtls/wolfssl.c b/lib/vtls/wolfssl.c index 467de62a19..82b21afb8c 100644 --- a/lib/vtls/wolfssl.c +++ b/lib/vtls/wolfssl.c @@ -295,7 +295,7 @@ static long wolfssl_bio_cf_ctrl(WOLFSSL_BIO *bio, int cmd, long num, void *ptr) #ifdef WOLFSSL_BIO_CTRL_EOF case WOLFSSL_BIO_CTRL_EOF: /* EOF has been reached on input? */ - return (!cf->next || !cf->next->connected); + return !cf->next || !cf->next->connected; #endif default: ret = 0; diff --git a/src/tool_doswin.c b/src/tool_doswin.c index c7f79cebbd..171b063b9f 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -418,7 +418,7 @@ static SANITIZEcode msdosify(char **const sanitized, const char *file_name, } *sanitized = strdup(dos_name); - return (*sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY); + return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY; } #endif /* MSDOS */ @@ -547,7 +547,7 @@ static SANITIZEcode rename_if_reserved_dos(char **const sanitized, #endif *sanitized = strdup(fname); - return (*sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY); + return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY; } #ifdef __DJGPP__ diff --git a/src/tool_operhlp.c b/src/tool_operhlp.c index 78d4e0adf8..06dc7a7254 100644 --- a/src/tool_operhlp.c +++ b/src/tool_operhlp.c @@ -66,7 +66,7 @@ bool output_expected(const char *url, const char *uploadfile) bool stdin_upload(const char *uploadfile) { - return (!strcmp(uploadfile, "-") || !strcmp(uploadfile, ".")); + return !strcmp(uploadfile, "-") || !strcmp(uploadfile, "."); } /* Convert a CURLUcode into a CURLcode */