[PATCH] remove pointless assignment
Trevor Saunders
tbsaunde@tbsaunde.org
Fri Apr 15 14:52:00 GMT 2016
On Fri, Apr 15, 2016 at 07:53:22AM +0930, Alan Modra wrote:
> 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]
well, -Wpointer-arith warns too ;) that's how I noticed it.
> 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.
makes sense, sure.
Trev
>
> --
> Alan Modra
> Australia Development Lab, IBM
More information about the Binutils
mailing list