]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: delete/replace clang warning pragmas
authorViktor Szakats <commit@vsz.me>
Sat, 27 Jan 2024 17:40:38 +0000 (17:40 +0000)
committerViktor Szakats <commit@vsz.me>
Sat, 27 Jan 2024 21:19:41 +0000 (21:19 +0000)
- delete redundant warning suppressions for `-Wformat-nonliteral`.
  This now relies on `CURL_PRINTF()` and it's theoratically possible
  that this macro isn't active but the warning is. We're ignoring this
  as a corner-case here.

- replace two pragmas with code changes to avoid the warnings.

Follow-up to aee4ebe59161d0a5281743f96e7738ad97fe1cd4 #12803
Follow-up to 09230127589eccc7e01c1a7217787ef8e64f3328 #12540
Follow-up to 3829759bd042c03225ae862062560f568ba1a231 #12489

Reviewed-by: Daniel Stenberg
Closes #12812

lib/curl_trc.c
lib/dict.c
lib/dynbuf.c
lib/memdebug.c
lib/mime.c
src/tool_easysrc.c
src/tool_msgs.c
src/tool_setopt.c
tests/libtest/lib1560.c

index 1c49d5535689de188c5b69eb023d8764a8bb6a8f..b8dccc41937763baa1b6c8dce3f355f6f3358efa 100644 (file)
@@ -92,14 +92,7 @@ void Curl_failf(struct Curl_easy *data, const char *fmt, ...)
     int len;
     char error[CURL_ERROR_SIZE + 2];
     va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
     len = mvsnprintf(error, CURL_ERROR_SIZE, fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
 
     if(data->set.errorbuffer && !data->state.errorbuf) {
       strcpy(data->set.errorbuffer, error);
@@ -125,14 +118,7 @@ void Curl_infof(struct Curl_easy *data, const char *fmt, ...)
     int len;
     char buffer[MAXINFO + 2];
     va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
     len = mvsnprintf(buffer, MAXINFO, fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
     va_end(ap);
     buffer[len++] = '\n';
     buffer[len] = '\0';
@@ -150,14 +136,7 @@ void Curl_trc_cf_infof(struct Curl_easy *data, struct Curl_cfilter *cf,
     char buffer[MAXINFO + 2];
     len = msnprintf(buffer, MAXINFO, "[%s] ", cf->cft->name);
     va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
     len += mvsnprintf(buffer + len, MAXINFO - len, fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
     va_end(ap);
     buffer[len++] = '\n';
     buffer[len] = '\0';
index 2d6e7e48c5c646769c13741edfd2e33fcb239485..323984822df031ca1301a9665900b99a4e7f547a 100644 (file)
@@ -135,14 +135,7 @@ static CURLcode sendf(curl_socket_t sockfd, struct Curl_easy *data,
   char *sptr;
   va_list ap;
   va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
   s = vaprintf(fmt, ap); /* returns an allocated string */
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
   va_end(ap);
   if(!s)
     return CURLE_OUT_OF_MEMORY; /* failure */
index a6a71c5daa80ee57ce24e7c2b8c23b765ab34417..a4c599d10c78c3924c5f3eacee838ca89df4b059 100644 (file)
@@ -204,14 +204,7 @@ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
   return CURLE_OUT_OF_MEMORY;
 #else
   char *str;
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
   str = vaprintf(fmt, ap); /* this allocs a new string to append */
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
 
   if(str) {
     CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str));
index f3d4817233336f040468ed8bb838c3f14bfa9798..fce933a32246e21b66b9e2e6e4686d6fa869fb8a 100644 (file)
@@ -448,14 +448,7 @@ void curl_dbg_log(const char *format, ...)
     return;
 
   va_start(ap, format);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
   nchars = mvsnprintf(buf, LOGLINE_BUFSIZE, format, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
   va_end(ap);
 
   if(nchars > LOGLINE_BUFSIZE - 1)
index e6553816fa3a5773e53a33fb8d50c4f498d7f1b4..d712331d0405e18fe94f6b7cbb3e1aab76a2e3ae 100644 (file)
@@ -1677,14 +1677,7 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...)
   va_list ap;
 
   va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
   s = curl_mvaprintf(fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
   va_end(ap);
 
   if(s) {
index 8b9c68c91fea50f7c9907c6073bdca7762145b16..6ef2be721cfd4d475494bd9254240aeca0d22a84 100644 (file)
@@ -113,14 +113,7 @@ CURLcode easysrc_addf(struct slist_wc **plist, const char *fmt, ...)
   char *bufp;
   va_list ap;
   va_start(ap, fmt);
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
   bufp = curlx_mvaprintf(fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
   va_end(ap);
   if(!bufp) {
     ret = CURLE_OUT_OF_MEMORY;
index d11c5186bfe40d061c332c635d47ba74168a3c58..04fae58a9ba2f81cf208257be77d57c3312b7f1e 100644 (file)
@@ -53,14 +53,7 @@ static void voutf(struct GlobalConfig *config,
     char *ptr;
     char *print_buffer;
 
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
     print_buffer = curlx_mvaprintf(fmt, ap);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
     if(!print_buffer)
       return;
     len = strlen(print_buffer);
index 1c3096b8b469b0229dbce940be6dd7c1e5fa6394..b41b6d1d263c484177781358ac7ccc48aeaa31a5 100644 (file)
@@ -240,22 +240,11 @@ static char *c_escape(const char *str, curl_off_t len)
       if(p && *p)
         result = curlx_dyn_addn(&escaped, to + 2 * (p - from), 2);
       else {
-        const char *format = "\\x%02x";
-
-        if(len > 1 && ISXDIGIT(s[1])) {
-          /* Octal escape to avoid >2 digit hex. */
-          format = "\\%03o";
-        }
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
-        result = curlx_dyn_addf(&escaped, format,
+        result = curlx_dyn_addf(&escaped,
+                                /* Octal escape to avoid >2 digit hex. */
+                                (len > 1 && ISXDIGIT(s[1])) ?
+                                  "\\%03o" : "\\x%02x",
                                 (unsigned int) *(unsigned char *) s);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
       }
     }
   }
index 6e734d2bf2d33cc73fafa45c1a9e8d32733a068e..1509c76a7fd7d21b98df862de5596c7da79aa380 100644 (file)
@@ -1639,7 +1639,6 @@ static char bigpart[120000];
  */
 static int huge(void)
 {
-  const char *url = "%s://%s:%s@%s/%s?%s#%s";
   const char *smallpart = "c";
   int i;
   CURLU *urlp = curl_url();
@@ -1662,12 +1661,8 @@ static int huge(void)
 
   for(i = 0; i <  7; i++) {
     char *partp;
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wformat-nonliteral"
-#endif
     msnprintf(total, sizeof(total),
-              url,
+              "%s://%s:%s@%s/%s?%s#%s",
               (i == 0)? &bigpart[1] : smallpart,
               (i == 1)? &bigpart[1] : smallpart,
               (i == 2)? &bigpart[1] : smallpart,
@@ -1675,9 +1670,6 @@ static int huge(void)
               (i == 4)? &bigpart[1] : smallpart,
               (i == 5)? &bigpart[1] : smallpart,
               (i == 6)? &bigpart[1] : smallpart);
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
     rc = curl_url_set(urlp, CURLUPART_URL, total, CURLU_NON_SUPPORT_SCHEME);
     if((!i && (rc != CURLUE_BAD_SCHEME)) ||
        (i && rc)) {