From: Takashi Yano <takashi.yano@nifty.ne.jp>
To: newlib@sourceware.org
Subject: Re: [PATCH] newlib: libc: Fix bugs in the commit 3d94e07c49b5.
Date: Sat, 11 Nov 2023 01:05:18 +0900 [thread overview]
Message-ID: <20231111010518.ff29a1b7856da2905e94fb4c@nifty.ne.jp> (raw)
In-Reply-To: <ZU5Jmdcz0YQ2L4Je@calimero.vinschen.de>
On Fri, 10 Nov 2023 16:17:45 +0100
Corinna Vinschen wrote:
> On Nov 10 20:34, Takashi Yano wrote:
> > The commit 3d94e07c49b5 has a few bugs which cause testsuite failure
> > in libstdc++. This is due to excess orientation check in __srefill_r()
> > and _ungetc_r(). This patch fixes them.
>
> Oops, _ungetc_r is used from ungetwc as well, that's not good.
> Sorry that I missed that yesterday!
>
> > Fixes: 3d94e07c49b5 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.")
> > Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
> > Reviewed-by:
> > Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> > ---
> > newlib/libc/stdio/refill.c | 3 ---
> > newlib/libc/stdio/ungetc.c | 8 ++------
> > 2 files changed, 2 insertions(+), 9 deletions(-)
> >
> > diff --git a/newlib/libc/stdio/refill.c b/newlib/libc/stdio/refill.c
> > index c1ef7e120..cd71ed152 100644
> > --- a/newlib/libc/stdio/refill.c
> > +++ b/newlib/libc/stdio/refill.c
> > @@ -43,9 +43,6 @@ __srefill_r (struct _reent * ptr,
> >
> > CHECK_INIT (ptr, fp);
> >
> > - if (ORIENT (fp, -1) != -1)
> > - return EOF;
> > -
> > fp->_r = 0; /* largely a convenience for callers */
> >
> > /* SysV does not make this test; take it out for compatibility */
> > diff --git a/newlib/libc/stdio/ungetc.c b/newlib/libc/stdio/ungetc.c
> > index 79914af08..5053fd6c4 100644
> > --- a/newlib/libc/stdio/ungetc.c
> > +++ b/newlib/libc/stdio/ungetc.c
> > @@ -125,12 +125,6 @@ _ungetc_r (struct _reent *rptr,
> >
> > _newlib_flockfile_start (fp);
> >
> > - if (ORIENT (fp, -1) != -1)
> > - {
> > - _newlib_flockfile_exit (fp);
> > - return EOF;
> > - }
> > -
> > /* After ungetc, we won't be at eof anymore */
> > fp->_flags &= ~__SEOF;
> >
> > @@ -213,6 +207,8 @@ int
> > ungetc (int c,
> > register FILE *fp)
> > {
> > + if (ORIENT (fp, -1) != -1)
> > + return EOF;
> > return _ungetc_r (_REENT, c, fp);
> > }
> > #endif /* !_REENT_ONLY */
> > --
> > 2.39.0
>
> Didn't you forget ungetwc?
Indeed. Thanks! I'll submit v2 patch.
> But then again, I checked GLibC, and there's something weird:
> ungetc does not at all set or test the orientation.
> ungetwc sets the orientation to 1, but doesn't check it.
> Puzzeling. I wonder about the reasoning behind this.
Hmm, I'll also check that behaviour.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
next prev parent reply other threads:[~2023-11-10 16:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-10 11:34 Takashi Yano
2023-11-10 15:17 ` Corinna Vinschen
2023-11-10 16:05 ` Takashi Yano [this message]
2023-11-10 16:08 ` Corinna Vinschen
2023-11-10 16:33 ` Takashi Yano
2023-11-13 13:05 ` Corinna Vinschen
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=20231111010518.ff29a1b7856da2905e94fb4c@nifty.ne.jp \
--to=takashi.yano@nifty.ne.jp \
--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).