]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
man/man3/*printf.3: Document ERRORS
authorTobias Stoeckmann <tobias@stoeckmann.org>
Sun, 18 May 2025 13:41:59 +0000 (15:41 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 21 May 2025 00:02:07 +0000 (02:02 +0200)
The printf family of functions set errno if a negative value is returned.

Source is POSIX.1, see
<https://pubs.opengroup.org/onlinepubs/9799919799/functions/fprintf.html>
<https://pubs.opengroup.org/onlinepubs/9799919799/functions/fwprintf.html>

Also see manual pages of FreeBSD and OpenBSD.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Message-ID: <34octlcodbwm3kfqlouvrvhriiftmlzzobbohgzivlkgi53nfs@7gxajeb56klz>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man3/asprintf.3
man/man3/printf.3
man/man3/wprintf.3

index 21c55bc0d664fb57eedcc073549adb657dda3534..68c372ed8d68266bf42ffcb9af5a0d2fe2d1fcb8 100644 (file)
@@ -37,10 +37,18 @@ to release the allocated storage when it is no longer needed.
 When successful, these functions return the number of bytes printed,
 just like
 .BR sprintf (3).
-If memory allocation wasn't possible, or some other error occurs,
-these functions will return \-1, and the contents of
+On error,
+\-1 is returned,
+.I errno
+is set to indicate the error,
+and the contents of
 .I strp
 are undefined.
+.SH ERRORS
+See
+.BR sprintf (3)
+and
+.BR malloc (3).
 .SH ATTRIBUTES
 For an explanation of the terms used in this section, see
 .BR attributes (7).
index 6b33584e2e6431d386985a37ca9d8ea410cfebc7..759539381e3b39408f716dbea6d4e7490a1b819f 100644 (file)
@@ -904,7 +904,30 @@ Thus, a return value of
 or more means that the output was truncated.
 (See also below under CAVEATS.)
 .P
-If an output error is encountered, a negative value is returned.
+On error,
+a negative value is returned,
+and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+See
+.BR write (2)
+and
+.BR putwc (3).
+In addition, the following error may occur:
+.TP
+.B EOVERFLOW
+The value to be returned is greater than
+.BR INT_MAX .
+.P
+The
+.BR dprintf ()
+function may fail additionally if:
+.TP
+.B EBADF
+The
+.I fd
+argument is not a valid file descriptor.
 .SH ATTRIBUTES
 For an explanation of the terms used in this section, see
 .BR attributes (7).
index 46163464a9d4e5c96db8b1e463a3d30afaa1cae9..a7324426b90940ec159f3f4ba8d13d3d01016405 100644 (file)
@@ -198,7 +198,30 @@ case of the functions
 .BR swprintf ()
 and
 .BR vswprintf ().
-They return \-1 when an error occurs.
+On error,
+\-1 is returned,
+and
+.I errno
+is set to indicate the error.
+.SH ERRORS
+See
+.BR write (2)
+and
+.BR putwc (3).
+In addition, the following error may occur:
+.TP
+.B EOVERFLOW
+The value to be returned is greater than
+.BR INT_MAX .
+.P
+The
+.BR fwprintf ()
+and
+.BR wprintf ()
+functions may fail additionally if:
+.TP
+.B ENOMEM
+Insufficient storage space is available.
 .SH ATTRIBUTES
 For an explanation of the terms used in this section, see
 .BR attributes (7).