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.
This commit is contained in:
Joel Sherrill
2026-01-30 09:19:17 -06:00
parent 80365c94a7
commit 3834430ea1

View File

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