From nobody Mon Feb 9 06:02:17 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=1675354277; cv=none; d=zohomail.com; s=zohoarc; b=gvjz92OOojsFYwAi5Ek7VzUz/9SDynjXK8UX9IreYIeR2uwdR1MbKU7bBn2OpU8hQ4+iS0+P1/oCmbrmmReasCTY10cSuBjBrr4ryy/pBg4LkY7BvqsszkTVWSf8DnAi7Z0+IdJ4wd8XWZ9YUKT9gdH/YujCowu0mhIaRzSiy6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675354277; 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=0xG44Txhfm30AcGOki+QWNay1Rdbos3xcny3fCCAIsU=; b=N9m/CinGARinDM9a6MHqztPAdFhRPgPX/er8wJ7caVrdIF0Lxc7j3j4Rq+XKL4y6v8OUgPMlizKkAzJ/zhPyH7SZQ31LOwgwdAQwp/c2xjYXygRNvEiRkpdrI1BaYvAkwIQbWI+n8diw9RsWreSVsZhLQNT0zYZxZfZADVUYsWM= 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 1675354277280650.8137292789721; Thu, 2 Feb 2023 08:11:17 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-376-xafStXkRN42W6nTXmP3EzQ-1; Thu, 02 Feb 2023 11:11:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 331711064C07; Thu, 2 Feb 2023 16:10:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F0C52166B37; Thu, 2 Feb 2023 16:10:54 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 78403194658C; Thu, 2 Feb 2023 16:10:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E68A51946586 for ; Thu, 2 Feb 2023 16:10:41 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D9554404BEC2; Thu, 2 Feb 2023 16:10:41 +0000 (UTC) Received: from speedmetal.lan (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 154C2404BEC0 for ; Thu, 2 Feb 2023 16:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675354275; 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=0xG44Txhfm30AcGOki+QWNay1Rdbos3xcny3fCCAIsU=; b=E/rGi/i9UZShXJB5GjVN8bvb8PW1rVTdSIV0klL1/Isvbg4+Sk5xKkGTnsIeJG13gSKWtE 5JPK5qDfLtQMTH2yZejjhiAAKxhLME7LrxBdfQeurWpOq4vFCv/hKYU15pKZVny1DPeqCr NVS9h3IVBHT7EjGNdwApeYrh5S40A+s= X-MC-Unique: xafStXkRN42W6nTXmP3EzQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] qemuDomainGetStatsVcpu: Refactor cleanup Date: Thu, 2 Feb 2023 17:10:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1675354279367100001 Content-Type: text/plain; charset="utf-8" Automatically free 'cpuinfo' and remove the cleanup label and ret variable. 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 f3f64d3411..6154fe9bfe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17585,8 +17585,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC= _UNUSED, virDomainVcpuDef *vcpu; qemuDomainVcpuPrivate *vcpupriv; size_t i; - int ret =3D -1; - virVcpuInfoPtr cpuinfo =3D NULL; + g_autofree virVcpuInfoPtr cpuinfo =3D NULL; g_autofree unsigned long long *cpuwait =3D NULL; g_autofree unsigned long long *cpudelay =3D NULL; qemuDomainObjPrivate *priv =3D dom->privateData; @@ -17615,8 +17614,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC= _UNUSED, virDomainDefGetVcpus(dom->def), NULL, 0) < 0) { virResetLastError(); - ret =3D 0; /* it's ok to be silent and go ahead */ - goto cleanup; + return 0; } if (HAVE_JOB(privflags) && qemuDomainRefreshStatsSchema(dom) =3D=3D 0)= { @@ -17634,7 +17632,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC= _UNUSED, if (virTypedParamListAddInt(params, cpuinfo[i].state, "vcpu.%u.state", cpuinfo[i].number) < = 0) - goto cleanup; + return -1; /* stats below are available only if the VM is alive */ if (!virDomainObjIsActive(dom)) @@ -17642,15 +17640,15 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GN= UC_UNUSED, if (virTypedParamListAddULLong(params, cpuinfo[i].cpuTime, "vcpu.%u.time", cpuinfo[i].number) = < 0) - goto cleanup; + return -1; if (virTypedParamListAddULLong(params, cpuwait[i], "vcpu.%u.wait", cpuinfo[i].number) = < 0) - goto cleanup; + return -1; if (virTypedParamListAddULLong(params, cpudelay[i], "vcpu.%u.delay", cpuinfo[i].number= ) < 0) - goto cleanup; + return -1; /* state below is extracted from the individual vcpu structs */ if (!(vcpu =3D virDomainDefGetVcpu(dom->def, cpuinfo[i].number))) @@ -17663,7 +17661,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNUC= _UNUSED, vcpupriv->halted =3D=3D VIR_TR= ISTATE_BOOL_YES, "vcpu.%u.halted", cpuinfo[i].number) < 0) - goto cleanup; + return -1; } if (!queried_stats) @@ -17675,11 +17673,7 @@ qemuDomainGetStatsVcpu(virQEMUDriver *driver G_GNU= C_UNUSED, qemuDomainAddStatsFromHashTable(stats, priv->statsSchema, prefix, = params); } - ret =3D 0; - - cleanup: - VIR_FREE(cpuinfo); - return ret; + return 0; } #define QEMU_ADD_NET_PARAM(params, num, name, value) \ --=20 2.39.1