Document dprintf, vdprintf in the manual (RHEL-46723)

Resolves: RHEL-46723
This commit is contained in:
Florian Weimer 2024-08-15 11:11:24 +02:00
parent 479ad685f5
commit 7a74d3400a
3 changed files with 103 additions and 1 deletions

44
glibc-RHEL-46723-1.patch Normal file
View File

@ -0,0 +1,44 @@
commit 0e16db440cc73d2cdd94e439c0efa1ec43d92b2a
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Aug 13 15:52:34 2024 +0200
manual: Document generic printf error codes
Describe EOVERFLOW, ENOMEN, EILSEQ.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 567f6780011f9db1..41298b87a4a6c7d9 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2318,6 +2318,29 @@ the easiest way to make sure you have all the right prototypes is to
just include @file{stdio.h}.
@pindex stdio.h
+The @code{printf} family shares the error codes listed below.
+Individual functions may report additional @code{errno} values if they
+fail.
+
+@table @code
+@item EOVERFLOW
+The number of written bytes would have exceeded @code{INT_MAX}, and thus
+could not be represented in the return type @code{int}.
+
+@item ENOMEM
+The function could not allocate memory during processing. Long argument
+lists and certain floating point conversions may require memory
+allocation, as does initialization of an output stream upon first use.
+
+@item EILSEQ
+POSIX specifies this error code should be used if a wide character is
+encountered that does not have a matching valid character. @Theglibc{}
+always performs transliteration, using a replacement character if
+necessary, so this error condition cannot occur on output. However,
+@theglibc{} uses @code{EILSEQ} to indicate that an input character
+sequence (wide or multi-byte) could not be converted successfully.
+@end table
+
@deftypefun int printf (const char *@var{template}, @dots{})
@standards{ISO, stdio.h}
@safety{@prelim{}@mtsafe{@mtslocale{}}@asunsafe{@asucorrupt{} @ascuheap{}}@acunsafe{@acsmem{} @aculock{} @acucorrupt{}}}

53
glibc-RHEL-46723-2.patch Normal file
View File

@ -0,0 +1,53 @@
commit 2be0572f3a41d5d5a8bb3b2b04244b7c01ac0f58
Author: Florian Weimer <fweimer@redhat.com>
Date: Tue Aug 13 15:52:34 2024 +0200
manual: Document dprintf and vdprintf
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/stdio.texi b/manual/stdio.texi
index 41298b87a4a6c7d9..d3d855fc62b8768b 100644
--- a/manual/stdio.texi
+++ b/manual/stdio.texi
@@ -2483,6 +2483,26 @@ store the result in which case @code{-1} is returned. This was
changed in order to comply with the @w{ISO C99} standard.
@end deftypefun
+@deftypefun dprintf (int @var{fd}, @var{template}, ...)
+@standards{POSIX, stdio.h}
+@safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+This function formats its arguments according to @var{template} and
+writes the result to the file descriptor @var{fd}, using the
+@code{write} function. It returns the number of bytes written, or a
+negative value if there was an error. In the error case, @code{errno}
+is set appropriately. The possible @code{errno} values depend on the
+type of the file descriptor @var{fd}, in addition to the general
+@code{printf} error codes.
+
+The number of calls to @code{write} is unspecified, and some @code{write}
+calls may have happened even if @code{dprintf} returns with an error.
+
+@strong{Portability Note:} POSIX does not require that this function is
+async-signal-safe, and @theglibc{} implementation is not. However, some
+other systems offer this function as an async-signal-safe alternative to
+@code{fprintf}. @xref{POSIX Safety Concepts}.
+@end deftypefun
+
@node Dynamic Output
@subsection Dynamically Allocating Formatted Output
@@ -2696,6 +2716,13 @@ The @code{obstack_vprintf} function is the equivalent of
as for @code{vprintf}.@refill
@end deftypefun
+@deftypefun int vdprintf (int @var{fd}, const char *@var{template}, va_list @var{ap})
+@standards{POSIX, stdio.h}
+@safety{@mtsafe{@mtslocale{}}@asunsafe{@ascuheap{}}@acunsafe{@acsmem{}}}
+The @code{vdprintf} is the equivalent of @code{dprintf}, but processes
+an argument list.
+@end deftypefun
+
Here's an example showing how you might use @code{vfprintf}. This is a
function that prints error messages to the stream @code{stderr}, along
with a prefix indicating the name of the program

View File

@ -157,7 +157,7 @@ end \
Summary: The GNU libc libraries Summary: The GNU libc libraries
Name: glibc Name: glibc
Version: %{glibcversion} Version: %{glibcversion}
Release: 120%{?dist} Release: 121%{?dist}
# In general, GPLv2+ is used by programs, LGPLv2+ is used for # In general, GPLv2+ is used by programs, LGPLv2+ is used for
# libraries. # libraries.
@ -848,6 +848,8 @@ Patch609: glibc-RHEL-50101-1.patch
Patch610: glibc-RHEL-50101-2.patch Patch610: glibc-RHEL-50101-2.patch
Patch611: glibc-RHEL-50101-3.patch Patch611: glibc-RHEL-50101-3.patch
Patch612: glibc-RHEL-54007.patch Patch612: glibc-RHEL-54007.patch
Patch613: glibc-RHEL-46723-1.patch
Patch614: glibc-RHEL-46723-2.patch
############################################################################## ##############################################################################
# Continued list of core "glibc" package information: # Continued list of core "glibc" package information:
@ -3007,6 +3009,9 @@ update_gconv_modules_cache ()
%endif %endif
%changelog %changelog
* Thu Aug 15 2024 Florian Weimer <fweimer@redhat.com> - 2.34-121
- Document dprintf, vdprintf in the manual (RHEL-46723)
* Tue Aug 13 2024 Frédéric Bérat <fberat@redhat.com> - 2.34-120 * Tue Aug 13 2024 Frédéric Bérat <fberat@redhat.com> - 2.34-120
- getdelim: ensure error indicator is set on error (RHEL-54007) - getdelim: ensure error indicator is set on error (RHEL-54007)