From 573e7e827e1e5ae499940d8cc666400f15b0b33d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 23 Aug 2024 14:44:16 +0200 Subject: [PATCH] lib, src: delete stray `curl_` prefix from printf calls Also: - unit1398: delete redundant `curl/mprintf.h` include. Closes #14664 --- lib/http_aws_sigv4.c | 92 +++++++++++++++++++++---------------------- lib/mime.c | 2 +- lib/netrc.c | 4 +- src/tool_cb_wrt.c | 2 +- src/tool_easysrc.c | 2 +- src/tool_findfile.c | 8 ++-- src/tool_msgs.c | 2 +- src/tool_paramhlp.c | 12 +++--- tests/unit/unit1398.c | 2 - 9 files changed, 62 insertions(+), 64 deletions(-) diff --git a/lib/http_aws_sigv4.c b/lib/http_aws_sigv4.c index a2c8ac1c89..3874993e9e 100644 --- a/lib/http_aws_sigv4.c +++ b/lib/http_aws_sigv4.c @@ -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; } diff --git a/lib/mime.c b/lib/mime.c index 9ba55fe3d2..d74dd2c31a 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -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) { diff --git a/lib/netrc.c b/lib/netrc.c index 571fc73599..490efb64ca 100644 --- a/lib/netrc.c +++ b/lib/netrc.c @@ -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; diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 0eca2edacc..660000b696 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -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); diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c index 296eb34bd7..a623f19613 100644 --- a/src/tool_easysrc.c +++ b/src/tool_easysrc.c @@ -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; diff --git a/src/tool_findfile.c b/src/tool_findfile.c index 2496cf7db6..672fc7b992 100644 --- a/src/tool_findfile.c +++ b/src/tool_findfile.c @@ -35,7 +35,7 @@ #include #endif -#include +#include #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; diff --git a/src/tool_msgs.c b/src/tool_msgs.c index 083250ee1d..58b935e962 100644 --- a/src/tool_msgs.c +++ b/src/tool_msgs.c @@ -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); diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index 39b1ffc778..d4024e1340 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -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)); diff --git a/tests/unit/unit1398.c b/tests/unit/unit1398.c index 4283a8d1b9..220665bc52 100644 --- a/tests/unit/unit1398.c +++ b/tests/unit/unit1398.c @@ -25,8 +25,6 @@ #include "curlcheck.h" -#include "curl/mprintf.h" - static CURLcode unit_setup(void) {return CURLE_OK;} static void unit_stop(void) {}