From 31e8f1b7829947e9f335a19ae42177a7e6c10e88 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Thu, 14 Mar 2019 14:25:18 -0500 Subject: shmopen.c: Fix logically unreachable code (Coverity ID: 1399706, 1399714) Closes #3694. --- cpukit/posix/src/shmopen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cpukit/posix/src/shmopen.c b/cpukit/posix/src/shmopen.c index ca8da00140..22b5868bda 100644 --- a/cpukit/posix/src/shmopen.c +++ b/cpukit/posix/src/shmopen.c @@ -195,7 +195,8 @@ static inline POSIX_Shm_Control *shm_allocate( static inline bool shm_access_ok( POSIX_Shm_Control *shm, int oflag ) { int flags; - if ( oflag & O_RDONLY ) { + + if ( (oflag & O_ACCMODE) == O_RDONLY ) { flags = RTEMS_FS_PERMS_READ; } else { flags = RTEMS_FS_PERMS_WRITE; @@ -286,7 +287,7 @@ int shm_open( const char *name, int oflag, mode_t mode ) rtems_filesystem_location_add_to_mt_entry( &iop->pathinfo ); flags = LIBIO_FLAGS_CLOSE_ON_EXEC; - if ( oflag & O_RDONLY ) { + if ( (oflag & O_ACCMODE) == O_RDONLY ) { flags |= LIBIO_FLAGS_READ; } else { flags |= LIBIO_FLAGS_READ_WRITE; -- cgit v1.2.3