From 785130d379de98e4b594d0d1de720c2645eef57d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 28 Jan 2026 10:42:55 -0600 Subject: [PATCH] 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. --- cpukit/libfs/src/ftpfs/tftpDriver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpukit/libfs/src/ftpfs/tftpDriver.c b/cpukit/libfs/src/ftpfs/tftpDriver.c index 97f3b97781..1a8d06b7a3 100644 --- a/cpukit/libfs/src/ftpfs/tftpDriver.c +++ b/cpukit/libfs/src/ftpfs/tftpDriver.c @@ -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);