about summary refs log tree commit diff
path: root/libio/oldfileops.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-02-18 11:49:54 +0100
committerFlorian Weimer <fweimer@redhat.com>2019-02-18 16:37:00 +0100
commita5406364ac949f91867352cb2ae867629f083c5b (patch)
tree0aeeedc3748d3b21cf8e8ea2e670670df1e441db /libio/oldfileops.c
parent6c29942cbf059aca47fd4bbd852ea42c9d46b71f (diff)
downloadglibc-a5406364ac949f91867352cb2ae867629f083c5b.tar.gz
glibc-a5406364ac949f91867352cb2ae867629f083c5b.tar.xz
glibc-a5406364ac949f91867352cb2ae867629f083c5b.zip
libio: Eliminate _IO_stdin, _IO_stdout, _IO_stderr
These variables are only used to determine if a stdio stream is
a pre-allocated stream, but it is possible to do so by comparing
a FILE * to all pre-allocated stream objects.  As a result, it is
not necessary to keep those pointers in separate variables.

Behavior with symbol interposition is unchanged because _IO_stdin_,
_IO_stdout_, _IO_stderr_ are exported, and refer to objects outside of
libc if symbol interposition or copy relocations are involved.  (The
removed variables _IO_stdin, _IO_stdout, _IO_stderr were not exported,
of course.)
Diffstat (limited to 'libio/oldfileops.c')
-rw-r--r--libio/oldfileops.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index 4d6c5e3fe7..5c319beacd 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -109,10 +109,7 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp)
 			     - (int) sizeof (struct _IO_FILE_complete));
   fp->file._fileno = -1;
 
-  if (__builtin_expect (&_IO_stdin_used != NULL, 1)
-      || (fp != (struct _IO_FILE_plus *) _IO_stdin
-	  && fp != (struct _IO_FILE_plus *) _IO_stdout
-	  && fp != (struct _IO_FILE_plus *) _IO_stderr))
+  if (&_IO_stdin_used != NULL || !_IO_legacy_file ((FILE *) fp))
     /* The object is dynamically allocated and large enough.  Initialize
        the _mode element as well.  */
     ((struct _IO_FILE_complete *) fp)->_mode = -1;