From: "Michael S. Tsirkin" <mst@redhat.com>
To: Ani Sinha <ani@anisinha.ca>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
philmd@redhat.com, Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH-for-5.2] acpi-build: Fix maybe-uninitialized warning when ACPI hotplug is off
Date: Sat, 7 Nov 2020 11:26:16 -0500 [thread overview]
Message-ID: <20201107112417-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20201107150851.87008-1-ani@anisinha.ca>
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
next prev parent reply other threads:[~2020-11-07 16:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2020-11-07 17:22 ` Ani Sinha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201107112417-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=ani@anisinha.ca \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.