* libc/stdio/fileno.c (fileno): Check if f is a valid stream. If not,
return -1 and set errno to EBADF per POSIX.
This commit is contained in:
parent
c416f16d44
commit
821c8b9aac
|
@ -1,3 +1,11 @@
|
||||||
|
2012-07-09 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
|
* libc/stdio/fileno.c (fileno): Check if f is a valid stream. If not,
|
||||||
|
return -1 and set errno to EBADF per POSIX.
|
||||||
|
|
||||||
|
2012-07-06 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
|
|
||||||
2012-07-06 Corinna Vinschen <vinschen@redhat.com>
|
2012-07-06 Corinna Vinschen <vinschen@redhat.com>
|
||||||
|
|
||||||
Allow building of Cygwin using Mingw64 SDK headers:
|
Allow building of Cygwin using Mingw64 SDK headers:
|
||||||
|
|
|
@ -47,6 +47,7 @@ Supporting OS subroutines required: none.
|
||||||
|
|
||||||
#include <_ansi.h>
|
#include <_ansi.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -56,7 +57,13 @@ _DEFUN(fileno, (f),
|
||||||
int result;
|
int result;
|
||||||
CHECK_INIT (_REENT, f);
|
CHECK_INIT (_REENT, f);
|
||||||
_newlib_flockfile_start (f);
|
_newlib_flockfile_start (f);
|
||||||
result = __sfileno (f);
|
if (f->_flags)
|
||||||
|
result = __sfileno (f);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = -1;
|
||||||
|
_REENT->_errno = EBADF;
|
||||||
|
}
|
||||||
_newlib_flockfile_end (f);
|
_newlib_flockfile_end (f);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue