From 3834430ea1b82240429e9b79927fddcf2535de9c Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 30 Jan 2026 09:19:17 -0600 Subject: [PATCH] cpukit/posix/src/mmap.c: 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/posix/src/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpukit/posix/src/mmap.c b/cpukit/posix/src/mmap.c index 8f4915b6a6..84cc2dddf8 100644 --- a/cpukit/posix/src/mmap.c +++ b/cpukit/posix/src/mmap.c @@ -180,13 +180,13 @@ void *mmap( if ( S_ISREG( sb.st_mode ) /* FIXME: Should this be using strict inequality (>) comparisons? It would * be valid to map a region exactly equal to the st_size, e.g. see below. */ - && (( off >= sb.st_size ) || (( off + len ) >= sb.st_size ))) { + && (( off >= sb.st_size ) || (( off + (off_t)len ) >= sb.st_size ))) { errno = EOVERFLOW; return MAP_FAILED; } /* Check to see if the mapping is valid for other file/object types. */ - if ( !S_ISCHR( sb.st_mode ) && sb.st_size < off + len ) { + if ( !S_ISCHR( sb.st_mode ) && sb.st_size < off + (off_t)len ) { errno = ENXIO; return MAP_FAILED; }