RTEMS | aio_fsync.c: Coverity reports dead code (#5100)
Joel Sherrill (@joel)
gitlab at rtems.org
Mon Aug 5 13:56:27 UTC 2024
Joel Sherrill created an issue: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5100
Assignee: Joel Sherrill
## Summary
Coverity CID 1616108
This one is not immediately obvious. The problem stems from O_SYNC and O_DSYNC having the same value. The solution is to:
1. add preprocessor checks that they are the same,
2. add comments that if the cpp test ever fails, the code needs updating
3. consolidate references to the first test so there is only once place to update in the future.
```
59
cond_const: Condition op != 8192, taking false branch. Now the value of op is equal to 8192.
60 if ( op != O_SYNC && op != O_DSYNC )
61 rtems_set_errno_and_return_minus_one( EINVAL );
62
63 if ( rtems_aio_check_sigevent( &aiocbp->aio_sigevent ) == 0 )
64 rtems_set_errno_and_return_minus_one( EINVAL );
65
66 mode = fcntl( aiocbp->aio_fildes, F_GETFL );
67 if (
68 !(
69 ((mode & O_ACCMODE) == O_WRONLY) ||
70 ((mode & O_ACCMODE) == O_RDWR)
71 )
72 )
73 rtems_set_errno_and_return_minus_one( EBADF );
74
75 req = malloc( sizeof( rtems_aio_request ) );
76 if ( req == NULL )
77 rtems_set_errno_and_return_minus_one( EAGAIN );
78
79 req->aiocbp = aiocbp;
const: At condition op == 8192, the value of op must be equal to 8192.
dead_error_condition: The condition op == 8192 must be true.
80 if ( op == O_SYNC ) {
81 req->op_type = AIO_OP_SYNC;
82 } else {
CID 1616018: (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement: req->op_type = 3;.
83 req->op_type = AIO_OP_DSYNC;
84 }
```
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5100
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20240805/c2a58969/attachment.htm>
More information about the bugs
mailing list