This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] remove pointless assignment
- From: Trevor Saunders <tbsaunde at tbsaunde dot org>
- To: Alan Modra <amodra at gmail dot com>
- Cc: tbsaunde+binutils at tbsaunde dot org, binutils at sourceware dot org
- Date: Fri, 15 Apr 2016 10:54:10 -0400
- Subject: Re: [PATCH] remove pointless assignment
- Authentication-results: sourceware.org; auth=none
- References: <1460669815-11911-1-git-send-email-tbsaunde+binutils at tbsaunde dot org> <20160414222322 dot GA27620 at bubble dot grove dot modra dot org>
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