From ce7174555dec4d077e9e905a47bffcd703175553 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 7 Mar 2026 13:58:22 +0100 Subject: [PATCH] build: adjust/add casts to fix `-Wformat-signedness` Also adjust a mask in `mqttd.c`. Follow-up to 548c16a824017c49ee14dfb039ddc367fc37838d #21335 Cherry-picked from #20848 Closes #21339 --- lib/socks.c | 8 ++++---- tests/server/mqttd.c | 4 ++-- tests/server/sockfilt.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/socks.c b/lib/socks.c index f09c751fe5..57e5a50f7a 100644 --- a/lib/socks.c +++ b/lib/socks.c @@ -419,7 +419,7 @@ static CURLproxycode socks4_check_resp(struct socks_state *sx, "[SOCKS] cannot complete SOCKS4 connection to %u.%u.%u.%u:%u. (%u)" ", request rejected or failed.", resp[4], resp[5], resp[6], resp[7], - ((resp[2] << 8) | resp[3]), resp[1]); + (unsigned int)((resp[2] << 8) | resp[3]), resp[1]); return CURLPX_REQUEST_FAILED; case 92: failf(data, @@ -427,7 +427,7 @@ static CURLproxycode socks4_check_resp(struct socks_state *sx, ", request rejected because SOCKS server cannot connect to " "identd on the client.", resp[4], resp[5], resp[6], resp[7], - ((resp[2] << 8) | resp[3]), resp[1]); + (unsigned int)((resp[2] << 8) | resp[3]), resp[1]); return CURLPX_IDENTD; case 93: failf(data, @@ -435,14 +435,14 @@ static CURLproxycode socks4_check_resp(struct socks_state *sx, ", request rejected because the client program and identd " "report different user-ids.", resp[4], resp[5], resp[6], resp[7], - ((resp[2] << 8) | resp[3]), resp[1]); + (unsigned int)((resp[2] << 8) | resp[3]), resp[1]); return CURLPX_IDENTD_DIFFER; default: failf(data, "[SOCKS] cannot complete SOCKS4 connection to %u.%u.%u.%u:%u. (%u)" ", Unknown.", resp[4], resp[5], resp[6], resp[7], - ((resp[2] << 8) | resp[3]), resp[1]); + (unsigned int)((resp[2] << 8) | resp[3]), resp[1]); return CURLPX_UNKNOWN_FAIL; } } diff --git a/tests/server/mqttd.c b/tests/server/mqttd.c index 23eefa65aa..0a3a6ee024 100644 --- a/tests/server/mqttd.c +++ b/tests/server/mqttd.c @@ -521,8 +521,8 @@ static curl_socket_t mqttit(curl_socket_t fd) /* check the length of the payload */ if((ssize_t)payload_len != (rc - 12)) { - logmsg("Payload length mismatch, expected %zx got %zx", - rc - 12, payload_len); + logmsg("Payload length mismatch, expected %zd got %zd", + rc - 12, (ssize_t)payload_len); goto end; } /* check the length of the client ID */ diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 61d81aeff7..94d6324251 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -1066,7 +1066,7 @@ static bool juggle(curl_socket_t *sockfdp, snprintf((char *)buffer, sizeof(buffer), "%s/%hu\n", ipv_inuse, server_port); buffer_len = (ssize_t)strlen((const char *)buffer); - snprintf(data, sizeof(data), "PORT\n%04x\n", (int)buffer_len); + snprintf(data, sizeof(data), "PORT\n%04x\n", (unsigned int)buffer_len); if(!write_stdout(data, 10)) return FALSE; if(!write_stdout(buffer, buffer_len)) @@ -1143,7 +1143,7 @@ static bool juggle(curl_socket_t *sockfdp, nread_socket = sread(sockfd, buffer, sizeof(buffer)); if(nread_socket > 0) { - snprintf(data, sizeof(data), "DATA\n%04x\n", (int)nread_socket); + snprintf(data, sizeof(data), "DATA\n%04x\n", (unsigned int)nread_socket); if(!write_stdout(data, 10)) return FALSE; if(!write_stdout(buffer, nread_socket))