OSDN Git Service

hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Sat, 7 Nov 2020 19:40:45 +0000 (20:40 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 12 Nov 2020 14:19:40 +0000 (09:19 -0500)
commit727a06326c9ebf4ad8ed80eb533278bc60202804
treebedfbb39937e80130f89f81ff26adbd362137800
parentd88618f717f948d97ae6f4401b014e30d52c68ec
hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off

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>
Message-Id: <20201107194045.438027-1-philmd@redhat.com>
Acked-by: Ani Sinha <ani@anisinha.ca>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/i386/acpi-build.c