diff mbox series

[v2,2/6] hw/loader: Clean up global variable shadowing in rom_add_file()

Message ID 20231010115048.11856-3-philmd@linaro.org
State New
Headers show
Series hw: Clean up global variables shadowing | expand

Commit Message

Philippe Mathieu-Daudé Oct. 10, 2023, 11:50 a.m. UTC
Invert 'option_rom' logic and rename it as 'option_rom_has_mr' to fix:

  hw/core/loader.c:1073:27: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
                       bool option_rom, MemoryRegion *mr,
                            ^
  include/sysemu/sysemu.h:57:22: note: previous declaration is here
  extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
                       ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/loader.h | 11 ++++++-----
 hw/core/loader.c    | 10 +++++-----
 2 files changed, 11 insertions(+), 10 deletions(-)

Comments

Ani Sinha Oct. 10, 2023, 12:54 p.m. UTC | #1
> On 10-Oct-2023, at 5:20 PM, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 
> Invert 'option_rom' logic and rename it as 'option_rom_has_mr' to fix:
> 
>  hw/core/loader.c:1073:27: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>                       bool option_rom, MemoryRegion *mr,
>                            ^
>  include/sysemu/sysemu.h:57:22: note: previous declaration is here
>  extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
>                       ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Ani Sinha <anisinha@redhat.com>

> ---
> include/hw/loader.h | 11 ++++++-----
> hw/core/loader.c    | 10 +++++-----
> 2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/include/hw/loader.h b/include/hw/loader.h
> index c4c14170ea..9dbb9f7fdb 100644
> --- a/include/hw/loader.h
> +++ b/include/hw/loader.h
> @@ -272,7 +272,8 @@ void pstrcpy_targphys(const char *name,
> 
> ssize_t rom_add_file(const char *file, const char *fw_dir,
>                      hwaddr addr, int32_t bootindex,
> -                     bool option_rom, MemoryRegion *mr, AddressSpace *as);
> +                     bool option_rom_has_mr,
> +                     MemoryRegion *mr, AddressSpace *as);
> MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
>                            size_t max_len, hwaddr addr,
>                            const char *fw_file_name,
> @@ -341,15 +342,15 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size);
> void hmp_info_roms(Monitor *mon, const QDict *qdict);
> 
> #define rom_add_file_fixed(_f, _a, _i)          \
> -    rom_add_file(_f, NULL, _a, _i, false, NULL, NULL)
> +    rom_add_file(_f, NULL, _a, _i, true, NULL, NULL)
> #define rom_add_blob_fixed(_f, _b, _l, _a)      \
>     rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, NULL, true)
> #define rom_add_file_mr(_f, _mr, _i)            \
> -    rom_add_file(_f, NULL, 0, _i, false, _mr, NULL)
> +    rom_add_file(_f, NULL, 0, _i, true, _mr, NULL)
> #define rom_add_file_as(_f, _as, _i)            \
> -    rom_add_file(_f, NULL, 0, _i, false, NULL, _as)
> +    rom_add_file(_f, NULL, 0, _i, true, NULL, _as)
> #define rom_add_file_fixed_as(_f, _a, _i, _as)          \
> -    rom_add_file(_f, NULL, _a, _i, false, NULL, _as)
> +    rom_add_file(_f, NULL, _a, _i, true, NULL, _as)
> #define rom_add_blob_fixed_as(_f, _b, _l, _a, _as)      \
>     rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, _as, true)
> 
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 4dd5a71fb7..f0d20fd776 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -1070,8 +1070,8 @@ static void *rom_set_mr(Rom *rom, Object *owner, const char *name, bool ro)
> 
> ssize_t rom_add_file(const char *file, const char *fw_dir,
>                      hwaddr addr, int32_t bootindex,
> -                     bool option_rom, MemoryRegion *mr,
> -                     AddressSpace *as)
> +                     bool option_rom_has_mr,
> +                     MemoryRegion *mr, AddressSpace *as)
> {
>     MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
>     Rom *rom;
> @@ -1139,7 +1139,7 @@ ssize_t rom_add_file(const char *file, const char *fw_dir,
>                  basename);
>         snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
> 
> -        if ((!option_rom || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
> +        if ((option_rom_has_mr || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
>             data = rom_set_mr(rom, OBJECT(fw_cfg), devpath, true);
>         } else {
>             data = rom->data;
> @@ -1239,12 +1239,12 @@ int rom_add_elf_program(const char *name, GMappedFile *mapped_file, void *data,
> 
> ssize_t rom_add_vga(const char *file)
> {
> -    return rom_add_file(file, "vgaroms", 0, -1, true, NULL, NULL);
> +    return rom_add_file(file, "vgaroms", 0, -1, false, NULL, NULL);
> }
> 
> ssize_t rom_add_option(const char *file, int32_t bootindex)
> {
> -    return rom_add_file(file, "genroms", 0, bootindex, true, NULL, NULL);
> +    return rom_add_file(file, "genroms", 0, bootindex, false, NULL, NULL);
> }
> 
> static void rom_reset(void *unused)
> -- 
> 2.41.0
>
diff mbox series

Patch

diff --git a/include/hw/loader.h b/include/hw/loader.h
index c4c14170ea..9dbb9f7fdb 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -272,7 +272,8 @@  void pstrcpy_targphys(const char *name,
 
 ssize_t rom_add_file(const char *file, const char *fw_dir,
                      hwaddr addr, int32_t bootindex,
-                     bool option_rom, MemoryRegion *mr, AddressSpace *as);
+                     bool option_rom_has_mr,
+                     MemoryRegion *mr, AddressSpace *as);
 MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len,
                            size_t max_len, hwaddr addr,
                            const char *fw_file_name,
@@ -341,15 +342,15 @@  void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size);
 void hmp_info_roms(Monitor *mon, const QDict *qdict);
 
 #define rom_add_file_fixed(_f, _a, _i)          \
-    rom_add_file(_f, NULL, _a, _i, false, NULL, NULL)
+    rom_add_file(_f, NULL, _a, _i, true, NULL, NULL)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
     rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, NULL, true)
 #define rom_add_file_mr(_f, _mr, _i)            \
-    rom_add_file(_f, NULL, 0, _i, false, _mr, NULL)
+    rom_add_file(_f, NULL, 0, _i, true, _mr, NULL)
 #define rom_add_file_as(_f, _as, _i)            \
-    rom_add_file(_f, NULL, 0, _i, false, NULL, _as)
+    rom_add_file(_f, NULL, 0, _i, true, NULL, _as)
 #define rom_add_file_fixed_as(_f, _a, _i, _as)          \
-    rom_add_file(_f, NULL, _a, _i, false, NULL, _as)
+    rom_add_file(_f, NULL, _a, _i, true, NULL, _as)
 #define rom_add_blob_fixed_as(_f, _b, _l, _a, _as)      \
     rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, _as, true)
 
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 4dd5a71fb7..f0d20fd776 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1070,8 +1070,8 @@  static void *rom_set_mr(Rom *rom, Object *owner, const char *name, bool ro)
 
 ssize_t rom_add_file(const char *file, const char *fw_dir,
                      hwaddr addr, int32_t bootindex,
-                     bool option_rom, MemoryRegion *mr,
-                     AddressSpace *as)
+                     bool option_rom_has_mr,
+                     MemoryRegion *mr, AddressSpace *as)
 {
     MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
     Rom *rom;
@@ -1139,7 +1139,7 @@  ssize_t rom_add_file(const char *file, const char *fw_dir,
                  basename);
         snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
 
-        if ((!option_rom || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
+        if ((option_rom_has_mr || mc->option_rom_has_mr) && mc->rom_file_has_mr) {
             data = rom_set_mr(rom, OBJECT(fw_cfg), devpath, true);
         } else {
             data = rom->data;
@@ -1239,12 +1239,12 @@  int rom_add_elf_program(const char *name, GMappedFile *mapped_file, void *data,
 
 ssize_t rom_add_vga(const char *file)
 {
-    return rom_add_file(file, "vgaroms", 0, -1, true, NULL, NULL);
+    return rom_add_file(file, "vgaroms", 0, -1, false, NULL, NULL);
 }
 
 ssize_t rom_add_option(const char *file, int32_t bootindex)
 {
-    return rom_add_file(file, "genroms", 0, bootindex, true, NULL, NULL);
+    return rom_add_file(file, "genroms", 0, bootindex, false, NULL, NULL);
 }
 
 static void rom_reset(void *unused)