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:
Viktor Szakats 2026-04-16 10:52:57 +02:00
parent ae2986cdf0
commit 2f3fa479dd
No known key found for this signature in database
162 changed files with 565 additions and 509 deletions

View file

@ -154,7 +154,8 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data,
if(ch->hexindex == 0) {
/* This is illegal data, we received junk where we expected
a hexadecimal digit. */
failf(data, "chunk hex-length char not a hex digit: 0x%x", *buf);
failf(data, "chunk hex-length char not a hex digit: 0x%x",
(unsigned int)*buf);
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_ILLEGAL_HEX;
return CURLE_RECV_ERROR;
@ -547,7 +548,7 @@ static CURLcode add_last_chunk(struct Curl_easy *data,
out:
curl_slist_free_all(trailers);
CURL_TRC_READ(data, "http_chunk, added last chunk with trailers "
"from client -> %d", result);
"from client -> %d", (int)result);
return result;
}
@ -595,7 +596,7 @@ static CURLcode add_chunk(struct Curl_easy *data,
if(!result)
result = Curl_bufq_cwrite(&ctx->chunkbuf, "\r\n", 2, &n);
CURL_TRC_READ(data, "http_chunk, made chunk of %zu bytes -> %d",
nread, result);
nread, (int)result);
if(result)
return result;
}