#3694 closed defect (fixed)

shm_open has logically unreachable code (Coverity ID: 1399706, 1399714)

Reported by: Joel Sherrill Owned by: Gedare Bloom
Priority: normal Milestone: 5.1
Component: fs Version: 5
Severity: normal Keywords: coverity
Cc: Blocked By:
Blocking:

Description (last modified by Joel Sherrill)

Coverity ID: 1399706 and 1399714
File: shmopen.c
Method: shm_open for first

   	dead_error_condition: The condition oflag & 0 cannot be true.
289  if ( oflag & O_RDONLY ) {
   	
CID 1399706 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: flags |= 2U;.
290    flags |= LIBIO_FLAGS_READ;
291  } else {

URL: https://scan5.coverity.com/reports.htm#v29811/p10069/fileInstanceId=153084281&defectInstanceId=42558012&mergedDefectId=1399706&fileStart=1&fileEnd=250

Same issue at other place in same file:

197  int flags;
   	dead_error_condition: The condition oflag & 0 cannot be true.
198  if ( oflag & O_RDONLY ) {
   	
CID 1399714 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: flags = 4;.
199    flags = RTEMS_FS_PERMS_READ;
200  } else {

Change History (3)

comment:1 Changed on Feb 19, 2019 at 6:12:13 PM by Joel Sherrill

Description: modified (diff)
Summary: shm_open has logically unreachable code (Coverity ID: 1399706)shm_open has logically unreachable code (Coverity ID: 1399706, 1399714)

comment:2 Changed on Mar 14, 2019 at 4:08:10 PM by Gedare Bloom

the fix is something along the lines of

(oflag & O_ACCMODE) == O_RDONLY

to check for read-only

comment:3 Changed on Mar 14, 2019 at 7:26:24 PM by Joel Sherrill <joel@…>

Resolution: fixed
Status: assignedclosed

In 31e8f1b/rtems:

shmopen.c: Fix logically unreachable code (Coverity ID: 1399706, 1399714)

Closes #3694.

Note: See TracTickets for help on using tickets.