objdump: avoid shadowing a libiberty symbol

Message ID 5D10C600020000780023A9E9@prv1-mh.provo.novell.com
State New
Headers show
Series
  • objdump: avoid shadowing a libiberty symbol
Related show

Commit Message

Jan Beulich June 24, 2019, 12:45 p.m.
With my (oldish) gcc I'm seeing

.../binutils/objdump.c: In function ‘dump_ctf_indent_lines’:
.../binutils/objdump.c:3210: error: declaration of ‘spaces’ shadows a global declaration
.../binutils/../include/libiberty.h:253: error: shadowed declaration is here

binutils/
2019-06-24  Jan Beulich  <jbeulich@suse.com>

	* objdump.c (dump_ctf_indent_lines): Rename local variable
	"spaces" to "spcs".

Comments

Nick Alcock June 24, 2019, 7:31 p.m. | #1
On 24 Jun 2019, Jan Beulich outgrape:

> With my (oldish) gcc I'm seeing

>

> .../binutils/objdump.c: In function ‘dump_ctf_indent_lines’:

> .../binutils/objdump.c:3210: error: declaration of ‘spaces’ shadows a global declaration

> .../binutils/../include/libiberty.h:253: error: shadowed declaration is here


Oof. Sorry about that.

> binutils/

> 2019-06-24  Jan Beulich  <jbeulich@suse.com>

>

> 	* objdump.c (dump_ctf_indent_lines): Rename local variable

> 	"spaces" to "spcs".

>

> --- a/binutils/objdump.c

> +++ b/binutils/objdump.c

> @@ -3207,10 +3207,10 @@ static char *

>  dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,

>  		       char *s, void *arg)

>  {

> -  char *spaces = arg;

> +  char *spcs = arg;


Hm. "blanks" might be a better name?

-- 
NULL && (void)
Jan Beulich June 25, 2019, 6:53 a.m. | #2
>>> On 24.06.19 at 21:31, <nick.alcock@oracle.com> wrote:

> On 24 Jun 2019, Jan Beulich outgrape:

>> --- a/binutils/objdump.c

>> +++ b/binutils/objdump.c

>> @@ -3207,10 +3207,10 @@ static char *

>>  dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,

>>  		       char *s, void *arg)

>>  {

>> -  char *spaces = arg;

>> +  char *spcs = arg;

> 

> Hm. "blanks" might be a better name?


Hmm, yes, fine with me. Will switch. I'd nevertheless hope I could get
approval to commit this without having to send a v2.

Jan
Alan Modra June 25, 2019, 8:03 a.m. | #3
On Tue, Jun 25, 2019 at 12:53:52AM -0600, Jan Beulich wrote:
> >>> On 24.06.19 at 21:31, <nick.alcock@oracle.com> wrote:

> > On 24 Jun 2019, Jan Beulich outgrape:

> >> --- a/binutils/objdump.c

> >> +++ b/binutils/objdump.c

> >> @@ -3207,10 +3207,10 @@ static char *

> >>  dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,

> >>  		       char *s, void *arg)

> >>  {

> >> -  char *spaces = arg;

> >> +  char *spcs = arg;

> > 

> > Hm. "blanks" might be a better name?

> 

> Hmm, yes, fine with me. Will switch. I'd nevertheless hope I could get

> approval to commit this without having to send a v2.


Sure, go ahead.

-- 
Alan Modra
Australia Development Lab, IBM
Jan Beulich June 25, 2019, 9:11 a.m. | #4
>>> On 25.06.19 at 10:03, <amodra@gmail.com> wrote:

> On Tue, Jun 25, 2019 at 12:53:52AM -0600, Jan Beulich wrote:

>> >>> On 24.06.19 at 21:31, <nick.alcock@oracle.com> wrote:

>> > On 24 Jun 2019, Jan Beulich outgrape:

>> >> --- a/binutils/objdump.c

>> >> +++ b/binutils/objdump.c

>> >> @@ -3207,10 +3207,10 @@ static char *

>> >>  dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,

>> >>  		       char *s, void *arg)

>> >>  {

>> >> -  char *spaces = arg;

>> >> +  char *spcs = arg;

>> > 

>> > Hm. "blanks" might be a better name?

>> 

>> Hmm, yes, fine with me. Will switch. I'd nevertheless hope I could get

>> approval to commit this without having to send a v2.

> 

> Sure, go ahead.


Thanks; I've extended this to the very similar readelf change as well,
but not to the slightly more different bfd/elf-properties.c and
ld/plugin.c ones.

Jan
Nick Alcock June 25, 2019, 2:11 p.m. | #5
On 25 Jun 2019, Jan Beulich verbalised:

>>>> On 25.06.19 at 10:03, <amodra@gmail.com> wrote:

>> On Tue, Jun 25, 2019 at 12:53:52AM -0600, Jan Beulich wrote:

>>> Hmm, yes, fine with me. Will switch. I'd nevertheless hope I could get

>>> approval to commit this without having to send a v2.

>> 

>> Sure, go ahead.

>

> Thanks; I've extended this to the very similar readelf change as well,

> but not to the slightly more different bfd/elf-properties.c and

> ld/plugin.c ones.


I was just about to suggest that you do exactly that. Thank you!
(The mystery is why I didn't see this warning at any time. Different GCC
version, perhaps?)
Hans-Peter Nilsson June 28, 2019, 1:13 a.m. | #6
On Tue, 25 Jun 2019, Nick Alcock wrote:
> On 25 Jun 2019, Jan Beulich verbalised:

>

> >>>> On 25.06.19 at 10:03, <amodra@gmail.com> wrote:

> >> On Tue, Jun 25, 2019 at 12:53:52AM -0600, Jan Beulich wrote:

> >>> Hmm, yes, fine with me. Will switch. I'd nevertheless hope I could get

> >>> approval to commit this without having to send a v2.

> >>

> >> Sure, go ahead.

> >

> > Thanks; I've extended this to the very similar readelf change as well,

> > but not to the slightly more different bfd/elf-properties.c and

> > ld/plugin.c ones.

>

> I was just about to suggest that you do exactly that. Thank you!

> (The mystery is why I didn't see this warning at any time. Different GCC

> version, perhaps?)


One version where you can see this is gcc-4.3.0. (Yes, I saw it
too, just didn't get around to do the legwork, so thanks Jan.)

The warning is removed from later gcc-versions, IIRC because it
was deemed incorrect, or removed as undesirable from -W, -Wall
or something like that.  That of course is not the same as (not)
actively avoiding the warning for compatibility reasons.

brgds, H-P

Patch

--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3207,10 +3207,10 @@  static char *
 dump_ctf_indent_lines (ctf_sect_names_t sect ATTRIBUTE_UNUSED,
 		       char *s, void *arg)
 {
-  char *spaces = arg;
+  char *spcs = arg;
   char *new_s;
 
-  if (asprintf (&new_s, "%s%s", spaces, s) < 0)
+  if (asprintf (&new_s, "%s%s", spcs, s) < 0)
     return s;
   return new_s;
 }