Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: delete/replace clang warning pragmas #12812

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 0 additions & 21 deletions lib/curl_trc.c
Expand Up @@ -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);
Expand All @@ -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';
Expand All @@ -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';
Expand Down
7 changes: 0 additions & 7 deletions lib/dict.c
Expand Up @@ -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 */
Expand Down
7 changes: 0 additions & 7 deletions lib/dynbuf.c
Expand Up @@ -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));
Expand Down
7 changes: 0 additions & 7 deletions lib/memdebug.c
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions lib/mime.c
Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions src/tool_easysrc.c
Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions src/tool_msgs.c
Expand Up @@ -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);
Expand Down
19 changes: 4 additions & 15 deletions src/tool_setopt.c
Expand Up @@ -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
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions tests/libtest/lib1560.c
Expand Up @@ -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();
Expand All @@ -1662,22 +1661,15 @@ 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,
(i == 3)? &bigpart[1] : smallpart,
(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)) {
Expand Down