[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 ma
From: |
Markus Armbruster |
Subject: |
[PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines |
Date: |
Fri, 6 Oct 2023 13:36:29 +0200 |
From: Ani Sinha <anisinha@redhat.com>
Code changes that addresses all compiler complaints coming from enabling
-Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing
other local variables or parameters. These makes the code confusing and/or adds
bugs that are difficult to catch.
See also
Subject: Help wanted for enabling -Wshadow=local
Message-Id: <87r0mqlf9x.fsf@pond.sub.org>
https://lore.kernel.org/qemu-devel/87r0mqlf9x.fsf@pond.sub.org
CC: Markus Armbruster <armbru@redhat.com>
CC: Philippe Mathieu-Daude <philmd@linaro.org>
CC: mst@redhat.com
Signed-off-by: Ani Sinha <anisinha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-ID: <20231003102803.6163-1-anisinha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
hw/i386/acpi-microvm.c | 4 ++--
hw/i386/pc.c | 1 -
hw/i386/x86.c | 2 --
3 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c
index fec22d85c1..2909a73933 100644
--- a/hw/i386/acpi-microvm.c
+++ b/hw/i386/acpi-microvm.c
@@ -55,8 +55,8 @@ static void acpi_dsdt_add_virtio(Aml *scope,
bus = sysbus_get_default();
QTAILQ_FOREACH(kid, &bus->children, sibling) {
- DeviceState *dev = kid->child;
- Object *obj = object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MMIO);
+ Object *obj = object_dynamic_cast(OBJECT(kid->child),
+ TYPE_VIRTIO_MMIO);
if (obj) {
VirtIOMMIOProxy *mmio = VIRTIO_MMIO(obj);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index aad7e8ccd1..bb3854d1d0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1049,7 +1049,6 @@ void pc_memory_init(PCMachineState *pcms,
if (machine->device_memory) {
uint64_t *val = g_malloc(sizeof(*val));
- PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
uint64_t res_mem_end = machine->device_memory->base;
if (!pcmc->broken_reserved_end) {
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index f034df8bf6..b3d054889b 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -365,8 +365,6 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
cpu_slot = x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx);
if (!cpu_slot) {
- MachineState *ms = MACHINE(x86ms);
-
x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids);
error_setg(errp,
"Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with"
--
2.41.0
- [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path(), (continued)
- [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path(), Markus Armbruster, 2023/10/06
- [PULL 25/32] trace/control: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 28/32] linux-user/flatload: clean up local variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 17/32] qom/object_interfaces: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 24/32] sysemu/tpm: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 30/32] linux-user/syscall.c: clean up local variable shadowing in do_ioctl_dm(), Markus Armbruster, 2023/10/06
- [PULL 02/32] target/loongarch: Clean up local variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 11/32] hw/ide/ahci: Clean up local variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 23/32] softmmu/vl: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 08/32] hw/virtio/vhost: Silence compiler warnings in vhost code when using -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 04/32] hw/i386: changes towards enabling -Wshadow=local for x86 machines,
Markus Armbruster <=
- [PULL 15/32] qemu-img: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- Re: [PULL 00/32] -Wshadow=local patches patches for 2023-10-06, Stefan Hajnoczi, 2023/10/09