diff options
author | pfg <pfg@FreeBSD.org> | 2014-08-03 18:28:10 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-08-03 18:28:10 +0000 |
commit | 5c8726d1b258dd69e1f906f463c2bcc65c1b64a5 (patch) | |
tree | fffeed563f0bdf924883b06dc4de075adb02c829 /lib/libc/stdio/wbuf.c | |
parent | eabfc5bd75e50f98ad4963ab269825213771c398 (diff) | |
download | FreeBSD-src-5c8726d1b258dd69e1f906f463c2bcc65c1b64a5.zip FreeBSD-src-5c8726d1b258dd69e1f906f463c2bcc65c1b64a5.tar.gz |
MFC r268926, r268930, r268983:
Use a correct errno in freopen.
Use EBADF instead of EINVAL when working around incorrect O_ACCMODE.
Adjust errno on failed prepwrite.
rewind: always clear error indicator as required by POSIX.
Obtained from: Apple Inc. (Libc 997.90.3)
Phabric: D442
Diffstat (limited to 'lib/libc/stdio/wbuf.c')
-rw-r--r-- | lib/libc/stdio/wbuf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index 3f697e2..5bc3c4d 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdio.h> #include "local.h" @@ -59,8 +60,10 @@ __swbuf(int c, FILE *fp) * calls might wrap _w from negative to positive. */ fp->_w = fp->_lbfsize; - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } c = (unsigned char)c; ORIENT(fp, -1); |