mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:33:31 +03:00
build: enable -Wformat-signedness, fix issues found
Adjust code to avoid `-Wformat-signedness` warnings, while making sure
that enums are always cast to a known type when passing them to `printf`
functions, to support compilers and compiler settings where enums are
not default-size signed ints.
- cast integers printed as hex to `unsigned`. (63 times, 20 of them in
`mbedtls.c`)
- cast misc enums to `int` for printing. (31 times)
- cast `CURL_LOCK_DATA_*` enums to `int`. (4 times)
- cast `CURL_FORMADD_*` enums to `int`. (13 times)
- cast `CURLSHE_*` enums to `int`. (3 times)
- cast `CURLUE_*` enums to `int`. (33 times)
- cast `CURLMSG_*` enums to `int`. (6 times)
- cast `CURLE_*` enums to `int`. (~380 times)
- unit1675: fix mask.
Follow-up to 7c34365cce #21879
Ref: #18343 (initial attempt)
Closes #20848
This commit is contained in:
parent
ae2986cdf0
commit
2f3fa479dd
162 changed files with 565 additions and 509 deletions
|
|
@ -134,14 +134,14 @@ int main(void)
|
|||
const char *url;
|
||||
CURL *curl = msg->easy_handle;
|
||||
curl_easy_getinfo(curl, CURLINFO_PRIVATE, &url);
|
||||
fprintf(stderr, "R: %d - %s <%s>\n",
|
||||
msg->data.result, curl_easy_strerror(msg->data.result), url);
|
||||
fprintf(stderr, "R: %d - %s <%s>\n", (int)msg->data.result,
|
||||
curl_easy_strerror(msg->data.result), url);
|
||||
curl_multi_remove_handle(multi, curl);
|
||||
curl_easy_cleanup(curl);
|
||||
left--;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "E: CURLMsg (%d)\n", msg->msg);
|
||||
fprintf(stderr, "E: CURLMsg (%d)\n", (int)msg->msg);
|
||||
}
|
||||
if(transfers < NUM_URLS)
|
||||
add_transfer(multi, transfers++, &left);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ int main(void)
|
|||
close(sockfd);
|
||||
|
||||
if(result != CURLE_OK) {
|
||||
printf("libcurl error: %d\n", result);
|
||||
printf("libcurl error: %d\n", (int)result);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ int main(void)
|
|||
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
fprintf(stderr, "curl told us %d\n", (int)result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ int main(void)
|
|||
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
fprintf(stderr, "curl told us %d\n", (int)result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int main(void)
|
|||
}
|
||||
else {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
fprintf(stderr, "curl told us %d\n", (int)result);
|
||||
}
|
||||
|
||||
/* always cleanup */
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ int main(void)
|
|||
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
fprintf(stderr, "curl told us %d\n", (int)result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ int main(void)
|
|||
failed = 0;
|
||||
}
|
||||
else {
|
||||
mem_addf(&t->log, "Transfer failed: (%d) %s\n", result,
|
||||
mem_addf(&t->log, "Transfer failed: (%d) %s\n", (int)result,
|
||||
(errbuf[0] ? errbuf : curl_easy_strerror(result)));
|
||||
fprintf(stderr, "%s", t->log.recent);
|
||||
failed = 1;
|
||||
|
|
|
|||
|
|
@ -99,10 +99,12 @@ int main(void)
|
|||
|
||||
switch(idx) {
|
||||
case HTTP_HANDLE:
|
||||
printf("HTTP transfer completed with status %d\n", msg->data.result);
|
||||
printf("HTTP transfer completed with status %d\n",
|
||||
(int)msg->data.result);
|
||||
break;
|
||||
case FTP_HANDLE:
|
||||
printf("FTP transfer completed with status %d\n", msg->data.result);
|
||||
printf("FTP transfer completed with status %d\n",
|
||||
(int)msg->data.result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,10 +177,12 @@ int main(void)
|
|||
|
||||
switch(idx) {
|
||||
case HTTP_HANDLE:
|
||||
printf("HTTP transfer completed with status %d\n", msg->data.result);
|
||||
printf("HTTP transfer completed with status %d\n",
|
||||
(int)msg->data.result);
|
||||
break;
|
||||
case FTP_HANDLE:
|
||||
printf("FTP transfer completed with status %d\n", msg->data.result);
|
||||
printf("FTP transfer completed with status %d\n",
|
||||
(int)msg->data.result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ int main(void)
|
|||
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
fprintf(stderr, "curl told us %d\n", (int)result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ int main(int argc, const char **argv)
|
|||
|
||||
for(i = 0; list[i]; i++)
|
||||
printf("SSL backend #%d: '%s' (ID: %d)\n",
|
||||
i, list[i]->name, list[i]->id);
|
||||
i, list[i]->name, (int)list[i]->id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static size_t read_cb(char *buf, size_t nitems, size_t buflen, void *p)
|
|||
result = curl_ws_start_frame(ctx->curl, CURLWS_TEXT,
|
||||
(curl_off_t)ctx->blen);
|
||||
if(result != CURLE_OK) {
|
||||
fprintf(stderr, "error starting frame: %d\n", result);
|
||||
fprintf(stderr, "error starting frame: %d\n", (int)result);
|
||||
return CURL_READFUNC_ABORT;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ retry:
|
|||
else {
|
||||
/* some other frame arrived. */
|
||||
fprintf(stderr, "ws: received frame of %u bytes rflags %x\n",
|
||||
(unsigned int)rlen, meta->flags);
|
||||
(unsigned int)rlen, (unsigned int)meta->flags);
|
||||
goto retry;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue