This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Note in fmemopen() that no file descriptor is allocated


Alexander Lamaison <awl03@doc.ic.ac.uk> pointed out that this is
not obvious from the documentation, citing an example with passing
the FILE * handle to a function that tries to fstat() its fileno()
in order to determine the buffer size.

This also moves BUGS before EXAMPLE according to the recommended
section order.

Signed-off-by: Petr Baudis <pasky@suse.cz>

diff --git a/man3/fmemopen.3 b/man3/fmemopen.3
index 608e16f..3ed6930 100644
--- a/man3/fmemopen.3
+++ b/man3/fmemopen.3
@@ -173,6 +173,22 @@ POSIX.1-2008.
 These functions are not specified in POSIX.1-2001,
 and are not widely available on other systems.
 These functions are GNU extensions.
+.SH NOTES
+There is no valid file descriptor associated with
+the returned handle, therefore
+.BR fileno (3)
+will return a negative value.
+Thus, you e.g. cannot determine the buffer size using
+.I fstat(fileno(f), &stat)
+and looking at
+.IR stat.st_size .
+.SH BUGS
+In glibc before version 2.7, seeking past the end of a stream created by
+.BR open_memstream ()
+does not enlarge the buffer; instead the
+.BR fseek ()
+call fails, returning \-1.
+.\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996
 .SH "EXAMPLE"
 The program below uses
 .BR fmemopen ()
@@ -236,13 +252,6 @@ main(int argc, char *argv[])
     exit(EXIT_SUCCESS);
 }
 .fi
-.SH BUGS
-In glibc before version 2.7, seeking past the end of a stream created by
-.BR open_memstream ()
-does not enlarge the buffer; instead the
-.BR fseek ()
-call fails, returning \-1.
-.\" http://sourceware.org/bugzilla/show_bug.cgi?id=1996
 .SH "SEE ALSO"
 .BR fopen (3),
 .BR fopencookie (3),


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]