Skip to content

Commit

Permalink
readelf: Don't shadow index function from string.h
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Mark Wielaard committed Jul 5, 2018
1 parent e893aab commit 3012cda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2018-07-04 Mark Wielaard <[email protected]>

* 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-07-04 Ross Burton <[email protected]>

* addr2line.c: Remove error.h include.
Expand Down
14 changes: 7 additions & 7 deletions src/readelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5261,14 +5261,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");
}
Expand Down Expand Up @@ -6966,12 +6966,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) ",
Expand Down Expand Up @@ -10255,7 +10255,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)
Expand All @@ -10267,7 +10267,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");

Expand Down

0 comments on commit 3012cda

Please sign in to comment.