[11/26] stdio-common: Simplify printf_unknown interface in vfprintf-internal.c

Message ID aea6360287c5ea86d3c5b5d18155a89640cdf3d0.1647544751.git.fweimer@redhat.com
State Superseded
Headers
Series vfprintf rework to remove vtables |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer March 17, 2022, 7:30 p.m. UTC
  The called function does not use the args array, so there is no need
to produce it.
---
 stdio-common/vfprintf-internal.c | 21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)
  

Comments

Adhemerval Zanella May 20, 2022, 6:07 p.m. UTC | #1
On 17/03/2022 16:30, Florian Weimer via Libc-alpha wrote:
> The called function does not use the args array, so there is no need
> to produce it.

LGTM, thanks.

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

> ---
>  stdio-common/vfprintf-internal.c | 21 +++------------------
>  1 file changed, 3 insertions(+), 18 deletions(-)
> 
> diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
> index f8aa2fdafb..fb94961f37 100644
> --- a/stdio-common/vfprintf-internal.c
> +++ b/stdio-common/vfprintf-internal.c
> @@ -672,8 +672,7 @@ static int printf_positional (FILE *s,
>  			      unsigned int mode_flags);
>  
>  /* Handle unknown format specifier.  */
> -static int printf_unknown (FILE *, const struct printf_info *,
> -			   const void *const *) __THROW;
> +static int printf_unknown (FILE *, const struct printf_info *) __THROW;
>  
>  /* Group digits of number string.  */
>  static CHAR_T *group_number (CHAR_T *, CHAR_T *, CHAR_T *, const char *,
> @@ -1465,19 +1464,7 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
>  
>  	  LABEL (form_unknown):
>  	  {
> -	    unsigned int i;
> -	    const void **ptr;
> -
> -	    ptr = alloca (specs[nspecs_done].ndata_args
> -			  * sizeof (const void *));
> -
> -	    /* Fill in an array of pointers to the argument values.  */
> -	    for (i = 0; i < specs[nspecs_done].ndata_args; ++i)
> -	      ptr[i] = &args_value[specs[nspecs_done].data_arg + i];
> -
> -	    /* Call the function.  */
> -	    function_done = printf_unknown (s, &specs[nspecs_done].info,
> -					    ptr);
> +	    int function_done = printf_unknown (s, &specs[nspecs_done].info);
>  
>  	    /* If an error occurred we don't have information about #
>  	       of chars.  */
> @@ -1507,9 +1494,7 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
>  /* Handle an unknown format specifier.  This prints out a canonicalized
>     representation of the format spec itself.  */
>  static int
> -printf_unknown (FILE *s, const struct printf_info *info,
> -		const void *const *args)
> -
> +printf_unknown (FILE *s, const struct printf_info *info)
>  {
>    int done = 0;
>    CHAR_T work_buffer[MAX (sizeof (info->width), sizeof (info->prec)) * 3];
  

Patch

diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index f8aa2fdafb..fb94961f37 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -672,8 +672,7 @@  static int printf_positional (FILE *s,
 			      unsigned int mode_flags);
 
 /* Handle unknown format specifier.  */
-static int printf_unknown (FILE *, const struct printf_info *,
-			   const void *const *) __THROW;
+static int printf_unknown (FILE *, const struct printf_info *) __THROW;
 
 /* Group digits of number string.  */
 static CHAR_T *group_number (CHAR_T *, CHAR_T *, CHAR_T *, const char *,
@@ -1465,19 +1464,7 @@  printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
 
 	  LABEL (form_unknown):
 	  {
-	    unsigned int i;
-	    const void **ptr;
-
-	    ptr = alloca (specs[nspecs_done].ndata_args
-			  * sizeof (const void *));
-
-	    /* Fill in an array of pointers to the argument values.  */
-	    for (i = 0; i < specs[nspecs_done].ndata_args; ++i)
-	      ptr[i] = &args_value[specs[nspecs_done].data_arg + i];
-
-	    /* Call the function.  */
-	    function_done = printf_unknown (s, &specs[nspecs_done].info,
-					    ptr);
+	    int function_done = printf_unknown (s, &specs[nspecs_done].info);
 
 	    /* If an error occurred we don't have information about #
 	       of chars.  */
@@ -1507,9 +1494,7 @@  printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
 /* Handle an unknown format specifier.  This prints out a canonicalized
    representation of the format spec itself.  */
 static int
-printf_unknown (FILE *s, const struct printf_info *info,
-		const void *const *args)
-
+printf_unknown (FILE *s, const struct printf_info *info)
 {
   int done = 0;
   CHAR_T work_buffer[MAX (sizeof (info->width), sizeof (info->prec)) * 3];