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: [PATCH] remove pointless assignment


On Thu, Apr 14, 2016 at 05:36:55PM -0400, tbsaunde+binutils@tbsaunde.org wrote:
> diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
> index 118b91d..f3dbd5f 100644
> --- a/gas/config/tc-mips.c
> +++ b/gas/config/tc-mips.c
> @@ -3604,7 +3604,6 @@ md_begin (void)
>        char regname[7];
>  
>        /* R5900 VU0 floating-point register.  */
> -      regname[sizeof (rename) - 1] = 0;
>        snprintf (regname, sizeof (regname) - 1, "$vf%d", i);
>        symbol_table_insert (symbol_new (regname, reg_section,
>  				       RTYPE_VF | i, &zero_address_frag));

OK.  Interestingly, gcc only warns about this with -pedantic.
warning: invalid application of âsizeofâ to a function type [-Wpointer-arith]

Hmm, there's really no need for snprintf here.  We know exactly how
large the result string will be, so if you like, you can replace
snprintf with sprintf while you're editing this code.  Oh, and use
char regname[6].  An odd size (not a power of two or multiple of 10)
says to me the programmer has calculated maximum needed size, so we
may as well use the correct max size.

-- 
Alan Modra
Australia Development Lab, IBM


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