From nobody Mon Feb 9 01:01:22 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1638282791; cv=none; d=zohomail.com; s=zohoarc; b=V7IBjaZ7+0wAZKONLLlt+rA4mJEpDuPVRQahMIar6+UjGgXXf46QqM8sHMfb74LPZaFHqe9YX0vki9XRUzwOn9HbcBv+rY6lwMp7px7S7vl5YcspJsF8SUPzPPgPL9g7aPzROl+d/e07Vow+OKdIZOG/tTAUVejygPRFMzsylIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638282791; 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=AWCL7LP2iTqSDVo2iHTrFd6z7tLa256yJqWQMLqKFso=; b=ffbX9t+5geuEPO/Wv8aYDYNAuM/pqfjSVkOWES+5a1RQb5V9MmN36C+DubV2j11Bwyu8UZ5L2+P0Ogi46W7u2aXD5j6rWPHEHceacsN6pP647JDG9fmWayHMuxYfKUk48po1h/G1nn2+BNwx4cn7kieDyAsGIIXF0l522dJKLXw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 163828279159240.47225899574755; Tue, 30 Nov 2021 06:33:11 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-186-60VZMzaoNYWKyRpvzNOHSA-1; Tue, 30 Nov 2021 09:33:08 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF63083DD23; Tue, 30 Nov 2021 14:33:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C075D7945B; Tue, 30 Nov 2021 14:33:03 +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 9312D4A70F; Tue, 30 Nov 2021 14:33:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AUEX2xI022684 for ; Tue, 30 Nov 2021 09:33:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7EC8250306; Tue, 30 Nov 2021 14:33:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6DDE60FDD for ; Tue, 30 Nov 2021 14:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638282790; 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=AWCL7LP2iTqSDVo2iHTrFd6z7tLa256yJqWQMLqKFso=; b=ASQUkf2p911yxjhmCnQPoIgpeI600l1HGej7S8F3L2i5RJQU4IfStWHILqrHkiJZFy0fVO 0zX3u1VTjtUDHBaabA5XcPyfv/0HGKn+1/vXVzVOAVfVCqPsb+8e8rViaYV+jMawTNgO49 tdHdEf/TYqnRK5QecgIi4OtQ0JYzoBg= X-MC-Unique: 60VZMzaoNYWKyRpvzNOHSA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/23] qemuDomainBlocksStatsGather: Automatically free GHashTable and refactor cleanup Date: Tue, 30 Nov 2021 15:31:51 +0100 Message-Id: <528021af98adf97cca34e559afee062d6be7c077.1638282671.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.16 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: 1638282792832100001 Content-Type: text/plain; charset="utf-8" No need for the cleanup section once we switch to g_autoptr. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4e680bc0a7..5330a1d3b7 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9975,24 +9975,23 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, qemuDomainObjPrivate *priv =3D vm->privateData; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); virDomainDiskDef *disk =3D NULL; - GHashTable *blockstats =3D NULL; + g_autoptr(GHashTable) blockstats =3D NULL; qemuBlockStats *stats; size_t i; int nstats; int rc =3D 0; const char *entryname =3D NULL; - int ret =3D -1; if (*path) { if (!(disk =3D virDomainDiskByName(vm->def, path, false))) { virReportError(VIR_ERR_INVALID_ARG, _("invalid path: %s"), pat= h); - goto cleanup; + return -1; } if (virStorageSourceGetActualType(disk->src) =3D=3D VIR_STORAGE_TY= PE_VHOST_USER) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("block stats are not supported for vhostuser = disk")); - goto cleanup; + return -1; } if (blockdev && QEMU_DOMAIN_DISK_PRIVATE(disk)->qomName) { @@ -10001,7 +10000,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!disk->info.alias) { virReportError(VIR_ERR_INTERNAL_ERROR, _("missing disk device alias name for %s"),= disk->dst); - goto cleanup; + return -1; } entryname =3D disk->info.alias; @@ -10019,7 +10018,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, } if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0 || rc < 0) - goto cleanup; + return -1; *retstats =3D g_new0(qemuBlockStats, 1); @@ -10027,7 +10026,7 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!(stats =3D virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find statistics for device '%s'"), en= tryname); - goto cleanup; + return -1; } **retstats =3D *stats; @@ -10063,18 +10062,14 @@ qemuDomainBlocksStatsGather(virQEMUDriver *driver, if (!(stats =3D virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot find statistics for device '%s'")= , entryname); - goto cleanup; + return -1; } qemuDomainBlockStatsGatherTotals(stats, *retstats); } } - ret =3D nstats; - - cleanup: - virHashFree(blockstats); - return ret; + return nstats; } --=20 2.31.1