This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [AArch64][SVE 02/32] Avoid hard-coded limit in indented_print


On 23/08/16 10:06, Richard Sandiford wrote:
> The maximum indentation needed by aarch64-gen.c grows as more
> instructions are added to aarch64-tbl.h.  Rather than having to
> increase the indentation limit to a higher value, it seemed better
> to replace it with "%*s".
> 
> OK to install?
> 
> Thanks,
> Richard
> 
> 
> opcodes/
> 	* aarch64-gen.c (indented_print): Avoid hard-coded indentation limit.
> 
> diff --git a/opcodes/aarch64-gen.c b/opcodes/aarch64-gen.c
> index ed0834a..b87dea4 100644
> --- a/opcodes/aarch64-gen.c
> +++ b/opcodes/aarch64-gen.c
> @@ -378,13 +378,9 @@ initialize_decoder_tree (void)
>  static void __attribute__ ((format (printf, 2, 3)))
>  indented_print (unsigned int indent, const char *format, ...)
>  {
> -  /* 80 number of spaces pluc a NULL terminator.  */
> -  static const char spaces[81] =
> -    "                                                                                ";
>    va_list ap;
>    va_start (ap, format);
> -  assert (indent <= 80);
> -  printf ("%s", &spaces[80 - indent]);
> +  printf ("%*s", indent, "");
>    vprintf (format, ap);
>    va_end (ap);
>  }
> 

According to the printf(3) INDENT must be of type 'int' (with special
treatment of negative values).  So for portability and to ensure we
don't get any warnings, I think we need a cast here.

Otherwise OK.

R.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]