* [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
@ 2020-11-07 19:40 Philippe Mathieu-Daudé
2020-11-08 3:58 ` Ani Sinha
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-07 19:40 UTC (permalink / raw)
To: qemu-devel
Cc: Eduardo Habkost, Michael S. Tsirkin, Igor Mammedov, Ani Sinha,
Paolo Bonzini, Philippe Mathieu-Daudé, Richard Henderson
GCC 9.3.0 thinks that 'method' can be left uninitialized. This code
is already in the "if (bsel || pcihp_bridge_en)" block statement,
but it isn't smart enough to figure it out.
Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)"
block statement to fix (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")
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
hw/i386/acpi-build.c | 45 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 24 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4f66642d887..1f5c2112452 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
*/
if (bsel || pcihp_bridge_en) {
method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
- }
- /* If bus supports hotplug select it and notify about local events */
- if (bsel) {
- uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
- aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
- aml_append(method,
- aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check */)
- );
- aml_append(method,
- aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request */)
- );
- }
+ /* If bus supports hotplug select it and notify about local events */
+ if (bsel) {
+ uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
- /* Notify about child bus events in any case */
- if (pcihp_bridge_en) {
- QLIST_FOREACH(sec, &bus->child, sibling) {
- int32_t devfn = sec->parent_dev->devfn;
-
- if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
- continue;
- }
-
- aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+ aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
+ aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
+ aml_int(1))); /* Device Check */
+ aml_append(method, aml_call2("DVNT", aml_name("PCID"),
+ aml_int(3))); /* Eject Request */
+ }
+
+ /* Notify about child bus events in any case */
+ if (pcihp_bridge_en) {
+ QLIST_FOREACH(sec, &bus->child, sibling) {
+ int32_t devfn = sec->parent_dev->devfn;
+
+ if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
+ continue;
+ }
+
+ aml_append(method, aml_name("^S%.02X.PCNT", devfn));
+ }
}
- }
- if (bsel || pcihp_bridge_en) {
aml_append(parent_scope, method);
}
qobject_unref(bsel);
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
2020-11-07 19:40 [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off Philippe Mathieu-Daudé
@ 2020-11-08 3:58 ` Ani Sinha
2020-11-08 17:10 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Ani Sinha @ 2020-11-08 3:58 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, Michael S. Tsirkin, QEMU Developers,
Igor Mammedov, Paolo Bonzini, Richard Henderson
On Sun, Nov 8, 2020 at 1:10 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> GCC 9.3.0 thinks that 'method' can be left uninitialized. This code
> is already in the "if (bsel || pcihp_bridge_en)" block statement,
> but it isn't smart enough to figure it out.
>
> Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)"
> block statement to fix (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
OK I looked at the patch closely and it makes sense. Can you please
run a "make check" to make sure we have not broken anything?
>
> Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off globally")
Acked-by: Ani Sinha <ani@anisinha.ca>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/i386/acpi-build.c | 45 +++++++++++++++++++++-----------------------
> 1 file changed, 21 insertions(+), 24 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 4f66642d887..1f5c2112452 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
> */
> if (bsel || pcihp_bridge_en) {
> method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
> - }
> - /* If bus supports hotplug select it and notify about local events */
> - if (bsel) {
> - uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>
> - aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> - aml_append(method,
> - aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check */)
> - );
> - aml_append(method,
> - aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request */)
> - );
> - }
> + /* If bus supports hotplug select it and notify about local events */
> + if (bsel) {
> + uint64_t bsel_val = qnum_get_uint(qobject_to(QNum, bsel));
>
> - /* Notify about child bus events in any case */
> - if (pcihp_bridge_en) {
> - QLIST_FOREACH(sec, &bus->child, sibling) {
> - int32_t devfn = sec->parent_dev->devfn;
> -
> - if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
> - continue;
> - }
> -
> - aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> + aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM")));
> + aml_append(method, aml_call2("DVNT", aml_name("PCIU"),
> + aml_int(1))); /* Device Check */
> + aml_append(method, aml_call2("DVNT", aml_name("PCID"),
> + aml_int(3))); /* Eject Request */
> + }
> +
> + /* Notify about child bus events in any case */
> + if (pcihp_bridge_en) {
> + QLIST_FOREACH(sec, &bus->child, sibling) {
> + int32_t devfn = sec->parent_dev->devfn;
> +
> + if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) {
> + continue;
> + }
> +
> + aml_append(method, aml_name("^S%.02X.PCNT", devfn));
> + }
> }
> - }
>
> - if (bsel || pcihp_bridge_en) {
> aml_append(parent_scope, method);
> }
> qobject_unref(bsel);
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
2020-11-08 3:58 ` Ani Sinha
@ 2020-11-08 17:10 ` Philippe Mathieu-Daudé
2020-11-12 3:51 ` Ani Sinha
0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-11-08 17:10 UTC (permalink / raw)
To: Ani Sinha
Cc: Eduardo Habkost, Michael S. Tsirkin, QEMU Developers,
Igor Mammedov, Paolo Bonzini, Richard Henderson
On 11/8/20 4:58 AM, Ani Sinha wrote:
> On Sun, Nov 8, 2020 at 1:10 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>>
>> GCC 9.3.0 thinks that 'method' can be left uninitialized. This code
>> is already in the "if (bsel || pcihp_bridge_en)" block statement,
>> but it isn't smart enough to figure it out.
>>
>> Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)"
>> block statement to fix (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
>
> OK I looked at the patch closely and it makes sense. Can you please
> run a "make check" to make sure we have not broken anything?
Yes I did...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
2020-11-08 17:10 ` Philippe Mathieu-Daudé
@ 2020-11-12 3:51 ` Ani Sinha
2020-11-12 9:02 ` Michael S. Tsirkin
0 siblings, 1 reply; 5+ messages in thread
From: Ani Sinha @ 2020-11-12 3:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Eduardo Habkost, Michael S. Tsirkin, QEMU Developers,
Paolo Bonzini, Igor Mammedov, Richard Henderson
[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]
On Sun, Nov 8, 2020 at 22:40 Philippe Mathieu-Daudé <philmd@redhat.com>
wrote:
> On 11/8/20 4:58 AM, Ani Sinha wrote:
> > On Sun, Nov 8, 2020 at 1:10 AM Philippe Mathieu-Daudé <philmd@redhat.com>
> wrote:
> >>
> >> GCC 9.3.0 thinks that 'method' can be left uninitialized. This code
> >> is already in the "if (bsel || pcihp_bridge_en)" block statement,
> >> but it isn't smart enough to figure it out.
> >>
> >> Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)"
> >> block statement to fix (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
> >
> > OK I looked at the patch closely and it makes sense. Can you please
> > run a "make check" to make sure we have not broken anything?
>
> Yes I did...
Has this been queued Michael?
>
>
[-- Attachment #2: Type: text/html, Size: 1868 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
2020-11-12 3:51 ` Ani Sinha
@ 2020-11-12 9:02 ` Michael S. Tsirkin
0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2020-11-12 9:02 UTC (permalink / raw)
To: Ani Sinha
Cc: Eduardo Habkost, QEMU Developers, Paolo Bonzini, Igor Mammedov,
Philippe Mathieu-Daudé, Richard Henderson
On Thu, Nov 12, 2020 at 09:21:47AM +0530, Ani Sinha wrote:
>
>
> On Sun, Nov 8, 2020 at 22:40 Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> On 11/8/20 4:58 AM, Ani Sinha wrote:
> > On Sun, Nov 8, 2020 at 1:10 AM Philippe Mathieu-Daudé <philmd@redhat.com>
> wrote:
> >>
> >> GCC 9.3.0 thinks that 'method' can be left uninitialized. This code
> >> is already in the "if (bsel || pcihp_bridge_en)" block statement,
> >> but it isn't smart enough to figure it out.
> >>
> >> Restrict the code to be used only in the "if (bsel || pcihp_bridge_en)"
> >> block statement to fix (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
> >
> > OK I looked at the patch closely and it makes sense. Can you please
> > run a "make check" to make sure we have not broken anything?
>
> Yes I did...
>
>
> Has this been queued Michael?
tagged, thanks!
>
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-12 9:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-07 19:40 [PATCH-for-5.2 v2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off Philippe Mathieu-Daudé
2020-11-08 3:58 ` Ani Sinha
2020-11-08 17:10 ` Philippe Mathieu-Daudé
2020-11-12 3:51 ` Ani Sinha
2020-11-12 9:02 ` Michael S. Tsirkin
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).