]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
clang-tidy: fix issues found with build-fuzzing
authorViktor Szakats <commit@vsz.me>
Sat, 28 Feb 2026 21:41:23 +0000 (22:41 +0100)
committerViktor Szakats <commit@vsz.me>
Sat, 28 Feb 2026 23:04:18 +0000 (00:04 +0100)
- 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 57ff2d6c918d0bb444e5a8a53405217aec116b1b #20106

Closes #20774

lib/curl_sha512_256.c
lib/doh.c
lib/url.c
lib/vtls/vtls.c
tests/unit/unit1607.c
tests/unit/unit1609.c
tests/unit/unit2600.c

index 2f51d2a4cd103d566628ec18a010da194589c430..00f4d1071f6b3bd9a4542da177b840e93451df03 100644 (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
index 283746cab3b9bbcecd92c017bb6acdc6822c7fa7..7fe4a060587e1ee12c0835aae52a5e48502a6b05 100644 (file)
--- a/lib/doh.c
+++ b/lib/doh.c
@@ -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
index 0e594681eaea43d3b3a9f5e6fa9013a2e9e0e1a7..495de2297cbdccf53e1180f5ba78ec3d5c0352a7 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -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
index df9bc33a7b37e5f91826b4fa7f05df8c091e1d06..f7201d18d6507d9f7d076928385d1304bff16dd1 100644 (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,
index 3072130cce7d231c1036f8b129b39d516a9ab6ea..3265df484a9874e3f1d4ff37ec909fdaf6832302 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "urldata.h"
 #include "connect.h"
+#include "curl_addrinfo.h"
 
 static CURLcode t1607_setup(void)
 {
index 366b117abe80e97a7c52efec875f92754119caa1..a862154176fbea2cc1f5ea5c48e0f1b4697a46b6 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "urldata.h"
 #include "connect.h"
+#include "curl_addrinfo.h"
 
 static CURLcode t1609_setup(void)
 {
index 97d4caed96e6afcec2e79275b015db768f4a5fcb..4bd12313e642d92eb06b4a5bb058658356171a3c 100644 (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)