build: adjust/add casts to fix -Wformat-signedness

Also adjust a mask in `mqttd.c`.

Follow-up to 548c16a824 #21335
Cherry-picked from #20848

Closes #21339
This commit is contained in:
Viktor Szakats 2026-03-07 13:58:22 +01:00
parent 7e450cb80a
commit ce7174555d
No known key found for this signature in database
3 changed files with 8 additions and 8 deletions

View file

@ -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;
}
}

View file

@ -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 */

View file

@ -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))