public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 06/11] stdio: Rename __printf_buffer to __vfprintf_buffer
Date: Fri, 16 Feb 2024 10:40:23 -0300	[thread overview]
Message-ID: <2f79b0ab-073d-4df5-8b36-941b93d5e7c3@linaro.org> (raw)
In-Reply-To: <c23bed2f8fed8be96f0b56f3b81430515e6ccf24.1707491940.git.fweimer@redhat.com>



On 09/02/24 12:25, Florian Weimer wrote:
> And __wprintf_buffer to __vwprintf_buffer.  These functions take
> a va_list argument, so they are closer to the v-variant functions
> in <stdio.h>.
> 
> Also move the declaration to <printf_buffer.h>, which is arguably
> a better fit than <printf.h> (which contains lots of printf
> internals).

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  include/printf.h                 |  9 +--------
>  include/printf_buffer.h          |  9 +++++++++
>  libio/iovdprintf.c               |  2 +-
>  libio/iovsprintf.c               |  2 +-
>  libio/obprintf.c                 |  2 +-
>  libio/vasprintf.c                |  2 +-
>  libio/vsnprintf.c                |  2 +-
>  libio/vswprintf.c                |  2 +-
>  stdio-common/vfprintf-internal.c | 10 ++++++----
>  9 files changed, 22 insertions(+), 18 deletions(-)
> 
> diff --git a/include/printf.h b/include/printf.h
> index 2c998059d4..78aac4dcad 100644
> --- a/include/printf.h
> +++ b/include/printf.h
> @@ -65,18 +65,11 @@ int __translated_number_width (locale_t loc,
>  			       const char *first, const char *last)
>    attribute_hidden;
>  
> -
> -struct __printf_buffer;
> -void __printf_buffer (struct __printf_buffer *buf, const char *format,
> -		      va_list ap, unsigned int mode_flags);
> -struct __wprintf_buffer;
> -void __wprintf_buffer (struct __wprintf_buffer *buf, const wchar_t *format,
> -		       va_list ap, unsigned int mode_flags);
> -
>  extern int __printf_fp (FILE *, const struct printf_info *,
>  			const void *const *);
>  libc_hidden_proto (__printf_fp)
>  
> +struct __printf_buffer;
>  void __printf_fphex_l_buffer (struct __printf_buffer *, locale_t,
>  			      const struct printf_info *,
>  			      const void *const *) attribute_hidden;
> diff --git a/include/printf_buffer.h b/include/printf_buffer.h
> index eff8e3413a..fb0b42178e 100644
> --- a/include/printf_buffer.h
> +++ b/include/printf_buffer.h
> @@ -200,6 +200,12 @@ int __printf_buffer_done (struct __printf_buffer *buf) attribute_hidden;
>     known, and the flush implementation can be called directly.  */
>  bool __printf_buffer_flush (struct __printf_buffer *buf) attribute_hidden;
>  
> +/* Building block for printf-style functions.  Write argument list AP
> +   to BUF according to FORMAT.  MODE_FLAGS contains PRINTF_* flags
> +   defined in <libioP.h>.  */
> +void __vprintf_buffer (struct __printf_buffer *buf, const char *format,
> +                       va_list ap, unsigned int mode_flags) attribute_hidden;
> +
>  /* Wide version of struct __printf_buffer follows.  */
>  
>  enum __wprintf_buffer_mode
> @@ -274,6 +280,9 @@ int __wprintf_buffer_done (struct __wprintf_buffer *buf) attribute_hidden;
>  
>  bool __wprintf_buffer_flush (struct __wprintf_buffer *buf) attribute_hidden;
>  
> +void __vwprintf_buffer (struct __wprintf_buffer *buf, const wchar_t *format,
> +                        va_list ap, unsigned int mode_flags) attribute_hidden;
> +
>  /* Type-generic convenience macros.  They are useful if
>     printf_buffer-char.h or printf_buffer-wchar_t.h is included as
>     well.  */
> diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c
> index 6894fa8347..47d9d0ba8f 100644
> --- a/libio/iovdprintf.c
> +++ b/libio/iovdprintf.c
> @@ -66,7 +66,7 @@ __vdprintf_internal (int d, const char *format, va_list arg,
>    __printf_buffer_init (&buf.base, buf.buf, array_length (buf.buf),
>  			__printf_buffer_mode_dprintf);
>    buf.fd = d;
> -  __printf_buffer (&buf.base, format, arg, mode_flags);
> +  __vprintf_buffer (&buf.base, format, arg, mode_flags);
>    if (__printf_buffer_has_failed (&buf.base))
>      return -1;
>    __printf_buffer_flush_dprintf (&buf);
> diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c
> index 2d81ee3507..7fdc06dcd4 100644
> --- a/libio/iovsprintf.c
> +++ b/libio/iovsprintf.c
> @@ -59,7 +59,7 @@ __vsprintf_internal (char *string, size_t maxlen,
>      __printf_buffer_init_end (&buf, string, (char *) ~(uintptr_t) 0,
>  			      __printf_buffer_mode_sprintf);
>  
> -  __printf_buffer (&buf, format, args, mode_flags);
> +  __vprintf_buffer (&buf, format, args, mode_flags);
>  
>    /* Write the NUL terminator if there is room.  Do not use the putc
>       operation to avoid overflowing the character write count.  */
> diff --git a/libio/obprintf.c b/libio/obprintf.c
> index 491d14fbae..24d1edf260 100644
> --- a/libio/obprintf.c
> +++ b/libio/obprintf.c
> @@ -92,7 +92,7 @@ __obstack_vprintf_internal (struct obstack *obstack, const char *format,
>    /* Now allocate the rest of the current chunk.  */
>    obstack_blank_fast (obstack, room);
>  
> -  __printf_buffer (&buf.base, format, args, mode_flags);
> +  __vprintf_buffer (&buf.base, format, args, mode_flags);
>  
>    if (buf.base.write_ptr == &buf.ch + 1)
>      /* buf.ch is in use.  Put it into the obstack.  */
> diff --git a/libio/vasprintf.c b/libio/vasprintf.c
> index 999ae526f4..edcfab2323 100644
> --- a/libio/vasprintf.c
> +++ b/libio/vasprintf.c
> @@ -99,7 +99,7 @@ __vasprintf_internal (char **result_ptr, const char *format, va_list args,
>    __printf_buffer_init (&buf.base, buf.direct, array_length (buf.direct),
>  			__printf_buffer_mode_asprintf);
>  
> -  __printf_buffer (&buf.base, format, args, mode_flags);
> +  __vprintf_buffer (&buf.base, format, args, mode_flags);
>    int done = __printf_buffer_done (&buf.base);
>    if (done < 0)
>      {
> diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c
> index dd7a585cbe..7077fcd9f2 100644
> --- a/libio/vsnprintf.c
> +++ b/libio/vsnprintf.c
> @@ -93,7 +93,7 @@ __vsnprintf_internal (char *string, size_t maxlen, const char *format,
>  {
>    struct __printf_buffer_snprintf buf;
>    __printf_buffer_snprintf_init (&buf, string, maxlen);
> -  __printf_buffer (&buf.base, format, args, mode_flags);
> +  __vprintf_buffer (&buf.base, format, args, mode_flags);
>    return __printf_buffer_snprintf_done (&buf);
>  }
>  
> diff --git a/libio/vswprintf.c b/libio/vswprintf.c
> index 5990bd2eff..d73246ba41 100644
> --- a/libio/vswprintf.c
> +++ b/libio/vswprintf.c
> @@ -41,7 +41,7 @@ __vswprintf_internal (wchar_t *string, size_t maxlen, const wchar_t *format,
>    struct __wprintf_buffer buf;
>    __wprintf_buffer_init (&buf, string, maxlen, __wprintf_buffer_mode_swprintf);
>  
> -  __wprintf_buffer (&buf, format, args, mode_flags);
> +  __vwprintf_buffer (&buf, format, args, mode_flags);
>  
>    if (buf.write_ptr == buf.write_end)
>      {
> diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
> index 771beca9bf..23754232f2 100644
> --- a/stdio-common/vfprintf-internal.c
> +++ b/stdio-common/vfprintf-internal.c
> @@ -122,6 +122,7 @@
>  
>  #ifndef COMPILE_WPRINTF
>  # include "printf_buffer-char.h"
> +# define VFPRINTF_BUFFER __vprintf_buffer
>  # define vfprintf	__vfprintf_internal
>  # define OTHER_CHAR_T   wchar_t
>  # define UCHAR_T	unsigned char
> @@ -136,6 +137,7 @@ typedef const char *THOUSANDS_SEP_T;
>  # define CONVERT_FROM_OTHER_STRING __wcsrtombs
>  #else
>  # include "printf_buffer-wchar_t.h"
> +# define VFPRINTF_BUFFER __vwprintf_buffer
>  # define vfprintf	__vfwprintf_internal
>  # define OTHER_CHAR_T   char
>  /* This is a hack!!!  There should be a type uwchar_t.  */
> @@ -595,8 +597,8 @@ static void group_number (struct Xprintf_buffer *buf,
>  
>  /* The buffer-based function itself.  */
>  void
> -Xprintf_buffer (struct Xprintf_buffer *buf, const CHAR_T *format,
> -		  va_list ap, unsigned int mode_flags)
> +VFPRINTF_BUFFER (struct Xprintf_buffer *buf, const CHAR_T *format,
> +		 va_list ap, unsigned int mode_flags)
>  {
>    /* The character used as thousands separator.  */
>    THOUSANDS_SEP_T thousands_sep = 0;
> @@ -1541,7 +1543,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
>      {
>        struct Xprintf (buffer_to_file) wrap;
>        Xprintf (buffer_to_file_init) (&wrap, s);
> -      Xprintf_buffer (&wrap.base, format, ap, mode_flags);
> +      VFPRINTF_BUFFER (&wrap.base, format, ap, mode_flags);
>        return Xprintf (buffer_to_file_done) (&wrap);
>      }
>  
> @@ -1556,7 +1558,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
>    Xprintf (buffer_to_file_init) (&wrap, s);
>  
>    /* Perform the printing operation on the buffer.  */
> -  Xprintf_buffer (&wrap.base, format, ap, mode_flags);
> +  VFPRINTF_BUFFER (&wrap.base, format, ap, mode_flags);
>    done = Xprintf (buffer_to_file_done) (&wrap);
>  
>    /* Unlock the stream.  */

  reply	other threads:[~2024-02-16 13:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09 15:24 [PATCH 00/11] Build getdomainname, gethostname, syslog with fortification Florian Weimer
2024-02-09 15:24 ` [PATCH 01/11] misc: Build getdomainname " Florian Weimer
2024-02-12 17:14   ` Adhemerval Zanella Netto
2024-02-12 17:30     ` Andreas Schwab
2024-02-12 19:29       ` Florian Weimer
2024-02-13  9:12         ` Andreas Schwab
2024-02-13  9:23           ` Florian Weimer
2024-02-13  9:32             ` Andreas Schwab
2024-02-09 15:24 ` [PATCH 02/11] misc: Build gethostname " Florian Weimer
2024-02-12 17:25   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 03/11] libio: Add fortify wrapper for internal __snprintf Florian Weimer
2024-02-12 17:34   ` Adhemerval Zanella Netto
2024-02-13 12:13     ` Florian Weimer
2024-02-13 13:16       ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 04/11] syslog: Update misc/tst-syslog to check reported %n value Florian Weimer
2024-02-13 11:59   ` Adhemerval Zanella Netto
2024-02-15 13:23     ` Florian Weimer
2024-02-09 15:25 ` [PATCH 05/11] syslog: Build with fortification Florian Weimer
2024-02-13 12:26   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 06/11] stdio: Rename __printf_buffer to __vfprintf_buffer Florian Weimer
2024-02-16 13:40   ` Adhemerval Zanella Netto [this message]
2024-02-09 15:25 ` [PATCH 07/11] libio: Extract __printf_buffer_asprintf_init from asprintf implementation Florian Weimer
2024-02-16 14:04   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 08/11] stdio-common: Introduce the __printf_buffer function Florian Weimer
2024-02-16 14:12   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 09/11] stdio-common: Allow skipping initial bytes in __printf_buffer for %n Florian Weimer
2024-02-16 14:13   ` Adhemerval Zanella Netto
2024-02-09 15:25 ` [PATCH 10/11] stdio-common: Support large offsets with %lln Florian Weimer
2024-02-16 14:20   ` Adhemerval Zanella Netto
2024-02-09 15:26 ` [PATCH 11/11] syslog: Use a printf buffer directly to construct the entire packet Florian Weimer
2024-02-14 15:16   ` Adhemerval Zanella Netto
2024-02-15 13:02     ` Florian Weimer
2024-02-16 13:35       ` Adhemerval Zanella Netto
2024-02-16 15:58   ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f79b0ab-073d-4df5-8b36-941b93d5e7c3@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).