aboutsummaryrefslogtreecommitdiff
path: root/hw/smbios
diff options
context:
space:
mode:
authorAni Sinha <anisinha@redhat.com>2023-09-22 18:12:02 +0530
committerMarkus Armbruster <armbru@redhat.com>2023-09-29 10:07:18 +0200
commit7b393b71424ba105f2b1c5f2c49f8d8710ad00eb (patch)
tree02e67f8160cfe31d2e115f4925ad8ef9996a0077 /hw/smbios
parentd8573092a49b3133530ceee35846a54e600f8a73 (diff)
hw/acpi: changes towards enabling -Wshadow=local
Code changes in acpi 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 The code is tested to build with and without the flag turned on. CC: Markus Armbruster <armbru@redhat.com> CC: Philippe Mathieu-Daude <philmd@linaro.org> CC: mst@redhat.com CC: imammedo@redhat.com Signed-off-by: Ani Sinha <anisinha@redhat.com> Message-ID: <20230922124203.127110-1-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'hw/smbios')
-rw-r--r--hw/smbios/smbios.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b753705856..2a90601ac5 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -1423,13 +1423,14 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
if (!qemu_opts_validate(opts, qemu_smbios_type8_opts, errp)) {
return;
}
- struct type8_instance *t;
- t = g_new0(struct type8_instance, 1);
- save_opt(&t->internal_reference, opts, "internal_reference");
- save_opt(&t->external_reference, opts, "external_reference");
- t->connector_type = qemu_opt_get_number(opts, "connector_type", 0);
- t->port_type = qemu_opt_get_number(opts, "port_type", 0);
- QTAILQ_INSERT_TAIL(&type8, t, next);
+ struct type8_instance *t8_i;
+ t8_i = g_new0(struct type8_instance, 1);
+ save_opt(&t8_i->internal_reference, opts, "internal_reference");
+ save_opt(&t8_i->external_reference, opts, "external_reference");
+ t8_i->connector_type = qemu_opt_get_number(opts,
+ "connector_type", 0);
+ t8_i->port_type = qemu_opt_get_number(opts, "port_type", 0);
+ QTAILQ_INSERT_TAIL(&type8, t8_i, next);
return;
case 11:
if (!qemu_opts_validate(opts, qemu_smbios_type11_opts, errp)) {
@@ -1452,27 +1453,27 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
type17.speed = qemu_opt_get_number(opts, "speed", 0);
return;
case 41: {
- struct type41_instance *t;
+ struct type41_instance *t41_i;
Error *local_err = NULL;
if (!qemu_opts_validate(opts, qemu_smbios_type41_opts, errp)) {
return;
}
- t = g_new0(struct type41_instance, 1);
- save_opt(&t->designation, opts, "designation");
- t->kind = qapi_enum_parse(&type41_kind_lookup,
- qemu_opt_get(opts, "kind"),
- 0, &local_err) + 1;
- t->kind |= 0x80; /* enabled */
+ t41_i = g_new0(struct type41_instance, 1);
+ save_opt(&t41_i->designation, opts, "designation");
+ t41_i->kind = qapi_enum_parse(&type41_kind_lookup,
+ qemu_opt_get(opts, "kind"),
+ 0, &local_err) + 1;
+ t41_i->kind |= 0x80; /* enabled */
if (local_err != NULL) {
error_propagate(errp, local_err);
- g_free(t);
+ g_free(t41_i);
return;
}
- t->instance = qemu_opt_get_number(opts, "instance", 1);
- save_opt(&t->pcidev, opts, "pcidev");
+ t41_i->instance = qemu_opt_get_number(opts, "instance", 1);
+ save_opt(&t41_i->pcidev, opts, "pcidev");
- QTAILQ_INSERT_TAIL(&type41, t, next);
+ QTAILQ_INSERT_TAIL(&type41, t41_i, next);
return;
}
default: