From 06ec3a6071d5b5ba6535c01729ca27e026d1b863 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 25 Nov 2014 19:08:15 +0000 Subject: C99 says setvbuf() returns non-zero, not EOF. Also, POSIX documents that it returns an error for invalid mode which matches our behavior. OK jmc@ deraadt@ --- lib/libc/stdio/setbuf.3 | 25 ++++++++++++++++++++----- lib/libc/stdio/setvbuf.3 | 22 +++++++++++++++++----- 2 files changed, 37 insertions(+), 10 deletions(-) (limited to 'lib/libc/stdio') diff --git a/lib/libc/stdio/setbuf.3 b/lib/libc/stdio/setbuf.3 index 1a6873c8a7c..8dd17acaa65 100644 --- a/lib/libc/stdio/setbuf.3 +++ b/lib/libc/stdio/setbuf.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: setbuf.3,v 1.15 2014/11/25 17:01:49 millert Exp $ +.\" $OpenBSD: setbuf.3,v 1.16 2014/11/25 19:08:14 millert Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -82,12 +82,27 @@ function is exactly equivalent to the call: .Pp .Dl "setvbuf(stream, NULL, _IOLBF, 0);" .Sh RETURN VALUES +Upon successful completion, the +.Fn setlinebuf +function returns 0. +If the request cannot be honored, a non-zero value is returned, +possibly setting +.Va errno +to indicate the error. +The stream is not modified in the error case. +.Sh ERRORS The +.Fn setbuf , +.Fn setbuffer , +and .Fn setlinebuf -function returns 0 on success, or -.Dv EOF -if the request cannot be honored -(note that the stream is still functional in this case). +functions will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa stream +specified is not associated with a valid file descriptor. +.El .Sh SEE ALSO .Xr fclose 3 , .Xr fopen 3 , diff --git a/lib/libc/stdio/setvbuf.3 b/lib/libc/stdio/setvbuf.3 index ae3abb7c1ef..edee931eb80 100644 --- a/lib/libc/stdio/setvbuf.3 +++ b/lib/libc/stdio/setvbuf.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: setvbuf.3,v 1.1 2014/11/25 17:01:49 millert Exp $ +.\" $OpenBSD: setvbuf.3,v 1.2 2014/11/25 19:08:14 millert Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -125,12 +125,24 @@ and before any .Tn I/O is performed. .Sh RETURN VALUES +Upon successful completion, a value of 0 is returned. +If +.Fa mode +is invalid or if the request cannot be honored, a non-zero value is returned, +possibly setting +.Va errno +to indicate the error. +The stream is not modified in the error case. +.Sh ERRORS The .Fn setvbuf -function returns 0 on success, or -.Dv EOF -if the request cannot be honored -(note that the stream is still functional in this case). +function will fail if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa stream +specified is not associated with a valid file descriptor. +.El .Sh SEE ALSO .Xr fclose 3 , .Xr fopen 3 , -- cgit v1.2.3