diff options
| author | David Schultz <das@FreeBSD.org> | 2004-06-08 05:44:52 +0000 |
|---|---|---|
| committer | David Schultz <das@FreeBSD.org> | 2004-06-08 05:44:52 +0000 |
| commit | 325d97d0d1b2826d9c0ddc5f4319dc5acf5178ff (patch) | |
| tree | 8d3a5c2c76db0241072041d4410c25b0d164ca4d /lib/libc | |
| parent | 591506d322c3dca6e60652111e46be977c039aa7 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdio/wsetup.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/stdio/wsetup.c b/lib/libc/stdio/wsetup.c index 4039a1164ef5..4c18dd48bb11 100644 --- a/lib/libc/stdio/wsetup.c +++ b/lib/libc/stdio/wsetup.c @@ -40,6 +40,7 @@ static char sccsid[] = "@(#)wsetup.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include "local.h" @@ -47,7 +48,7 @@ __FBSDID("$FreeBSD$"); /* * Various output routines call wsetup to be sure it is safe to write, * because either _flags does not include __SWR, or _buf is NULL. - * _wsetup returns 0 if OK to write, nonzero otherwise. + * _wsetup returns 0 if OK to write; otherwise, it returns EOF and sets errno. */ int __swsetup(fp) @@ -61,8 +62,10 @@ __swsetup(fp) * If we are not writing, we had better be reading and writing. */ if ((fp->_flags & __SWR) == 0) { - if ((fp->_flags & __SRW) == 0) + if ((fp->_flags & __SRW) == 0) { + errno = EBADF; return (EOF); + } if (fp->_flags & __SRD) { /* clobber any ungetc data */ if (HASUB(fp)) |
