From f76a54f890d41f7cfa97bb268a90919958b931a7 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 26 Feb 2026 21:36:59 +0100 Subject: [PATCH] clang-tidy: add missing and delete redundant parentheses Reported by clang-tidy v22.1.0. Ref: https://releases.llvm.org/22.1.0/tools/clang/tools/extra/docs/ReleaseNotes.html Closes #20749 --- lib/memdebug.c | 8 ++++---- lib/mime.c | 2 +- lib/mprintf.c | 3 ++- lib/parsedate.c | 4 ++-- lib/tftp.c | 2 +- lib/transfer.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/memdebug.c b/lib/memdebug.c index c4772d3686..af4fc9d6c1 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -219,7 +219,7 @@ void *curl_dbg_malloc(size_t wantedsize, int line, const char *source) /* alloc at least 64 bytes */ size = sizeof(struct memdebug) + wantedsize; - mem = (Curl_cmalloc)(size); + mem = Curl_cmalloc(size); if(mem) { mem->size = wantedsize; } @@ -249,7 +249,7 @@ void *curl_dbg_calloc(size_t wanted_elements, size_t wanted_size, user_size = wanted_size * wanted_elements; size = sizeof(struct memdebug) + user_size; - mem = (Curl_ccalloc)(1, size); + mem = Curl_ccalloc(1, size); if(mem) mem->size = user_size; @@ -344,7 +344,7 @@ void *curl_dbg_realloc(void *ptr, size_t wantedsize, # pragma warning(pop) #endif - mem = (Curl_crealloc)(mem, size); + mem = Curl_crealloc(mem, size); if(source) curl_dbg_log_locked("MEM %s:%d realloc(%p, %zu) = %p\n", source, line, (void *)ptr, wantedsize, @@ -380,7 +380,7 @@ void curl_dbg_free(void *ptr, int line, const char *source) #endif /* free for real */ - (Curl_cfree)(mem); + Curl_cfree(mem); } } diff --git a/lib/mime.c b/lib/mime.c index 51c0fcf28a..bf4916f51b 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -423,7 +423,7 @@ static curl_off_t encoder_base64_size(curl_mimepart *part) return size; /* Unknown size or no data. */ /* Compute base64 character count. */ - size = 4 * (1 + (size - 1) / 3); + size = 4 * (1 + ((size - 1) / 3)); /* Effective character count must include CRLFs. */ return size + (2 * ((size - 1) / MAX_ENCODED_LINE_LENGTH)); diff --git a/lib/mprintf.c b/lib/mprintf.c index d874efe81a..10cede837c 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -676,9 +676,10 @@ static bool out_double(void *userp, #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif + /* !checksrc! disable BANNEDFUNC 1 */ /* !checksrc! disable LONGLINE */ /* NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) */ - (snprintf)(work, BUFFSIZE, formatbuf, dnum); + snprintf(work, BUFFSIZE, formatbuf, dnum); #if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop #endif diff --git a/lib/parsedate.c b/lib/parsedate.c index 1eec38a048..db450f10f7 100644 --- a/lib/parsedate.c +++ b/lib/parsedate.c @@ -422,7 +422,7 @@ static int parsedate(const char *date, time_t *output) (num_digits == 4) && (val <= 1400) && (indate < date) && - ((date[-1] == '+' || date[-1] == '-'))) { + (date[-1] == '+' || date[-1] == '-')) { /* four digits and a value less than or equal to 1400 (to take into account all sorts of funny time zone diffs) and it is preceded with a plus or minus. This is a time zone indication. 1400 is @@ -432,7 +432,7 @@ static int parsedate(const char *date, time_t *output) anyone has a more authoritative source for the exact maximum time zone offsets, please speak up! */ found = TRUE; - tzoff = (val / 100 * 60 + val % 100) * 60; + tzoff = ((val / 100 * 60) + (val % 100)) * 60; /* the + and - prefix indicates the local time compared to GMT, this we need their reversed math to get what we want */ diff --git a/lib/tftp.c b/lib/tftp.c index d6dbc4afa4..1e1bf41577 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -486,7 +486,7 @@ static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event) break; default: - failf(data, "tftp_tx: internal error, event: %i", (int)(event)); + failf(data, "tftp_tx: internal error, event: %i", (int)event); break; } diff --git a/lib/transfer.c b/lib/transfer.c index 71914e13cf..8153e0622f 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -870,8 +870,8 @@ CURLcode Curl_xfer_send_close(struct Curl_easy *data) 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); + bool want_send = (data->req.keepon & KEEP_SEND); + bool want_recv = (data->req.keepon & KEEP_RECV); if(!want_send) return want_recv && Curl_xfer_recv_is_paused(data); else if(!want_recv)