From nobody Fri Dec 19 06:36:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1634654673; cv=none; d=zohomail.com; s=zohoarc; b=EyTwRUL5/TZF0lUY93tfqRqSc5Z+rERQqjlcNd51y/JQiYuFrBPF3AjumwYqqoiamkv3uLwJ55sOjHQtKp8GCNcJQmWeUr2T0MhpuqZ70wvxdnzKh6+P9svgcuu510Hrjaz21DYSfEVTCJKrw72cnwVjpxlG/OIe6EV1NZaDWHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634654673; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JyqH1C5h63EfXjwV2gR2Qq3nGU7A9P1T2fwMHX56aUw=; b=fVIiPldIvZ39r7+MyqK9+Z6l7/S8bJH6tW4yGfHu3GLGJF68oqK3hy3dPlEXOuG/JUUxB/1XNhSLGu7WruSCRSmTSE/jjn4RJ9IM8Gn3hcASNM+ploZtix53aD2VvytpRwuBoKQGaiYKo+VQlkvETk9eeIVPmsc/RufbcgPeFfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1634654673843249.07981168304764; Tue, 19 Oct 2021 07:44:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-459--d_ZkTjnNVqf3zZYoTHZZw-1; Tue, 19 Oct 2021 10:44:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A47E801FCE; Tue, 19 Oct 2021 14:44:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4AD31815D; Tue, 19 Oct 2021 14:44:04 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C5D61819AC1; Tue, 19 Oct 2021 14:44:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 19JEhMtv031711 for ; Tue, 19 Oct 2021 10:43:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A65119D9F; Tue, 19 Oct 2021 14:43:22 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id BED0919C79 for ; Tue, 19 Oct 2021 14:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634654672; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JyqH1C5h63EfXjwV2gR2Qq3nGU7A9P1T2fwMHX56aUw=; b=faOwpill0n44TWvQf/XiZm1nWRO+67Hs/PKWx7oVV0BLmau5iAuk70ZFNopevBqezlU91Y QsXW20hUZ9bpNG3UOPLoq1LjYudtMhcOBE9146QWxO5mkEMY2+5xythoSfzVsHqkqmJRJ/ h9iRhqqGOR7CHSkEp3MjIH/sbj1sNic= X-MC-Unique: -d_ZkTjnNVqf3zZYoTHZZw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/8] qemuDomainGetStatsBlock: Refactor cleanup Date: Tue, 19 Oct 2021 16:43:12 +0200 Message-Id: <100e4a850d6e855761a11d3bf4225e2901203815.1634654476.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1634654675514100003 Content-Type: text/plain; charset="utf-8" Use automatic memory clearing for the temporary variables and remove the cleanup section. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index b46ee01d31..822fd99ae2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18461,11 +18461,10 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, unsigned int privflags) { size_t i; - int ret =3D -1; int rc; - GHashTable *stats =3D NULL; - GHashTable *nodestats =3D NULL; - virJSONValue *nodedata =3D NULL; + g_autoptr(GHashTable) stats =3D NULL; + g_autoptr(GHashTable) nodestats =3D NULL; + g_autoptr(virJSONValue) nodedata =3D NULL; qemuDomainObjPrivate *priv =3D dom->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); @@ -18492,7 +18491,7 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, nodedata =3D qemuMonitorQueryNamedBlockNodes(priv->mon); if (qemuDomainObjExitMonitor(driver, dom) < 0) - goto cleanup; + return -1; /* failure to retrieve stats is fine at this point */ if (rc < 0 || (fetchnodedata && !nodedata)) @@ -18501,31 +18500,26 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, if (nodedata && !(nodestats =3D qemuBlockGetNodeData(nodedata))) - goto cleanup; + return -1; /* When listing backing chains, it's easier to fix up the count * after the iteration than it is to iterate twice; but we still * want count listed first. */ count_index =3D params->npar; if (virTypedParamListAddUInt(params, 0, "block.count") < 0) - goto cleanup; + return -1; for (i =3D 0; i < dom->def->ndisks; i++) { if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, n= odestats, params, &visited, visitBacking, driver, cfg, d= om, blockdev) < 0) - goto cleanup; + return -1; } params->par[count_index].value.ui =3D visited; - ret =3D 0; - cleanup: - virHashFree(stats); - virHashFree(nodestats); - virJSONValueFree(nodedata); - return ret; + return 0; } --=20 2.31.1