From feac23ce18b9c42d0cd09a4c3f961bb1992f7b2e Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 30 Jan 2026 09:17:33 -0600 Subject: [PATCH] cpukit/.../imfs: Address -Wsign-compare warnings This warning occurs when comparing a signed variable to an unsigned one. This addresses warnings that only occurred on 64-bit targets. For the ones which only appeared on 64-bit targets, the cause was frequently a mismatch when comparing a combination off_t, ssize_t, and int. --- cpukit/include/rtems/imfs.h | 2 +- cpukit/libfs/src/imfs/imfs_memfile.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h index 8d418aa19a..31399d7678 100644 --- a/cpukit/include/rtems/imfs.h +++ b/cpukit/include/rtems/imfs.h @@ -114,7 +114,7 @@ typedef block_p *block_ptr; IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS)) #define IMFS_MEMFILE_MAXIMUM_SIZE \ - ((LAST_TRIPLY_INDIRECT + 1) * IMFS_MEMFILE_BYTES_PER_BLOCK) + (size_t)((LAST_TRIPLY_INDIRECT + 1) * IMFS_MEMFILE_BYTES_PER_BLOCK) /** @} */ diff --git a/cpukit/libfs/src/imfs/imfs_memfile.c b/cpukit/libfs/src/imfs/imfs_memfile.c index 187ebf479a..82d81ca81a 100644 --- a/cpukit/libfs/src/imfs/imfs_memfile.c +++ b/cpukit/libfs/src/imfs/imfs_memfile.c @@ -138,7 +138,7 @@ static int memfile_ftruncate( * as an extend operation. */ - if ( length > memfile->File.size ) + if ( length > (int64_t)memfile->File.size ) return IMFS_memfile_extend( memfile, true, length ); /* @@ -179,13 +179,13 @@ static int IMFS_memfile_extend( /* * Verify new file size is supported */ - if ( new_length >= IMFS_MEMFILE_MAXIMUM_SIZE ) + if ( new_length >= (int64_t)IMFS_MEMFILE_MAXIMUM_SIZE ) rtems_set_errno_and_return_minus_one( EFBIG ); /* * Verify new file size is actually larger than current size */ - if ( new_length <= memfile->File.size ) + if ( new_length <= (int64_t)memfile->File.size ) return 0; /* @@ -560,7 +560,7 @@ ssize_t IMFS_memfile_write( last_byte = start + my_length; if ( last_byte > memfile->File.size ) { - bool zero_fill = start > memfile->File.size; + bool zero_fill = start > (int64_t)memfile->File.size; status = IMFS_memfile_extend( memfile, zero_fill, last_byte ); if ( status )