mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: stdio fixes & internals documentation
Date: Fri, 29 May 2015 00:32:38 -0400	[thread overview]
Message-ID: <20150529043238.GC17573@brightrain.aerifal.cx> (raw)
In-Reply-To: <20150529013937.GA32093@brightrain.aerifal.cx>

On Thu, May 28, 2015 at 09:39:37PM -0400, Rich Felker wrote:
> Once these fixes are taken care of I'd like to look at the EOF logic
> in f->read() and moving it out to the callers (only __uflow and fread)
> where we won't have to worry about bugs (which I think exist) in the
> FILE-type-specific read functions.

Actually there don't seem to be such bugs, so I'm not in a big hurry
to make changes here. I did notice one issue though with __toread and
__towrite: they set the error status for the FILE when an illegal
operation (per the fopen mode) is attempted, but they don't set errno.
glibc sets errno to EBADF in this case, which I'm not sure is a
permitted behavior. POSIX says:

[EBADF]
    [CX] [Option Start] The file descriptor underlying stream is not a
    valid file descriptor open for reading. [Option End]

So if the underlying fd allows reading but the fopen mode doesn't, I
think this would be reusing a specified errno value with a meaning
distinct from the specified meaning, and thus non-conforming. I don't
know what would be an appropriate errno value, though.

On the other hand, the general text for EBADF reads:

[EBADF]
    Bad file descriptor. A file descriptor argument is out of range,
    refers to no open file, or a read (write) request is made to a
    file that is only open for writing (reading).

which makes it sound more permissible here.

Rich


      parent reply	other threads:[~2015-05-29  4:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29  1:39 Rich Felker
2015-05-29  3:05 ` Rich Felker
2015-05-29  4:32 ` Rich Felker [this message]

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=20150529043238.GC17573@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).