]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib, src: delete stray `curl_` prefix from printf calls
authorViktor Szakats <commit@vsz.me>
Fri, 23 Aug 2024 12:44:16 +0000 (14:44 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 26 Aug 2024 09:00:15 +0000 (11:00 +0200)
Also:
- unit1398: delete redundant `curl/mprintf.h` include.

Closes #14664

lib/http_aws_sigv4.c
lib/mime.c
lib/netrc.c
src/tool_cb_wrt.c
src/tool_easysrc.c
src/tool_findfile.c
src/tool_msgs.c
src/tool_paramhlp.c
tests/unit/unit1398.c

index a2c8ac1c89a32460b45877b6fcbf6358dd615ff3..3874993e9ebba5c87a1eb1d68e851c48c84983cf 100644 (file)
@@ -271,7 +271,7 @@ static CURLcode make_headers(struct Curl_easy *data,
     if(!tmp_head)
       goto fail;
     head = tmp_head;
-    *date_header = curl_maprintf("%s: %s\r\n", date_hdr_key, timestamp);
+    *date_header = aprintf("%s: %s\r\n", date_hdr_key, timestamp);
   }
   else {
     char *value;
@@ -766,19 +766,19 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy)
   result = CURLE_OUT_OF_MEMORY;
 
   canonical_request =
-    curl_maprintf("%s\n" /* HTTPRequestMethod */
-                  "%s\n" /* CanonicalURI */
-                  "%s\n" /* CanonicalQueryString */
-                  "%s\n" /* CanonicalHeaders */
-                  "%s\n" /* SignedHeaders */
-                  "%.*s",  /* HashedRequestPayload in hex */
-                  method,
-                  Curl_dyn_ptr(&canonical_path),
-                  Curl_dyn_ptr(&canonical_query) ?
-                  Curl_dyn_ptr(&canonical_query) : "",
-                  Curl_dyn_ptr(&canonical_headers),
-                  Curl_dyn_ptr(&signed_headers),
-                  (int)payload_hash_len, payload_hash);
+    aprintf("%s\n" /* HTTPRequestMethod */
+            "%s\n" /* CanonicalURI */
+            "%s\n" /* CanonicalQueryString */
+            "%s\n" /* CanonicalHeaders */
+            "%s\n" /* SignedHeaders */
+            "%.*s",  /* HashedRequestPayload in hex */
+            method,
+            Curl_dyn_ptr(&canonical_path),
+            Curl_dyn_ptr(&canonical_query) ?
+            Curl_dyn_ptr(&canonical_query) : "",
+            Curl_dyn_ptr(&canonical_headers),
+            Curl_dyn_ptr(&signed_headers),
+            (int)payload_hash_len, payload_hash);
   if(!canonical_request)
     goto fail;
 
@@ -786,12 +786,12 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy)
 
   /* provider 0 lowercase */
   Curl_strntolower(provider0, provider0, strlen(provider0));
-  request_type = curl_maprintf("%s4_request", provider0);
+  request_type = aprintf("%s4_request", provider0);
   if(!request_type)
     goto fail;
 
-  credential_scope = curl_maprintf("%s/%s/%s/%s",
-                                   date, region, service, request_type);
+  credential_scope = aprintf("%s/%s/%s/%s",
+                             date, region, service, request_type);
   if(!credential_scope)
     goto fail;
 
@@ -808,22 +808,22 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy)
    * Google allows using RSA key instead of HMAC, so this code might change
    * in the future. For now we only support HMAC.
    */
-  str_to_sign = curl_maprintf("%s4-HMAC-SHA256\n" /* Algorithm */
-                              "%s\n" /* RequestDateTime */
-                              "%s\n" /* CredentialScope */
-                              "%s",  /* HashedCanonicalRequest in hex */
-                              provider0,
-                              timestamp,
-                              credential_scope,
-                              sha_hex);
+  str_to_sign = aprintf("%s4-HMAC-SHA256\n" /* Algorithm */
+                        "%s\n" /* RequestDateTime */
+                        "%s\n" /* CredentialScope */
+                        "%s",  /* HashedCanonicalRequest in hex */
+                        provider0,
+                        timestamp,
+                        credential_scope,
+                        sha_hex);
   if(!str_to_sign) {
     goto fail;
   }
 
   /* provider 0 uppercase */
-  secret = curl_maprintf("%s4%s", provider0,
-                         data->state.aptr.passwd ?
-                         data->state.aptr.passwd : "");
+  secret = aprintf("%s4%s", provider0,
+                   data->state.aptr.passwd ?
+                   data->state.aptr.passwd : "");
   if(!secret)
     goto fail;
 
@@ -836,24 +836,24 @@ CURLcode Curl_output_aws_sigv4(struct Curl_easy *data, bool proxy)
   sha256_to_hex(sha_hex, sign0);
 
   /* provider 0 uppercase */
-  auth_headers = curl_maprintf("Authorization: %s4-HMAC-SHA256 "
-                               "Credential=%s/%s, "
-                               "SignedHeaders=%s, "
-                               "Signature=%s\r\n"
-                               /*
-                                * date_header is added here, only if it was not
-                                * user-specified (using CURLOPT_HTTPHEADER).
-                                * date_header includes \r\n
-                                */
-                               "%s"
-                               "%s", /* optional sha256 header includes \r\n */
-                               provider0,
-                               user,
-                               credential_scope,
-                               Curl_dyn_ptr(&signed_headers),
-                               sha_hex,
-                               date_header ? date_header : "",
-                               content_sha256_hdr);
+  auth_headers = aprintf("Authorization: %s4-HMAC-SHA256 "
+                         "Credential=%s/%s, "
+                         "SignedHeaders=%s, "
+                         "Signature=%s\r\n"
+                         /*
+                          * date_header is added here, only if it was not
+                          * user-specified (using CURLOPT_HTTPHEADER).
+                          * date_header includes \r\n
+                          */
+                         "%s"
+                         "%s", /* optional sha256 header includes \r\n */
+                         provider0,
+                         user,
+                         credential_scope,
+                         Curl_dyn_ptr(&signed_headers),
+                         sha_hex,
+                         date_header ? date_header : "",
+                         content_sha256_hdr);
   if(!auth_headers) {
     goto fail;
   }
index 9ba55fe3d27bbbf7b8a0a109e91f6abbb7838079..d74dd2c31ad13f9956afc5c4316d1d5a32552f59 100644 (file)
@@ -1680,7 +1680,7 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
   va_list ap;
 
   va_start(ap, fmt);
-  s = curl_mvaprintf(fmt, ap);
+  s = vaprintf(fmt, ap);
   va_end(ap);
 
   if(s) {
index 571fc73599bcfab1abaefa18de551d6c4b9fe598..490efb64caaf35ac035720cfc4066930a8f1280b 100644 (file)
@@ -324,7 +324,7 @@ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp,
       return retcode; /* no home directory found (or possibly out of
                          memory) */
 
-    filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR);
+    filealloc = aprintf("%s%s.netrc", home, DIR_CHAR);
     if(!filealloc) {
       free(homea);
       return -1;
@@ -334,7 +334,7 @@ int Curl_parsenetrc(const char *host, char **loginp, char **passwordp,
 #ifdef _WIN32
     if(retcode == NETRC_FILE_MISSING) {
       /* fallback to the old-style "_netrc" file */
-      filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR);
+      filealloc = aprintf("%s%s_netrc", home, DIR_CHAR);
       if(!filealloc) {
         free(homea);
         return -1;
index 0eca2edaccebbf906a94bed8fb59521ac56d6a63..660000b6966d91ec36157d5fe6e93e919aa29783 100644 (file)
@@ -96,7 +96,7 @@ bool tool_create_output_file(struct OutStruct *outs,
             (errno == EEXIST || errno == EISDIR) &&
             /* because we keep having files that already exist */
             next_num < 100 /* and we have not reached the retry limit */ ) {
-        curl_msnprintf(newname + len + 1, 12, "%d", next_num);
+        msnprintf(newname + len + 1, 12, "%d", next_num);
         next_num++;
         do {
           fd = open(newname, O_CREAT | O_WRONLY | O_EXCL | O_BINARY, OPENMODE);
index 296eb34bd7b2a3ab42a6336d44f67260318e19bc..a623f1961345bc61cd0fb0498e6174b535ee84cb 100644 (file)
@@ -111,7 +111,7 @@ CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
   char *bufp;
   va_list ap;
   va_start(ap, fmt);
-  bufp = curl_mvaprintf(fmt, ap);
+  bufp = vaprintf(fmt, ap);
   va_end(ap);
   if(!bufp) {
     ret = CURLE_OUT_OF_MEMORY;
index 2496cf7db642f5378453bcf89946e07538086689..672fc7b9924957955e4df611697b73cf570e26e9 100644 (file)
@@ -35,7 +35,7 @@
 #include <fcntl.h>
 #endif
 
-#include <curl/mprintf.h>
+#include <curlx.h>
 
 #include "tool_findfile.h"
 
@@ -72,9 +72,9 @@ static char *checkhome(const char *home, const char *fname, bool dotscore)
   for(i = 0; i < (dotscore ? 2 : 1); i++) {
     char *c;
     if(dotscore)
-      c = curl_maprintf("%s" DIR_CHAR "%c%s", home, pref[i], &fname[1]);
+      c = aprintf("%s" DIR_CHAR "%c%s", home, pref[i], &fname[1]);
     else
-      c = curl_maprintf("%s" DIR_CHAR "%s", home, fname);
+      c = aprintf("%s" DIR_CHAR "%s", home, fname);
     if(c) {
       int fd = open(c, O_RDONLY);
       if(fd >= 0) {
@@ -118,7 +118,7 @@ char *findfile(const char *fname, int dotscore)
         continue;
       }
       if(conf_list[i].append) {
-        char *c = curl_maprintf("%s%s", home, conf_list[i].append);
+        char *c = aprintf("%s%s", home, conf_list[i].append);
         curl_free(home);
         if(!c)
           return NULL;
index 083250ee1d20b57b8b235d12e058e955f0d4d760..58b935e962e4bcf778f6f1afedad22c901f65574 100644 (file)
@@ -53,7 +53,7 @@ static void voutf(struct GlobalConfig *config,
     char *ptr;
     char *print_buffer;
 
-    print_buffer = curl_mvaprintf(fmt, ap);
+    print_buffer = vaprintf(fmt, ap);
     if(!print_buffer)
       return;
     len = strlen(print_buffer);
index 39b1ffc77877b5106221d8158d85cd23ba33ab83..d4024e13401a02e445b353825505ec7f274c5f04 100644 (file)
@@ -557,13 +557,13 @@ static CURLcode checkpasswd(const char *kind, /* for what purpose */
 
     /* build a nice-looking prompt */
     if(!i && last)
-      curl_msnprintf(prompt, sizeof(prompt),
-                     "Enter %s password for user '%s':",
-                     kind, *userpwd);
+      msnprintf(prompt, sizeof(prompt),
+                "Enter %s password for user '%s':",
+                kind, *userpwd);
     else
-      curl_msnprintf(prompt, sizeof(prompt),
-                     "Enter %s password for user '%s' on URL #%zu:",
-                     kind, *userpwd, i + 1);
+      msnprintf(prompt, sizeof(prompt),
+                "Enter %s password for user '%s' on URL #%zu:",
+                kind, *userpwd, i + 1);
 
     /* get password */
     getpass_r(prompt, passwd, sizeof(passwd));
index 4283a8d1b98772cb9599ad19460c8811ea8ec652..220665bc52e8508981657994c3a97a1064975797 100644 (file)
@@ -25,8 +25,6 @@
 
 #include "curlcheck.h"
 
-#include "curl/mprintf.h"
-
 static CURLcode unit_setup(void) {return CURLE_OK;}
 static void unit_stop(void) {}