From patchwork Fri Apr 18 13:41:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Batuzov X-Patchwork-Id: 340310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E08E01400F7 for ; Fri, 18 Apr 2014 23:42:31 +1000 (EST) Received: from localhost ([::1]:37989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wb93l-0002UP-MY for incoming@patchwork.ozlabs.org; Fri, 18 Apr 2014 09:42:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57142) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wb93F-0001kb-GY for qemu-devel@nongnu.org; Fri, 18 Apr 2014 09:42:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wb938-0003Ui-B6 for qemu-devel@nongnu.org; Fri, 18 Apr 2014 09:41:57 -0400 Received: from smtp.ispras.ru ([83.149.199.79]:44888) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wb938-0003QG-3U for qemu-devel@nongnu.org; Fri, 18 Apr 2014 09:41:50 -0400 Received: from bulbul.intra.ispras.ru (unknown [83.149.199.91]) by smtp.ispras.ru (Postfix) with ESMTP id 702F4224AF; Thu, 17 Apr 2014 09:21:33 +0400 (MSK) From: Kirill Batuzov To: qemu-devel@nongnu.org Date: Fri, 18 Apr 2014 17:41:21 +0400 Message-Id: <1397828484-21771-2-git-send-email-batuzovk@ispras.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1397828484-21771-1-git-send-email-batuzovk@ispras.ru> References: <1397828484-21771-1-git-send-email-batuzovk@ispras.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.79 Cc: Kirill Batuzov Subject: [Qemu-devel] [PATCH 1/4] Replace acpi_pcihp_get_bsel with generic object_property_get_int X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Replacing it with generic object_property_get_int serves two purposes: reducing code duplication and fixing memory leak. Signed-off-by: Kirill Batuzov --- hw/acpi/pcihp.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index f80c480..ff44aec 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -61,24 +61,11 @@ typedef struct AcpiPciHpFind { PCIBus *bus; } 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) { - return -1; - } - return bsel; -} - static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find = opaque; - if (find->bsel == acpi_pcihp_get_bsel(bus)) { + if (find->bsel == object_property_get_int(OBJECT(bus), + ACPI_PCIHP_PROP_BSEL, NULL)) { find->bus = bus; } } @@ -185,7 +172,8 @@ void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); - int bsel = acpi_pcihp_get_bsel(pdev->bus); + int bsel = object_property_get_int(OBJECT(pdev->bus), + ACPI_PCIHP_PROP_BSEL, NULL); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set"); @@ -210,7 +198,8 @@ void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, { PCIDevice *pdev = PCI_DEVICE(dev); int slot = PCI_SLOT(pdev->devfn); - int bsel = acpi_pcihp_get_bsel(pdev->bus); + int bsel = object_property_get_int(OBJECT(pdev->bus), + ACPI_PCIHP_PROP_BSEL, NULL); if (bsel < 0) { error_setg(errp, "Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set");