]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: use STRCONST() when possible in curlx_strcopy() calls
authorDaniel Stenberg <daniel@haxx.se>
Fri, 16 Jan 2026 09:36:07 +0000 (10:36 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 16 Jan 2026 09:55:10 +0000 (10:55 +0100)
Follow-up to a535be4ea0960cfaeeaf74412

Closes #20335

lib/hsts.c
lib/imap.c
lib/mime.c
lib/progress.c
lib/strerror.c

index de6c5731cd5b63bab77dda84b167ad18dac97895..15d4207548d319fc021423e1150e50a95ae71f22 100644 (file)
@@ -294,7 +294,7 @@ static CURLcode hsts_push(struct Curl_easy *data,
                    stamp.tm_hour, stamp.tm_min, stamp.tm_sec);
   }
   else
-    curlx_strcopy(e.expire, sizeof(e.expire), UNLIMITED, strlen(UNLIMITED));
+    curlx_strcopy(e.expire, sizeof(e.expire), STRCONST(UNLIMITED));
 
   sc = data->set.hsts_write(data, &e, i, data->set.hsts_write_userp);
   *stop = (sc != CURLSTS_OK);
index 4ef055c13db295817b415f81dd4e79e999d25cc7..c28395634c4be3e164a713bc8b4203f8cb6306ae 100644 (file)
@@ -1966,7 +1966,7 @@ static CURLcode imap_connect(struct Curl_easy *data, bool *done)
   imap_state(data, imapc, IMAP_SERVERGREET);
 
   /* Start off with an response id of '*' */
-  curlx_strcopy(imapc->resptag, sizeof(imapc->resptag), "*", 1);
+  curlx_strcopy(imapc->resptag, sizeof(imapc->resptag), STRCONST("*"));
 
   result = imap_multi_statemach(data, done);
 
index 22f43794f98081f1a85ec358cc0d6d03b308e349..de811eddb13b13ae080ff386d81ce9b65ccf6073 100644 (file)
@@ -573,7 +573,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
         }
       }
       if(softlinebreak) {
-        curlx_strcopy(buf, sizeof(buf), "\x3D\x0D\x0A", 3);    /* "=\r\n" */
+        curlx_strcopy(buf, sizeof(buf), STRCONST("\x3D\x0D\x0A")); /* =\r\n */
         len = 3;
         consumed = 0;
       }
index 74c8088b49fb95c21ab4d5ac57d7450082e7a1e9..3c9fa88b60f8f62afa898b5954e685a478e4e2ed 100644 (file)
@@ -43,7 +43,7 @@ UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds)
 {
   curl_off_t h;
   if(seconds <= 0) {
-    curlx_strcopy(r, rsize, "       ", 7);
+    curlx_strcopy(r, rsize, STRCONST("       "));
     return;
   }
   h = seconds / 3600;
@@ -76,7 +76,7 @@ UNITTEST void time2str(char *r, size_t rsize, curl_off_t seconds)
         if(y <= 99999)
           curl_msnprintf(r, rsize, "%6" FMT_OFF_T "y", y);
         else
-          curlx_strcopy(r, rsize, ">99999y", 7);
+          curlx_strcopy(r, rsize, STRCONST(">99999y"));
       }
     }
   }
index d7de8e657432278b33ee6e52a648b950e0bd0d64..2f04d1178d0a947790355bf8a58ee418a3a3b96c 100644 (file)
@@ -656,12 +656,12 @@ const char *Curl_sspi_strerror(SECURITY_STATUS err, char *buf, size_t buflen)
     else
       curl_msnprintf(buf, buflen, "%s (0x%08lx)", txt, err);
   }
-#else
+#else /* !CURL_DISABLE_VERBOSE_STRINGS */
+  (void)txt;
   if(err == SEC_E_OK)
-    txt = "No error";
+    curlx_strcopy(buf, buflen, STRCONST("No error"));
   else
-    txt = "Error";
-  curlx_strcopy(buf, buflen, txt, strlen(txt));
+    curlx_strcopy(buf, buflen, STRCONST("Error"));
 #endif
 
   if(errno != old_errno)