[PATCH] remove pointless assignment
Dan
dgisselq@verizon.net
Thu Apr 14 23:01:00 GMT 2016
More information about the Binutils mailing list
Thu Apr 14 23:01:00 GMT 2016
- Previous message (by thread): [PATCH] remove pointless assignment
- Next message (by thread): New ARC linker testsuite failure
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Trevor, I just checked the man page on snprintf. Wouldn't, snprintf(regname, sizeof(regname), "$vf%d", i); be more appropriate? According to the manpage, the size parameter needs to include the null termination. Dan P.S. My apologies if this is a duplicate msg ... On Thu, 2016-04-14 at 17:36 -0400, tbsaunde+binutils@tbsaunde.org wrote: > From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org> > > Hi, > > Presumably this was supposed to be regname[sizeof (regname) - 1] but was typoed > to regname[sizeof (rename) - 1]. However that should be unnecessary because > sprintf should null terminate. As is this assignment is invalid ISO C because > rename refers to the function rename (), and sizeof on functions is undefined. > In GNU C C the size of functions is 1 so the expression is the same as > regname[0]. The following call to sprintf () clearly will over right that, so > the statement either has no effect or is invalid. Given that it seems safe to > just remove it. > > built and regtested cross to mips64-elf, ok? > > Trev > > gas/ChangeLog: > > 2016-04-14 Trevor Saunders <tbsaunde+binutils@tbsaunde.org> > > * config/tc-mips.c (md_begin): Remove useless assignment. > --- > gas/config/tc-mips.c | 1 - > 1 file changed, 1 deletion(-) > > 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));
- Previous message (by thread): [PATCH] remove pointless assignment
- Next message (by thread): New ARC linker testsuite failure
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list