public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: newlib@sourceware.org
Subject: Re: fprintf() crashes on wide-oriented stream.
Date: Tue, 7 Nov 2023 20:12:05 +0100	[thread overview]
Message-ID: <ZUqMBRWis8Lsh10S@calimero.vinschen.de> (raw)
In-Reply-To: <929083ca-9985-4bcd-90a8-30be950d5da8@Shaw.ca>

On Nov  7 09:50, Brian Inglis wrote:
> On 2023-11-07 06:24, Corinna Vinschen wrote:
> > It took me a while, but I think the BSD behaviour is only accepted
> > (acceptable) due its long history.  The only really correct way of
> > handling this issue is to do soemthing along the lines of GLibC.
> > 
> > I. e., while "cannot be applied" is sufficently vague, it should be
> > interpreted as "must not be applied", basically.  However, "must not"
> > kind of implies setting errno, but there's not a trace of that in
> > the standard.
> > 
> > Consequentially, IMHO, the way GLibC handles it sounds like the best way
> > out: The call is a no-op and returns a value indicating that the stream
> > isn't available for the given operation (EOF/WEOF/younameit), but it
> > does not change errno.  There's no errno value defined for this kind
> > of problem anyway.
> 
> POSIX disagrees with glibc and states that errno should be set (to EALREADY,
> EBADF, EBADFD, EIO, ENOTSUP, EPERM, or add EORIENT or EWIDTH?) and callers
> need to do "the errno shuffle":
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fwide.html
> 
> "[CX] [Option Start] The fwide() function shall not change the setting of
> errno if successful.
> 
> Since no return value is reserved to indicate an error, an application
> wishing to check for error situations should set errno to 0, then call
> fwide(), then check errno, and if it is non-zero, assume an error has
> occurred. [Option End]"

You're totally missing the point.  The POSIX text is about an error
occuring in fwide(3), and the only possible error in fwide(3) is an
invalid file pointer.  Given that fwide(3) doesn't define a return
value indicating an error, the above errno checking is required in
the application.

However, Takashi's input and code as well as my reply are talking about
all the other stdio functions depending on the orientation value.  The
stdio function behaviour in terms of orientation has nothing to do with
the POSIX description of fwide(3) you're quoting.


Corinna


  reply	other threads:[~2023-11-07 19:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  3:41 Takashi Yano
2023-09-26  8:30 ` Takashi Yano
2023-10-03  8:30   ` Takashi Yano
2023-10-03 17:31     ` Jeff Johnston
2023-10-03 20:12       ` Takashi Yano
2023-10-03 18:07     ` Brian Inglis
2023-09-28  3:58 ` Takashi Yano
2023-09-28  8:42   ` Takashi Yano
2023-09-28 20:06     ` Brian Inglis
2023-10-04 20:16   ` Jeff Johnston
2023-10-05 10:18     ` Takashi Yano
2023-10-05 15:18       ` Takashi Yano
2023-10-05 18:20         ` Torbjorn SVENSSON
2023-11-07 13:24         ` Corinna Vinschen
2023-11-07 16:50           ` Brian Inglis
2023-11-07 19:12             ` Corinna Vinschen [this message]
2023-11-08 12:05           ` Takashi Yano
2023-11-02 18:53     ` Corinna Vinschen
2023-11-06 18:26       ` Brian Inglis

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=ZUqMBRWis8Lsh10S@calimero.vinschen.de \
    --to=vinschen@redhat.com \
    --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).