]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tidy-up: minor code fixes and improvements
authorViktor Szakats <commit@vsz.me>
Fri, 24 Jul 2026 22:11:21 +0000 (00:11 +0200)
committerViktor Szakats <commit@vsz.me>
Thu, 30 Jul 2026 10:00:22 +0000 (12:00 +0200)
- schannel: drop redundant parentheses.
- os400sys: drop redundant includes.
  Follow-up to ebc5212dacd3db8f5315b5a2d676415848e936d5 #22374
- pytest: replace `()` with `[]` to match rest of tests.
- libtests: constify some local pointers.
- libtests: drop redundant `(long)` casts.
- lib650: use `CURL_CSTRLEN()`.
  Follow-up to 59dc2bbe07c3b5889e0b380e5fa384d338d9d24e #22424

Closes #22444

lib/vtls/schannel.c
projects/OS400/os400sys.c
tests/http/test_02_download.py
tests/http/test_21_resolve.py
tests/libtest/lib1549.c
tests/libtest/lib1582.c
tests/libtest/lib3102.c
tests/libtest/lib3207.c
tests/libtest/lib5000.c
tests/libtest/lib5004.c
tests/libtest/lib650.c

index 583c87222da09ff7425d5c3ce12abea5719d195b..88d7ccec88f0d907c63a25684c98a1f7399ec95d 100644 (file)
@@ -921,7 +921,7 @@ static CURLcode schannel_connect_step1(struct Curl_cfilter *cf,
 
     /* The first four bytes is an unsigned int indicating number
        of bytes of data in the rest of the buffer. */
-    extension_len = (unsigned int *)(void *)(&alpn_buffer[cur]);
+    extension_len = (unsigned int *)(void *)&alpn_buffer[cur];
     cur += (int)sizeof(unsigned int);
 
     /* The next four bytes are an indicator that this buffer contains
@@ -932,7 +932,7 @@ static CURLcode schannel_connect_step1(struct Curl_cfilter *cf,
 
     /* The next two bytes is an unsigned short indicating the number
        of bytes used to list the preferred protocols. */
-    list_len = (unsigned short *)(void *)(&alpn_buffer[cur]);
+    list_len = (unsigned short *)(void *)&alpn_buffer[cur];
     cur += (int)sizeof(unsigned short);
 
     list_start_index = cur;
index 41f0f670e70b6be7afd9dca415c1d32121ecf487..bea84500629d083e9d172803159b839b77ca14db 100644 (file)
@@ -28,8 +28,6 @@
 #include <curl/curl.h>
 #include "config-os400.h"  /* Not curl_setup.h: we only need some defines. */
 
-#include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 
 #include <stdlib.h>
index 940245920d47a3d2c30e1387f925aadfb4d0a003..e556c014b8219e239ed3ffe223e17b9194a21209 100644 (file)
@@ -718,7 +718,7 @@ class TestDownload:
                 # or destroys the connection with internal error
                 # ERR_QPACK_HEADER_TOO_LARGE,
                 # depending on nghttp3 version and payload size
-                assert r.exit_code in (0, 56), f'expected exit code 0 or 56, '\
+                assert r.exit_code in [0, 56], f'expected exit code 0 or 56, '\
                                                f'got {r.exit_code}\n{r.dump_logs()}'
                 if r.exit_code == 0:
                     r.check_response(http_status=431)
index a287cfdf8f9e6bdcf6310487f116e8eec0c6fa0e..ec15de7a9c19d2fc7001f4ce7e39283cb80a034f 100644 (file)
@@ -298,7 +298,7 @@ class TestResolve:
             '--connect-timeout', '1'
         ])
         # should fail with CURLE_OPERATION_TIMEOUT or COULDNT_CONNECT
-        assert r.exit_code in (7, 28), f'{r.dump_logs()}'
+        assert r.exit_code in [7, 28], f'{r.dump_logs()}'
         af_unspec_resolves = [
             line for line in r.trace_lines
             if re.match(r'.* \[DNS] re-queueing query .+ for AF_UNSPEC resolve', line)
index e004546f58fe38d2dc1bc4914da0968811a3bed2..04510526bb5cbad24f346ebd4d1b4d210932e1b3 100644 (file)
@@ -55,7 +55,7 @@ static CURLcode test_lib1549(const char *URL)
     result = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
     if(!result && cookies) {
       /* a linked list of cookies in cookie file format */
-      struct curl_slist *each = cookies;
+      const struct curl_slist *each = cookies;
       while(each) {
         curl_mprintf("%s\n", each->data);
         each = each->next;
index ec9624be940b81eadc642dc3799477fae9d72468..81f8664ef3088c5d5c1191b140037337b07173ec 100644 (file)
@@ -43,7 +43,7 @@ static CURLcode test_lib1582(const char *URL)
   easy_setopt(curl, CURLOPT_HEADER, 1L);
   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
   easy_setopt(curl, CURLOPT_URL, URL);
-  easy_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_NEGOTIATE);
+  easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE);
   easy_setopt(curl, CURLOPT_USERPWD, ":");
   easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
   easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
index 312d5e600e00373d26275a48244d45fd5170fdc9..b3af3981a1688ac35d5e339fcb467e84bb1f650c 100644 (file)
@@ -38,7 +38,7 @@ static bool is_chain_in_order(struct curl_certinfo *cert_info)
 
   /* Enumerate each certificate in the chain */
   for(cert = 0; cert < cert_info->num_of_certs; cert++) {
-    struct curl_slist *slist = cert_info->certinfo[cert];
+    const struct curl_slist *slist = cert_info->certinfo[cert];
     const char *issuer = NULL;
     const char *subject = NULL;
 
index 77df591710c88ea434b6e2d5e6d40852f9c540d3..f28085c8652df96ea0e01ca2a5d208a40ea3a96c 100644 (file)
@@ -197,7 +197,7 @@ static CURLcode test_lib3207(const char *URL)
       result = ctx[i].result;
     }
     else {
-      struct curl_slist *item = ctx[i].contents;
+      const struct curl_slist *item = ctx[i].contents;
       while(item) {
         curl_mprintf("%s", item->data);
         item = item->next;
index 05c5b99ac4fa68f188a8758a9fe9fe95df4e40fd..511b26c8e48184caf25b779a241caa9e02e7ba8b 100644 (file)
@@ -42,7 +42,7 @@ static CURLcode test_lib5000(const char *URL)
   }
 
   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-  easy_setopt(curl, CURLOPT_HTTPSIG_ALGORITHM, (long)CURLHTTPSIG_ED25519);
+  easy_setopt(curl, CURLOPT_HTTPSIG_ALGORITHM, CURLHTTPSIG_ED25519);
   easy_setopt(curl, CURLOPT_HTTPSIG_KEY,
               "9f8362f87a484a954e6e740c5b4c0e84"
               "229139a20aa8ab56ff66586f6a7d29c5");
index 767bec410a63334ab41b1bead2e12a4fd05c0c6b..08ab3b6f384b80d867c76d99d45f2fceffb2775c 100644 (file)
@@ -49,7 +49,7 @@ static CURLcode test_lib5004(const char *URL)
   }
 
   easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-  easy_setopt(curl, CURLOPT_HTTPSIG_ALGORITHM, (long)CURLHTTPSIG_ED25519);
+  easy_setopt(curl, CURLOPT_HTTPSIG_ALGORITHM, CURLHTTPSIG_ED25519);
   easy_setopt(curl, CURLOPT_HTTPSIG_KEY,
               "9f8362f87a484a954e6e740c5b4c0e84"
               "229139a20aa8ab56ff66586f6a7d29c5");
index ac56c4f35bc4cb0f2fb3cbf5e7be29c07c02ecc1..04b288725fc4d529204d2e77e920d49eebf23102 100644 (file)
@@ -92,7 +92,7 @@ static CURLcode test_lib650(const char *URL)
   formrc = curl_formadd(&formpost,
                         &lastptr,
                         CURLFORM_PTRNAME, testname,
-                        CURLFORM_NAMELENGTH, (long)(sizeof(testname) - 2),
+                        CURLFORM_NAMELENGTH, (long)CURL_CSTRLEN(testname) - 1,
                         CURLFORM_ARRAY, formarray,
                         CURLFORM_FILENAME, "remotefile.txt",
                         CURLFORM_END);