cpukit/libfs/tftpfs: Address -Wsign-compare warnings

This warning occurs when comparing a signed variable to an unsigned one.
This is frequently an int or ssize_t variable compared to a uint32_t or
size_t. Sometimes the size_t is from a sizeof() use.

This addresses sign comparison warnings in the tftp file system.
This commit is contained in:
Joel Sherrill
2026-01-28 10:42:55 -06:00
committed by Gedare Bloom
parent 63d3c17d8f
commit 785130d379

View File

@@ -258,7 +258,7 @@ struct tftpStream {
* (blocknum_last_filled + 1).
*/
int nleft;
int nused;
size_t nused;
/*
* Flags
@@ -518,7 +518,7 @@ static void send_error (
msg.opcode = htons (TFTP_OPCODE_ERROR);
msg.errorCode = htons (error_code);
len = snprintf (msg.errorMessage, sizeof (msg.errorMessage), error_message);
if (len >= sizeof (msg.errorMessage)) {
if ((size_t) len >= sizeof (msg.errorMessage)) {
len = sizeof (msg.errorMessage) - 1;
}
len += sizeof (msg.opcode) + sizeof (msg.errorCode) + 1;
@@ -688,7 +688,7 @@ static int process_data_packet (struct tftpStream *tp, ssize_t len)
int32_t pkt_blocknum;
union tftpPacket *send_buf;
if (len < sizeof (tp->receive_buf->tftpACK)) {
if ((size_t) len < sizeof (tp->receive_buf->tftpACK)) {
return process_malformed_packet (tp, len);
}
pkt_blocknum = (int32_t) ntohs (tp->receive_buf->tftpACK.blocknum);
@@ -757,7 +757,7 @@ static int process_data_packet (struct tftpStream *tp, ssize_t len)
static int process_ack_packet (struct tftpStream *tp, ssize_t len)
{
uint16_t blocknum_ack;
if (len < sizeof (tp->receive_buf->tftpACK)) {
if ((size_t) len < sizeof (tp->receive_buf->tftpACK)) {
return process_malformed_packet (tp, len);
}
blocknum_ack = ntohs (tp->receive_buf->tftpACK.blocknum);