public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: Don't shadow index function from string.h
@ 2018-07-04 14:13 Mark Wielaard
  2018-07-05 19:26 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-07-04 14:13 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Mark Wielaard

On some ancient GCC versions (4.4.7 at least) -Wshadow warns about local
variables "shadowing" global function definitions.

  readelf.c: In function ‘print_debug_addr_section’:
  readelf.c:5265: error: declaration of ‘index’ shadows a global declaration
  /usr/include/string.h:489: error: shadowed declaration is here

This is silly of course, but easy to work around.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 src/ChangeLog |  6 ++++++
 src/readelf.c | 14 +++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 6d962bb..2b711da 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2018-07-04  Mark Wielaard  <mark@klomp.org>
+
+	* readelf.c (print_debug_addr_section): Rename index var to uidx.
+	(attr_callback): Rename index var to word.
+	(print_debug_str_offsets_section): Rename index var to uidx.
+
 2018-06-25  Mark Wielaard  <mark@klomp.org>
 
 	* readelf.c (print_decoded_line_section): Use dwarf_next_lines
diff --git a/src/readelf.c b/src/readelf.c
index faed61a..22355e9 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -5262,14 +5262,14 @@ print_debug_addr_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 	  addresses /= 10;
 	}
 
-      unsigned int index = 0;
+      unsigned int uidx = 0;
       size_t index_offset =  readp - (const unsigned char *) data->d_buf;
       printf (" Addresses start at offset 0x%zx:\n", index_offset);
       while (readp <= next_unitp - address_size)
 	{
 	  Dwarf_Addr addr = read_addr_unaligned_inc (address_size, dbg,
 						     readp);
-	  printf (" [%*u] ", digits, index++);
+	  printf (" [%*u] ", digits, uidx++);
 	  print_dwarf_addr (dwflmod, address_size, addr, addr);
 	  printf ("\n");
 	}
@@ -6967,12 +6967,12 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
 	    }
 	  if (form != DW_FORM_addr )
 	    {
-	      Dwarf_Word index;
-	      if (dwarf_formudata (attrp, &index) != 0)
+	      Dwarf_Word word;
+	      if (dwarf_formudata (attrp, &word) != 0)
 		goto attrval_out;
 	      printf ("           %*s%-20s (%s) [%" PRIx64 "] ",
 		      (int) (level * 2), "", dwarf_attr_name (attr),
-		      dwarf_form_name (form), index);
+		      dwarf_form_name (form), word);
 	    }
 	  else
 	    printf ("           %*s%-20s (%s) ",
@@ -10256,7 +10256,7 @@ print_debug_str_offsets_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 	  offsets /= 10;
 	}
 
-      unsigned int index = 0;
+      unsigned int uidx = 0;
       size_t index_offset =  readp - (const unsigned char *) data->d_buf;
       printf (" Offsets start at 0x%zx:\n", index_offset);
       while (readp <= next_unitp - offset_size)
@@ -10268,7 +10268,7 @@ print_debug_str_offsets_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
 	    offset = read_8ubyte_unaligned_inc (dbg, readp);
 	  const char *str = dwarf_getstring (dbg, offset, NULL);
 	  printf (" [%*u] [%*" PRIx64 "]  \"%s\"\n",
-		  digits, index++, (int) offset_size * 2, offset, str ?: "???");
+		  digits, uidx++, (int) offset_size * 2, offset, str ?: "???");
 	}
       printf ("\n");
 
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] readelf: Don't shadow index function from string.h
  2018-07-04 14:13 [PATCH] readelf: Don't shadow index function from string.h Mark Wielaard
@ 2018-07-05 19:26 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-07-05 19:26 UTC (permalink / raw)
  To: elfutils-devel

On Wed, Jul 04, 2018 at 04:13:26PM +0200, Mark Wielaard wrote:
> On some ancient GCC versions (4.4.7 at least) -Wshadow warns about local
> variables "shadowing" global function definitions.
> 
>   readelf.c: In function ‘print_debug_addr_section’:
>   readelf.c:5265: error: declaration of ‘index’ shadows a global declaration
>   /usr/include/string.h:489: error: shadowed declaration is here
> 
> This is silly of course, but easy to work around.

Pushed to master.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-05 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 14:13 [PATCH] readelf: Don't shadow index function from string.h Mark Wielaard
2018-07-05 19:26 ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).