Subject: standards/32981: man page is wrong on return values of printf/fprintf/sprintf/etc.
To: None <standards-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Johan Veenhuizen <veenhuizen@users.sourceforge.net>
List: netbsd-bugs
Date: 03/03/2006 22:05:00
>Number:         32981
>Category:       standards
>Synopsis:       correct return values of fprintf/sprintf functions
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 03 22:05:00 +0000 2006
>Originator:     Johan Veenhuizen
>Release:        NetBSD 3.0
>Organization:
	
>Environment:
	
	
System: NetBSD carola.zapto.org 3.0 NetBSD 3.0 (CAROLA) #1: Tue Feb 28 12:46:17 CET 2006 jpv@carola.zapto.org:/usr/src/sys/arch/i386/compile/CAROLA i386
Architecture: i386
Machine: i386
>Description:

	I have no copies of the C90/C99 standards in front of me,
	but "The C Programming Language, 2nd Ed.", POSIX and SUS
	document different return values for fprintf/sprintf/etc
	than the NetBSD manual page.

	I have no clue about asprintf and vasprintf.  Maybe their
	return values should be changed as well, but they are not
	standardised yet as far as I know.

>How-To-Repeat:

	$ man 3 printf

>Fix:

Index: printf.3
===================================================================
RCS file: /cvsroot/src/lib/libc/stdio/printf.3,v
retrieving revision 1.40
diff -u -r1.40 printf.3
--- printf.3	20 Jul 2005 13:31:15 -0000	1.40
+++ printf.3	3 Mar 2006 21:38:40 -0000
@@ -667,7 +667,7 @@
 and
 .Fn vfprintf
 return the number of characters printed.
-Otherwise \-1 is returned and
+Otherwise a negative value is returned and
 .Dv errno
 is set to indicate the error.
 .Pp
@@ -680,7 +680,7 @@
 excluding the terminating
 .Dv NUL
 character.
-Otherwise \-1 is returned and
+Otherwise a negative value is returned and
 .Dv errno
 is set to indicate the error.
 .Pp
@@ -694,6 +694,9 @@
 excluding the terminating
 .Dv NUL
 character.
+Otherwise a negative value is returned and
+.Dv errno
+is set to indicate the error.
 .Pp
 Upon successful completion
 .Fn asprintf

>Unformatted: