[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 01/11] acpi/pcihp.c: Rewrite acpi_pcihp_get_bsel u
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 01/11] acpi/pcihp.c: Rewrite acpi_pcihp_get_bsel using object_property_get_int |
Date: |
Wed, 7 May 2014 19:16:52 +0300 |
From: Kirill Batuzov <address@hidden>
acpi_pcihp_get_bsel implements functionality of object_property_get_int for
specific property named ACPI_PCIHP_PROP_BSEL, but fails to decrement object's
reference counter properly. Rewriting it using generic object_property_get_int
serves two purposes: reducing code duplication and fixing memory leak.
Signed-off-by: Kirill Batuzov <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/acpi/pcihp.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index f80c480..3b143b3 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -63,16 +63,18 @@ typedef struct AcpiPciHpFind {
static int acpi_pcihp_get_bsel(PCIBus *bus)
{
- QObject *o = object_property_get_qobject(OBJECT(bus),
- ACPI_PCIHP_PROP_BSEL, NULL);
- int64_t bsel = -1;
- if (o) {
- bsel = qint_get_int(qobject_to_qint(o));
- }
- if (bsel < 0) {
+ Error *local_err = NULL;
+ int64_t bsel = object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+ &local_err);
+
+ if (local_err || bsel < 0 || bsel >= ACPI_PCIHP_MAX_HOTPLUG_BUS) {
+ if (local_err) {
+ error_free(local_err);
+ }
return -1;
+ } else {
+ return bsel;
}
- return bsel;
}
static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque)
--
MST
- [Qemu-devel] [PULL v2 00/11] pc,net,MAINTAINERS,build updates, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 01/11] acpi/pcihp.c: Rewrite acpi_pcihp_get_bsel using object_property_get_int,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 02/11] acpi-build: properly decrement objects' reference counters, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 03/11] acpi: fix tables for no-hpet configuration, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 05/11] pc: add compat_props placeholder for 2.0 machine type, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 04/11] i8259: don't abort when trying to use level sensitive irqs, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 07/11] smbus: allow returning an error from reads, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 06/11] apic: use emulated lapic version 0x14 on pc machines >= 2.1, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 08/11] smbus: return -1 if nothing found at the given address, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 09/11] pm_smbus: correctly report unclaimed cycles, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 10/11] MAINTAINERS: addresses for responsible disclosure, Michael S. Tsirkin, 2014/05/07
- [Qemu-devel] [PULL v2 11/11] configure: make source tree build more robust, Michael S. Tsirkin, 2014/05/07