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

@ -3183,7 +3183,7 @@ static CURLcode ssh_statemachine(struct Curl_easy *data,
result = CURLE_OK;
}
CURL_TRC_SSH(data, "[%s] statemachine() -> %d, block=%d",
Curl_ssh_statename(sshc->state), result, *block);
Curl_ssh_statename(sshc->state), (int)result, *block);
return result;
}
@ -3209,7 +3209,7 @@ static CURLcode ssh_pollset(struct Curl_easy *data,
if(waitfor & REQ_IO_SEND)
flags |= CURL_POLL_OUT;
DEBUGASSERT(flags);
CURL_TRC_SSH(data, "pollset, flags=%x", flags);
CURL_TRC_SSH(data, "pollset, flags=%x", (unsigned int)flags);
return Curl_pollset_change(data, ps, sock, flags, 0);
}
/* While we still have a session, we listen incoming data. */
@ -3844,7 +3844,7 @@ static CURLcode sftp_disconnect(struct Curl_easy *data,
CURL_TRC_SSH(data, "DISCONNECT starts now");
myssh_to(data, sshc, SSH_SFTP_SHUTDOWN);
result = ssh_block_statemach(data, sshc, sshp, TRUE);
CURL_TRC_SSH(data, "DISCONNECT is done -> %d", result);
CURL_TRC_SSH(data, "DISCONNECT is done -> %d", (int)result);
}
sshc_cleanup(sshc, data, TRUE);
}