sim: Fix -Werror=shadow=local by changing mem to addr in sim_{read,write}

m32c/cpu.h defines mem as enum value, which causes GCC 14 to emit

sim/m32c/gdb-if.c: In function ‘sim_read’:
sim/m32c/gdb-if.c:162:33: error: declaration of ‘mem’ shadows a previous local [-Werror=shadow=local]
  162 | sim_read (SIM_DESC sd, uint64_t mem, void *buf, uint64_t length)
      |                        ~~~~~~~~~^~~
In file included from ../../binutils-gdb/sim/m32c/gdb-if.c:38:
sim/m32c/cpu.h:83:3: note: shadowed declaration is here
   83 |   mem,
      |   ^~~

Fix this by renaming mem to addr in all sim_read and sim_write functions.
Most already used addr instead of mem. In one file, sim/rx/gdb-if.c, this
also meant renaming the local addr variable to vma.
This commit is contained in:
Mark Wielaard
2024-01-22 12:58:11 +01:00
parent c2625a463f
commit cbbcd7fd10
7 changed files with 42 additions and 42 deletions

View File

@@ -227,23 +227,23 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
}
uint64_t
sim_read (SIM_DESC sd, uint64_t mem, void *buffer, uint64_t length)
sim_read (SIM_DESC sd, uint64_t addr, void *buffer, uint64_t length)
{
int i;
unsigned char *data = buffer;
check_desc (sd);
if (mem == 0)
if (addr == 0)
return 0;
execution_error_clear_last_error ();
for (i = 0; i < length; i++)
{
bfd_vma addr = mem + i;
int do_swap = addr_in_swap_list (addr);
data[i] = mem_get_qi (addr ^ (do_swap ? 3 : 0));
bfd_vma vma = addr + i;
int do_swap = addr_in_swap_list (vma);
data[i] = mem_get_qi (vma ^ (do_swap ? 3 : 0));
if (execution_error_get_last_error () != SIM_ERR_NONE)
return i;
@@ -253,7 +253,7 @@ sim_read (SIM_DESC sd, uint64_t mem, void *buffer, uint64_t length)
}
uint64_t
sim_write (SIM_DESC sd, uint64_t mem, const void *buffer, uint64_t length)
sim_write (SIM_DESC sd, uint64_t addr, const void *buffer, uint64_t length)
{
int i;
const unsigned char *data = buffer;
@@ -264,9 +264,9 @@ sim_write (SIM_DESC sd, uint64_t mem, const void *buffer, uint64_t length)
for (i = 0; i < length; i++)
{
bfd_vma addr = mem + i;
int do_swap = addr_in_swap_list (addr);
mem_put_qi (addr ^ (do_swap ? 3 : 0), data[i]);
bfd_vma vma = addr + i;
int do_swap = addr_in_swap_list (vma);
mem_put_qi (vma ^ (do_swap ? 3 : 0), data[i]);
if (execution_error_get_last_error () != SIM_ERR_NONE)
return i;