Unchecked Return Value in stdio.c
Fri Jun 18 20:07:20 GMT 2021
I hope this email's formatting isn't an issue. I converted the
Scan output to plain text.
Looking through Coverity Scan's report, I see this:
85 if (fp->_flags & __SAPP)
CID 175328 (#1 of 1): Unchecked return value (CHECKED_RETURN)2.
check_return: Calling _lseek_r without checking return value (as is
done elsewhere 7 out of 8 times).
86 _lseek_r (ptr, fp->_file, (_off_t) 0, SEEK_END);
87 fp->_flags &= ~__SOFF; /* in case O_APPEND mode is set */
If the _lseek_r() fails, shouldn't this return an error? Looking at
where it appears to get called indirectly, it looks like it is acceptable
for this return -1.
If this can't fail or it isn't an issue if it fails, then this should
have (void) added along with a comment.
Looking at the POSIX standard, the lseek() should fail if the fildes
argument is associated with a pipe, FIFO, or socket. It may mean
an errno of ESPIPE is acceptable and the method should continue.
Suggestions on how to resolve this appreciated.
More information about the Newlib