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>
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).
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).
.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).