]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: constify `memchr()`/`strchr()`/etc result variables (cont.)
authorViktor Szakats <commit@vsz.me>
Sun, 25 Jan 2026 12:38:09 +0000 (13:38 +0100)
committerViktor Szakats <commit@vsz.me>
Sun, 25 Jan 2026 13:20:37 +0000 (14:20 +0100)
Assisted-by: Rudi Heitbaum
Fixes #20420
Follow-up to 7dc60bdb90c710c2e36b2d05aa3686ff491a9bbe #20425
Follow-up to 0e2507a3c65376d6bda860ff20bd94ada9bbb9fd #20421

Closes #20428

lib/dict.c
lib/http_digest.c
src/tool_operhlp.c
src/tool_urlglob.c
src/tool_writeout.c
tests/libtest/lib1560.c
tests/server/sws.c

index 832da30ce4549dd66d9fea17774619426b278f44..fcdea918cf2b8096fb51c0b94c0cb9d5201a8cf2 100644 (file)
@@ -136,7 +136,7 @@ static CURLcode sendf(struct Curl_easy *data, const char *fmt, ...)
 
 static CURLcode dict_do(struct Curl_easy *data, bool *done)
 {
-  const char *word;
+  char *word;
   char *eword = NULL;
   char *ppath;
   char *database = NULL;
index ccc67f5efcef939ddf1c77274ec2e463f1134864..f5b20c5e9d2dfe323b005dcc27e393715250e5fb 100644 (file)
@@ -69,7 +69,7 @@ CURLcode Curl_output_digest(struct Curl_easy *data,
 {
   CURLcode result;
   unsigned char *path = NULL;
-  char *tmp = NULL;
+  const char *tmp = NULL;
   char *response;
   size_t len;
   bool have_chlg;
index db3365e7f154fbb300cd5808f55a80c7dbad7bf0..035f6b63183da0d65679dc6987a5d208a673aab3 100644 (file)
@@ -116,7 +116,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename)
       /* We only want the part of the local path that is on the right
          side of the rightmost slash and backslash. */
       const char *filep = strrchr(filename, '/');
-      char *file2 = strrchr(filep ? filep : filename, '\\');
+      const char *file2 = strrchr(filep ? filep : filename, '\\');
       char *encfile;
 
       if(file2)
index 6cd8ec176e713919808a70c493a311c18f77f1d7..4ab37c935f93e5406792d1860e2e976eadfe85c4 100644 (file)
@@ -352,7 +352,7 @@ static CURLcode peek_ipv6(const char *str, size_t *skip, bool *ipv6p)
    */
   char hostname[MAX_IP6LEN];
   CURLU *u;
-  char *endbr = strchr(str, ']');
+  const char *endbr = strchr(str, ']');
   size_t hlen;
   CURLUcode rc;
   CURLcode result = CURLE_OK;
index f4de98a2077cc7368485bd64855fd9df07e260cc..fd0224c32a3170a297801ea31449af8dec432a38 100644 (file)
@@ -734,10 +734,10 @@ void ourWriteOut(struct OperationConfig *config, struct per_transfer *per,
       }
       else {
         /* this is meant as a variable to output */
-        char *end;
+        const char *end;
         size_t vlen;
         if('{' == ptr[1]) {
-          struct writeoutvar *wv = NULL;
+          const struct writeoutvar *wv = NULL;
           struct writeoutvar find = { 0 };
           end = strchr(ptr, '}');
           ptr += 2; /* pass the % and the { */
index deb24be9dcbc342d1572fc1a663fa4bf6acd375e..c880902940eed00ed6836fefdca349c583b641e1 100644 (file)
@@ -1185,7 +1185,7 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags)
 
   /* make sure the last command ends with a comma too! */
   while(p) {
-    char *e = strchr(p, ',');
+    const char *e = strchr(p, ',');
     if(e) {
       size_t n = (size_t)(e - p);
       char buf[80];
index 43813c95f880cc35e5730262bef247ea4d765bcb..297cd58174b90dc5373c6cd35ba5a9ba2f14f194 100644 (file)
@@ -491,7 +491,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
 
   if(req->testno == DOCNUMBER_NOTHING) {
     /* check for a Testno: header with the test case number */
-    char *testno = strstr(line, "\nTestno: ");
+    const char *testno = strstr(line, "\nTestno: ");
     if(testno) {
       pval = &testno[9];
       if(!curlx_str_number(&pval, &num, INT_MAX)) {
@@ -596,7 +596,7 @@ static int sws_ProcessRequest(struct sws_httprequest *req)
         return 1; /* done */
       }
       else if(strstr(req->reqbuf, "\r\n0\r\n")) {
-        char *last_crlf_char = strstr(req->reqbuf, "\r\n\r\n");
+        const char *last_crlf_char = strstr(req->reqbuf, "\r\n\r\n");
         while(TRUE) {
           if(!strstr(last_crlf_char + 4, "\r\n\r\n"))
             break;