diff mbox series

[v2,3/6] hw/display/vga: Clean up global variable shadowing

Message ID 20231010115048.11856-4-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
Rename 'address_space' -> 'legacy_io' and
'address_space_io' -> 'io' to fix:

  hw/display/vga.c:2307:29: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
                MemoryRegion *address_space_io, bool init_vga_ports)
                            ^
  include/exec/address-spaces.h:35:21: note: previous declaration is here
  extern AddressSpace address_space_io;
                      ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/display/vga_int.h |  4 ++--
 hw/display/vga.c     | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Ani Sinha Oct. 10, 2023, 12:46 p.m. UTC | #1
> On 10-Oct-2023, at 5:20 PM, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> 
> Rename 'address_space' -> 'legacy_io' and
> 'address_space_io' -> 'io' to fix:

This works but why not replace address_space with legacy_address_space instead?

> 
>  hw/display/vga.c:2307:29: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>                MemoryRegion *address_space_io, bool init_vga_ports)
>                            ^
>  include/exec/address-spaces.h:35:21: note: previous declaration is here
>  extern AddressSpace address_space_io;
>                      ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/display/vga_int.h |  4 ++--
> hw/display/vga.c     | 12 ++++++------
> 2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
> index 7cf0d11201..0f5db522c2 100644
> --- a/hw/display/vga_int.h
> +++ b/hw/display/vga_int.h
> @@ -157,8 +157,8 @@ static inline int c6_to_8(int v)
> }
> 
> bool vga_common_init(VGACommonState *s, Object *obj, Error **errp);
> -void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
> -              MemoryRegion *address_space_io, bool init_vga_ports);
> +void vga_init(VGACommonState *s, Object *obj,
> +              MemoryRegion *legacy_io, MemoryRegion *io, bool init_vga_ports);
> MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,
>                           const MemoryRegionPortio **vga_ports,
>                           const MemoryRegionPortio **vbe_ports);
> diff --git a/hw/display/vga.c b/hw/display/vga.c
> index 37557c3442..4dc6535ae5 100644
> --- a/hw/display/vga.c
> +++ b/hw/display/vga.c
> @@ -2303,8 +2303,8 @@ MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,
>     return vga_mem;
> }
> 
> -void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
> -              MemoryRegion *address_space_io, bool init_vga_ports)
> +void vga_init(VGACommonState *s, Object *obj,
> +              MemoryRegion *legacy_io, MemoryRegion *io, bool init_vga_ports)
> {
>     MemoryRegion *vga_io_memory;
>     const MemoryRegionPortio *vga_ports, *vbe_ports;
> @@ -2313,10 +2313,10 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
> 
>     s->bank_offset = 0;
> 
> -    s->legacy_address_space = address_space;
> +    s->legacy_address_space = legacy_io;
> 
>     vga_io_memory = vga_init_io(s, obj, &vga_ports, &vbe_ports);
> -    memory_region_add_subregion_overlap(address_space,
> +    memory_region_add_subregion_overlap(legacy_io,
>                                         0x000a0000,
>                                         vga_io_memory,
>                                         1);
> @@ -2324,10 +2324,10 @@ void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
>     if (init_vga_ports) {
>         portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga");
>         portio_list_set_flush_coalesced(&s->vga_port_list);
> -        portio_list_add(&s->vga_port_list, address_space_io, 0x3b0);
> +        portio_list_add(&s->vga_port_list, io, 0x3b0);
>     }
>     if (vbe_ports) {
>         portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe");
> -        portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce);
> +        portio_list_add(&s->vbe_port_list, io, 0x1ce);
>     }
> }
> -- 
> 2.41.0
>
Philippe Mathieu-Daudé Oct. 10, 2023, 12:50 p.m. UTC | #2
On 10/10/23 14:46, Ani Sinha wrote:
> 
> 
>> On 10-Oct-2023, at 5:20 PM, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Rename 'address_space' -> 'legacy_io' and
>> 'address_space_io' -> 'io' to fix:
> 
> This works but why not replace address_space with legacy_address_space instead?

I'd rather avoid using 'address_space' for MemoryRegion, since we
also have an AddressSpace type.

Besides, both regions are mapped in I/O space.

> 
>>
>>   hw/display/vga.c:2307:29: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>>                 MemoryRegion *address_space_io, bool init_vga_ports)
>>                             ^
>>   include/exec/address-spaces.h:35:21: note: previous declaration is here
>>   extern AddressSpace address_space_io;
>>                       ^
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> hw/display/vga_int.h |  4 ++--
>> hw/display/vga.c     | 12 ++++++------
>> 2 files changed, 8 insertions(+), 8 deletions(-)
Philippe Mathieu-Daudé Oct. 10, 2023, 12:51 p.m. UTC | #3
On 10/10/23 14:50, Philippe Mathieu-Daudé wrote:
> On 10/10/23 14:46, Ani Sinha wrote:
>>
>>
>>> On 10-Oct-2023, at 5:20 PM, Philippe Mathieu-Daudé 
>>> <philmd@linaro.org> wrote:
>>>
>>> Rename 'address_space' -> 'legacy_io' and
>>> 'address_space_io' -> 'io' to fix:
>>
>> This works but why not replace address_space with legacy_address_space 
>> instead?
> 
> I'd rather avoid using 'address_space' for MemoryRegion, since we
> also have an AddressSpace type.
> 
> Besides, both regions are mapped in I/O space.

That said, I should clarify that in the patch description.

> 
>>
>>>
>>>   hw/display/vga.c:2307:29: error: declaration shadows a variable in 
>>> the global scope [-Werror,-Wshadow]
>>>                 MemoryRegion *address_space_io, bool init_vga_ports)
>>>                             ^
>>>   include/exec/address-spaces.h:35:21: note: previous declaration is 
>>> here
>>>   extern AddressSpace address_space_io;
>>>                       ^
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> hw/display/vga_int.h |  4 ++--
>>> hw/display/vga.c     | 12 ++++++------
>>> 2 files changed, 8 insertions(+), 8 deletions(-)
>
diff mbox series

Patch

diff --git a/hw/display/vga_int.h b/hw/display/vga_int.h
index 7cf0d11201..0f5db522c2 100644
--- a/hw/display/vga_int.h
+++ b/hw/display/vga_int.h
@@ -157,8 +157,8 @@  static inline int c6_to_8(int v)
 }
 
 bool vga_common_init(VGACommonState *s, Object *obj, Error **errp);
-void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
-              MemoryRegion *address_space_io, bool init_vga_ports);
+void vga_init(VGACommonState *s, Object *obj,
+              MemoryRegion *legacy_io, MemoryRegion *io, bool init_vga_ports);
 MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,
                           const MemoryRegionPortio **vga_ports,
                           const MemoryRegionPortio **vbe_ports);
diff --git a/hw/display/vga.c b/hw/display/vga.c
index 37557c3442..4dc6535ae5 100644
--- a/hw/display/vga.c
+++ b/hw/display/vga.c
@@ -2303,8 +2303,8 @@  MemoryRegion *vga_init_io(VGACommonState *s, Object *obj,
     return vga_mem;
 }
 
-void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
-              MemoryRegion *address_space_io, bool init_vga_ports)
+void vga_init(VGACommonState *s, Object *obj,
+              MemoryRegion *legacy_io, MemoryRegion *io, bool init_vga_ports)
 {
     MemoryRegion *vga_io_memory;
     const MemoryRegionPortio *vga_ports, *vbe_ports;
@@ -2313,10 +2313,10 @@  void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
 
     s->bank_offset = 0;
 
-    s->legacy_address_space = address_space;
+    s->legacy_address_space = legacy_io;
 
     vga_io_memory = vga_init_io(s, obj, &vga_ports, &vbe_ports);
-    memory_region_add_subregion_overlap(address_space,
+    memory_region_add_subregion_overlap(legacy_io,
                                         0x000a0000,
                                         vga_io_memory,
                                         1);
@@ -2324,10 +2324,10 @@  void vga_init(VGACommonState *s, Object *obj, MemoryRegion *address_space,
     if (init_vga_ports) {
         portio_list_init(&s->vga_port_list, obj, vga_ports, s, "vga");
         portio_list_set_flush_coalesced(&s->vga_port_list);
-        portio_list_add(&s->vga_port_list, address_space_io, 0x3b0);
+        portio_list_add(&s->vga_port_list, io, 0x3b0);
     }
     if (vbe_ports) {
         portio_list_init(&s->vbe_port_list, obj, vbe_ports, s, "vbe");
-        portio_list_add(&s->vbe_port_list, address_space_io, 0x1ce);
+        portio_list_add(&s->vbe_port_list, io, 0x1ce);
     }
 }