* [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off
@ 2020-11-07 15:08 Ani Sinha
2020-11-07 16:26 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Ani Sinha @ 2020-11-07 15:08 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, mst, Paolo Bonzini, Ani Sinha, Igor Mammedov,
philmd, Richard Henderson
This fixes the following warning (gcc 9.3.0 on Ubuntu):
../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices':
../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized
in this function [-Werror=maybe-uninitialized]
496 | aml_append(parent_scope, method);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")
Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
hw/i386/acpi-build.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4f66642d88..79b86d4a36 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -349,7 +349,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
bool pcihp_bridge_en)
{
- Aml *dev, *notify_method = NULL, *method;
+ Aml *dev, *notify_method = NULL, *method = NULL;
QObject *bsel;
PCIBus *sec;
int i;
@@ -492,7 +492,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
}
}
- if (bsel || pcihp_bridge_en) {
+ if (method) {
aml_append(parent_scope, method);
}
qobject_unref(bsel);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off
2020-11-07 15:08 [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off Ani Sinha
@ 2020-11-07 16:26 ` Michael S. Tsirkin
2020-11-07 17:22 ` Ani Sinha
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2020-11-07 16:26 UTC (permalink / raw)
To: Ani Sinha
Cc: Eduardo Habkost, qemu-devel, Paolo Bonzini, Igor Mammedov, philmd,
Richard Henderson
On Sat, Nov 07, 2020 at 08:38:51PM +0530, Ani Sinha wrote:
> This fixes the following warning (gcc 9.3.0 on Ubuntu):
>
> ../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices':
> ../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized
> in this function [-Werror=maybe-uninitialized]
> 496 | aml_append(parent_scope, method);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")
> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
> hw/i386/acpi-build.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 4f66642d88..79b86d4a36 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -349,7 +349,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
> static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> bool pcihp_bridge_en)
> {
> - Aml *dev, *notify_method = NULL, *method;
> + Aml *dev, *notify_method = NULL, *method = NULL;
> QObject *bsel;
> PCIBus *sec;
> int i;
> @@ -492,7 +492,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> }
> }
>
> - if (bsel || pcihp_bridge_en) {
> + if (method) {
> aml_append(parent_scope, method);
> }
> qobject_unref(bsel);
I prefer Philippe's fix I think - gcc does not warn about it but
using method when it's NULL would lead to a crash.
> --
> 2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off
2020-11-07 16:26 ` Michael S. Tsirkin
@ 2020-11-07 17:22 ` Ani Sinha
0 siblings, 0 replies; 3+ messages in thread
From: Ani Sinha @ 2020-11-07 17:22 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Eduardo Habkost, QEMU Developers, Paolo Bonzini, Igor Mammedov,
Philippe Mathieu-Daudé, Richard Henderson
On Sat, Nov 7, 2020 at 9:56 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Sat, Nov 07, 2020 at 08:38:51PM +0530, Ani Sinha wrote:
> > This fixes the following warning (gcc 9.3.0 on Ubuntu):
> >
> > ../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices':
> > ../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized
> > in this function [-Werror=maybe-uninitialized]
> > 496 | aml_append(parent_scope, method);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> >
> > Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")
> > Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> > hw/i386/acpi-build.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 4f66642d88..79b86d4a36 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -349,7 +349,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot)
> > static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> > bool pcihp_bridge_en)
> > {
> > - Aml *dev, *notify_method = NULL, *method;
> > + Aml *dev, *notify_method = NULL, *method = NULL;
> > QObject *bsel;
> > PCIBus *sec;
> > int i;
> > @@ -492,7 +492,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> > }
> > }
> >
> > - if (bsel || pcihp_bridge_en) {
> > + if (method) {
> > aml_append(parent_scope, method);
> > }
> > qobject_unref(bsel);
>
> I prefer Philippe's fix I think - gcc does not warn about it but
> using method when it's NULL would lead to a crash.
I could be wrong but I do not see a case where we are using a method
which is uninitialized first.
I did see another bug in my V1 and I fixed it in V2.
>
> > --
> > 2.25.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-07 17:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-07 15:08 [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off Ani Sinha
2020-11-07 16:26 ` Michael S. Tsirkin
2020-11-07 17:22 ` Ani Sinha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).