[rtems commit] shmopen.c: Fix logically unreachable code (Coverity ID: 1399706, 1399714)
Joel Sherrill
joel at rtems.org
Thu Mar 14 19:26:12 UTC 2019
Module: rtems
Branch: master
Commit: 31e8f1b7829947e9f335a19ae42177a7e6c10e88
Changeset: http://git.rtems.org/rtems/commit/?id=31e8f1b7829947e9f335a19ae42177a7e6c10e88
Author: Joel Sherrill <joel at rtems.org>
Date: Thu Mar 14 14:25:18 2019 -0500
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 ca8da00..22b5868 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;
More information about the vc
mailing list