From: Joel Sherrill <joel@rtems.org>
To: Newlib <newlib@sourceware.org>
Subject: Unchecked Return Value in stdio.c
Date: Fri, 18 Jun 2021 15:07:20 -0500 [thread overview]
Message-ID: <CAF9ehCVovUzphMSB9KRAnQFfbBH3tt9YNGO_ZiQY7xhjEM_TkA@mail.gmail.com> (raw)
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
reply other threads:[~2021-06-18 20:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAF9ehCVovUzphMSB9KRAnQFfbBH3tt9YNGO_ZiQY7xhjEM_TkA@mail.gmail.com \
--to=joel@rtems.org \
--cc=newlib@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).