public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin/main] stdio: drop unnecessary calls to ORIENT
Date: Mon, 20 Nov 2023 20:02:16 +0000 (GMT)	[thread overview]
Message-ID: <20231120200216.2366B3858C30@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=61e52c4d60c57f520cd19de310260395add5ce97

commit 61e52c4d60c57f520cd19de310260395add5ce97
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Mon Nov 20 20:49:53 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Mon Nov 20 20:59:47 2023 +0100

    stdio: drop unnecessary calls to ORIENT
    
    Now that the low-level functions set and test stream orientation,
    a few calls in API functions are redundant.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 newlib/libc/stdio/fputs.c    | 2 --
 newlib/libc/stdio/fputwc_u.c | 2 --
 newlib/libc/stdio/fputws.c   | 2 --
 newlib/libc/stdio/fwrite.c   | 2 --
 newlib/libc/stdio/getc.c     | 6 ------
 newlib/libc/stdio/putc.c     | 4 ----
 newlib/libc/stdio/puts.c     | 2 --
 7 files changed, 20 deletions(-)

diff --git a/newlib/libc/stdio/fputs.c b/newlib/libc/stdio/fputs.c
index a4f18df2af55..7437949433d4 100644
--- a/newlib/libc/stdio/fputs.c
+++ b/newlib/libc/stdio/fputs.c
@@ -115,8 +115,6 @@ _fputs_r (struct _reent * ptr,
   CHECK_INIT(ptr, fp);
 
   _newlib_flockfile_start (fp);
-  if (ORIENT (fp, -1) != -1)
-    goto error;
   /* Make sure we can write.  */
   if (cantwrite (ptr, fp))
     goto error;
diff --git a/newlib/libc/stdio/fputwc_u.c b/newlib/libc/stdio/fputwc_u.c
index a5cc9a5d5817..7e7403b998eb 100644
--- a/newlib/libc/stdio/fputwc_u.c
+++ b/newlib/libc/stdio/fputwc_u.c
@@ -34,8 +34,6 @@ _fputwc_unlocked_r (struct _reent *ptr,
 	wchar_t wc,
 	FILE *fp)
 {
-  if (ORIENT(fp, 1) != 1)
-    return WEOF;
   return __fputwc(ptr, wc, fp);
 }
 
diff --git a/newlib/libc/stdio/fputws.c b/newlib/libc/stdio/fputws.c
index d6963837b4c7..f9fe4a4b324f 100644
--- a/newlib/libc/stdio/fputws.c
+++ b/newlib/libc/stdio/fputws.c
@@ -130,8 +130,6 @@ error:
   return (-1);
 #else
   _newlib_flockfile_start (fp);
-  if (ORIENT (fp, 1) != 1)
-    goto error;
   if (cantwrite (ptr, fp) != 0)
     goto error;
 
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c
index 2d9749693b43..9241ea2cd997 100644
--- a/newlib/libc/stdio/fwrite.c
+++ b/newlib/libc/stdio/fwrite.c
@@ -152,8 +152,6 @@ _fwrite_r (struct _reent * ptr,
   CHECK_INIT (ptr, fp);
 
   _newlib_flockfile_start (fp);
-  if (ORIENT (fp, -1) != -1)
-    goto ret;
   /* Make sure we can write.  */
   if (cantwrite (ptr, fp))
     goto ret;
diff --git a/newlib/libc/stdio/getc.c b/newlib/libc/stdio/getc.c
index 12bffaf8f79a..c8781320e603 100644
--- a/newlib/libc/stdio/getc.c
+++ b/newlib/libc/stdio/getc.c
@@ -81,9 +81,6 @@ _getc_r (struct _reent *ptr,
 {
   int result;
   CHECK_INIT (ptr, fp);
-  if (ORIENT (fp, -1) != -1)
-    return EOF;
-
   _newlib_flockfile_start (fp);
   result = __sgetc_r (ptr, fp);
   _newlib_flockfile_end (fp);
@@ -99,9 +96,6 @@ getc (register FILE *fp)
   struct _reent *reent = _REENT;
 
   CHECK_INIT (reent, fp);
-  if (ORIENT (fp, -1) != -1)
-    return EOF;
-
   _newlib_flockfile_start (fp);
   result = __sgetc_r (reent, fp);
   _newlib_flockfile_end (fp);
diff --git a/newlib/libc/stdio/putc.c b/newlib/libc/stdio/putc.c
index 925341939f7d..6a410e216df0 100644
--- a/newlib/libc/stdio/putc.c
+++ b/newlib/libc/stdio/putc.c
@@ -84,8 +84,6 @@ _putc_r (struct _reent *ptr,
 {
   int result;
   CHECK_INIT (ptr, fp);
-  if (ORIENT (fp, -1) != -1)
-    return EOF;
   _newlib_flockfile_start (fp);
   result = __sputc_r (ptr, c, fp);
   _newlib_flockfile_end (fp);
@@ -102,8 +100,6 @@ putc (int c,
   struct _reent *reent = _REENT;
 
   CHECK_INIT (reent, fp);
-  if (ORIENT (fp, -1) != -1)
-    return EOF;
   _newlib_flockfile_start (fp);
   result = __sputc_r (reent, c, fp);
   _newlib_flockfile_end (fp);
diff --git a/newlib/libc/stdio/puts.c b/newlib/libc/stdio/puts.c
index 20d889b81eea..d24022b4b36a 100644
--- a/newlib/libc/stdio/puts.c
+++ b/newlib/libc/stdio/puts.c
@@ -102,8 +102,6 @@ _puts_r (struct _reent *ptr,
   fp = _stdout_r (ptr);
   CHECK_INIT (ptr, fp);
   _newlib_flockfile_start (fp);
-  if (ORIENT (fp, -1) != -1)
-    goto err;
   /* Make sure we can write.  */
   if (cantwrite (ptr, fp))
     goto err;

                 reply	other threads:[~2023-11-20 20:02 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=20231120200216.2366B3858C30@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@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).