public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Unchecked Return Value in stdio.c
@ 2021-06-18 20:07 Joel Sherrill
  0 siblings, 0 replies; only message in thread
From: Joel Sherrill @ 2021-06-18 20:07 UTC (permalink / raw)
  To: Newlib

Hi

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.

https://pubs.opengroup.org/onlinepubs/009696699/functions/lseek.html

Suggestions on how to resolve this appreciated.

Thanks.

--joel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-18 20:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-18 20:07 Unchecked Return Value in stdio.c Joel Sherrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).