clang-tidy: fix issues found with build-fuzzing

- curl_sha512_256: add missing, drop redundant, parentheses.
- doh: drop redundant returns.
- url: add missing parentheses.
- vtls: fix unused const variables.
- tests/unit: fix missing header with clang-tidy and !threaded-resolver.
  Follow-up to 57ff2d6c91 #20106

Closes #20774
This commit is contained in:
Viktor Szakats 2026-02-28 22:41:23 +01:00
parent bcc8144b89
commit 35bbb2e830
No known key found for this signature in database
7 changed files with 19 additions and 20 deletions

View file

@ -452,14 +452,14 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
/* Four 'Sigma' macro functions.
See FIPS PUB 180-4 formulae 4.10, 4.11, 4.12, 4.13. */
#define SIG0(x) \
(Curl_rotr64((x), 28) ^ Curl_rotr64((x), 34) ^ Curl_rotr64((x), 39))
#define SIG1(x) \
(Curl_rotr64((x), 14) ^ Curl_rotr64((x), 18) ^ Curl_rotr64((x), 41))
#define sig0(x) \
(Curl_rotr64((x), 1) ^ Curl_rotr64((x), 8) ^ ((x) >> 7))
#define sig1(x) \
(Curl_rotr64((x), 19) ^ Curl_rotr64((x), 61) ^ ((x) >> 6))
#define SIG0(x) \
(Curl_rotr64(x, 28) ^ Curl_rotr64(x, 34) ^ Curl_rotr64(x, 39))
#define SIG1(x) \
(Curl_rotr64(x, 14) ^ Curl_rotr64(x, 18) ^ Curl_rotr64(x, 41))
#define sig0(x) \
(Curl_rotr64(x, 1) ^ Curl_rotr64(x, 8) ^ ((x) >> 7))
#define sig1(x) \
(Curl_rotr64(x, 19) ^ Curl_rotr64(x, 61) ^ ((x) >> 6))
if(1) {
unsigned int t;
@ -520,8 +520,8 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
used. */
#define SHA2STEP64(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt) \
do { \
(vD) += ((vH) += SIG1((vE)) + Sha512_Ch((vE), (vF), (vG)) + (kt) + (wt)); \
(vH) += SIG0((vA)) + Sha512_Maj((vA), (vB), (vC)); \
(vD) += ((vH) += SIG1(vE) + Sha512_Ch(vE, vF, vG) + (kt) + (wt)); \
(vH) += SIG0(vA) + Sha512_Maj(vA, vB, vC); \
} while(0)
/* One step of SHA-512/256 computation with working variables rotation,
@ -530,7 +530,7 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
#define SHA2STEP64RV(vA, vB, vC, vD, vE, vF, vG, vH, kt, wt) \
do { \
uint64_t tmp_h_ = (vH); \
SHA2STEP64((vA), (vB), (vC), (vD), (vE), (vF), (vG), tmp_h_, (kt), (wt)); \
SHA2STEP64(vA, vB, vC, vD, vE, vF, vG, tmp_h_, kt, wt); \
(vH) = (vG); \
(vG) = (vF); \
(vF) = (vE); \
@ -546,7 +546,7 @@ static void Curl_sha512_256_transform(uint64_t H[SHA512_256_HASH_SIZE_WORDS],
Input data must be read in big-endian bytes order,
see FIPS PUB 180-4 section 3.1.2. */
#define SHA512_GET_W_FROM_DATA(buf, t) \
CURL_GET_64BIT_BE(((const uint8_t *)(buf)) + (t) * SHA512_256_BYTES_IN_WORD)
CURL_GET_64BIT_BE((const uint8_t *)(buf) + ((t) * SHA512_256_BYTES_IN_WORD))
/* During first 16 steps, before making any calculation on each step, the
W element is read from the input data buffer as a big-endian value and

View file

@ -201,7 +201,6 @@ static void doh_print_buf(struct Curl_easy *data,
infof(data, "%s: len=%d, val=%s", prefix, (int)len, hexstr);
else
infof(data, "%s: len=%d (truncated)val=%s", prefix, (int)len, hexstr);
return;
}
#endif
@ -1191,7 +1190,6 @@ UNITTEST void doh_print_httpsrr(struct Curl_easy *data,
}
else
infof(data, "HTTPS RR: no ipv6hints");
return;
}
# endif
#endif

View file

@ -953,7 +953,7 @@ static bool url_match_proxy_use(struct connectdata *conn,
return TRUE;
}
#else
#define url_match_proxy_use(c, m) ((void)c, (void)m, TRUE)
#define url_match_proxy_use(c, m) ((void)(c), (void)(m), TRUE)
#endif
#ifndef CURL_DISABLE_HTTP
@ -1009,8 +1009,8 @@ static bool url_match_http_version(struct connectdata *conn,
return TRUE;
}
#else
#define url_match_http_multiplex(c, m) ((void)c, (void)m, TRUE)
#define url_match_http_version(c, m) ((void)c, (void)m, TRUE)
#define url_match_http_multiplex(c, m) ((void)(c), (void)(m), TRUE)
#define url_match_http_version(c, m) ((void)(c), (void)(m), TRUE)
#endif
static bool url_match_proto_config(struct connectdata *conn,
@ -1178,7 +1178,7 @@ static bool url_match_auth_ntlm(struct connectdata *conn,
return TRUE;
}
#else
#define url_match_auth_ntlm(c, m) ((void)c, (void)m, TRUE)
#define url_match_auth_ntlm(c, m) ((void)(c), (void)(m), TRUE)
#endif
#ifdef USE_SPNEGO

View file

@ -136,7 +136,6 @@ static const struct alpn_spec ALPN_SPEC_H11 = {
static const struct alpn_spec ALPN_SPEC_H10_H11 = {
{ ALPN_HTTP_1_0, ALPN_HTTP_1_1 }, 2
};
#endif /* !CURL_DISABLE_HTTP || !CURL_DISABLE_PROXY */
#ifdef USE_HTTP2
static const struct alpn_spec ALPN_SPEC_H2 = {
{ ALPN_H2 }, 1
@ -149,7 +148,6 @@ static const struct alpn_spec ALPN_SPEC_H11_H2 = {
};
#endif /* USE_HTTP2 */
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_PROXY)
static const struct alpn_spec *alpn_get_spec(http_majors wanted,
http_majors preferred,
bool only_http_10,

View file

@ -25,6 +25,7 @@
#include "urldata.h"
#include "connect.h"
#include "curl_addrinfo.h"
static CURLcode t1607_setup(void)
{

View file

@ -25,6 +25,7 @@
#include "urldata.h"
#include "connect.h"
#include "curl_addrinfo.h"
static CURLcode t1609_setup(void)
{

View file

@ -46,6 +46,7 @@
#include "cf-ip-happy.h"
#include "multiif.h"
#include "select.h"
#include "curl_addrinfo.h"
#include "curl_trc.h"
static CURLcode t2600_setup(CURL **easy)