Fix perror fileno namespace (bug 17633)
Commit Message
perror, an ISO C function, uses fileno, which is not an ISO C
function. This patch makes it use __fileno instead. (The nearby call
to fdopen is not a problem because that's #defined to _IO_new_fdopen.)
Tested for x86_64 (testsuite, and that installed stripped shared
libraries are unchanged by this patch).
2014-11-21 Joseph Myers <joseph@codesourcery.com>
[BZ #17633]
* stdio-common/perror.c (perror): Call __fileno instead of fileno.
* conform/Makefile (test-xfail-ISO/stdio.h/linknamespace): Remove
variable.
(test-xfail-ISO99/stdio.h/linknamespace): Likewise.
(test-xfail-ISO11/stdio.h/linknamespace): Likewise.
Comments
That change is fine, but I'd be more comfortable if we also changed that
fdopen reference rather than implicitly assuming we'll have the internal
macro forever. perror is already using _IO_* calls, so it can just use
the internal name directly.
Thanks,
Roland
On Fri, 21 Nov 2014, Roland McGrath wrote:
> That change is fine, but I'd be more comfortable if we also changed that
> fdopen reference rather than implicitly assuming we'll have the internal
> macro forever. perror is already using _IO_* calls, so it can just use
If the internal macro is removed (generally or for a particular
configuration), failures in the linknamespace tests will make it
immediately obvious that this fdopen call needs to change.
@@ -325,12 +325,9 @@ test-xfail-XOPEN2K/ndbm.h/linknamespace = yes
test-xfail-XOPEN2K8/ndbm.h/linknamespace = yes
# Unsorted expected failures.
-test-xfail-ISO/stdio.h/linknamespace = yes
test-xfail-ISO/time.h/linknamespace = yes
test-xfail-ISO99/ctype.h/linknamespace = yes
-test-xfail-ISO99/stdio.h/linknamespace = yes
test-xfail-ISO11/ctype.h/linknamespace = yes
-test-xfail-ISO11/stdio.h/linknamespace = yes
test-xfail-XPG3/ctype.h/linknamespace = yes
test-xfail-XPG3/fnmatch.h/linknamespace = yes
test-xfail-XPG3/glob.h/linknamespace = yes
@@ -56,7 +56,7 @@ perror (const char *s)
oriented yet? In this case we'll create a new stream which is
using the same underlying file descriptor. */
if (__builtin_expect (_IO_fwide (stderr, 0) != 0, 1)
- || (fd = fileno (stderr)) == -1
+ || (fd = __fileno (stderr)) == -1
|| (fd = __dup (fd)) == -1
|| (fp = fdopen (fd, "w+")) == NULL)
{