mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-02-04 12:41:34 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user