From nobody Sun Feb 8 20:13:08 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=1628757585; cv=none; d=zohomail.com; s=zohoarc; b=Aiqv/xOBx+Kr/OqYxV9bcLfx702cSztlKRUlxsoiS8r2rhQNZy/56Hu8+W7CBKkWrLFd8i+lbuUOzCV0eXP32sjXmVhSoDFfcEVeJ2b0cfoMXqFhsoGSbJAhyMi8Z2oPgfa8UyWESA1J6UCdlAtNOgornAVX1ijj3XAMQWIXRg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757585; 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=mQUKqQ5rPeev7hI1EaJ4bdsF+hHxtkKX8wCCs/Y9Nkc=; b=ahrQkIGHytZh2m+aTlW5BLnkVeakmgNXJ3TshFrfdx3pZrThpchWaNMw6lSvKCjaBLgjLPqVFGpY2w+jBNb2uEG1E74y4wlNMlaJXv0535o41BtLudb6WrWxZbi1KpcXxnmWoZjiRoBMgo37a1nlP3W21hhDsLJyF5AdB8GMEG8= 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 1628757585332117.68240571321212; Thu, 12 Aug 2021 01:39:45 -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-162-002_mqJCPrCCKfTzInjXVA-1; Thu, 12 Aug 2021 04:39:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B9291082924; Thu, 12 Aug 2021 08:39:37 +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 3B55C60C9D; Thu, 12 Aug 2021 08:39:37 +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 0616D181A2A9; Thu, 12 Aug 2021 08:39:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XAAH003681 for ; Thu, 12 Aug 2021 04:33:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDFFC10372CC; Thu, 12 Aug 2021 08:33:10 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7510410013C1 for ; Thu, 12 Aug 2021 08:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757584; 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=mQUKqQ5rPeev7hI1EaJ4bdsF+hHxtkKX8wCCs/Y9Nkc=; b=Kc9OCgqAqB5DLR2UZq2Ot/XhVoe2SNMmXbRwHiags4tVmJIShjqZW5+ExsWRE3jp99GMtc yUwWtayFlG9pMOXow8Yu111PwtuXes/LWUgf1qv8pY5oVtTDJGdYKnU372LgZ/w8tJGFce wQVTwLOG/3Fu5JJUCkLHHuZ8UwwznnY= X-MC-Unique: 002_mqJCPrCCKfTzInjXVA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/12] tools: virsh: use automatic cleanup for vshTable Date: Thu, 12 Aug 2021 10:32:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628757586281100001 Signed-off-by: J=C3=A1n Tomko --- tools/virsh-domain-monitor.c | 9 +++------ tools/virsh-domain.c | 9 +++------ tools/virsh-interface.c | 3 +-- tools/virsh-network.c | 9 +++------ tools/virsh-nwfilter.c | 6 ++---- tools/virsh-pool.c | 3 +-- tools/virsh-secret.c | 3 +-- tools/virsh-volume.c | 3 +-- tools/virt-admin.c | 6 ++---- 9 files changed, 17 insertions(+), 34 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index fb52915cab..4059acc7d6 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -602,7 +602,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) char *device =3D NULL; char *target =3D NULL; char *source =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_DOMAIN_XML_INACTIVE; @@ -686,7 +686,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); VIR_FREE(source); VIR_FREE(target); VIR_FREE(device); @@ -723,7 +722,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) int ninterfaces; xmlNodePtr *interfaces =3D NULL; size_t i; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_DOMAIN_XML_INACTIVE; @@ -775,7 +774,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); VIR_FREE(interfaces); return ret; } @@ -1950,7 +1948,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) char id_buf[VIR_INT64_STR_BUFLEN]; unsigned int id; unsigned int flags =3D VIR_CONNECT_LIST_DOMAINS_ACTIVE; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* construct filter flags */ if (vshCommandOptBool(cmd, "inactive") || @@ -2072,7 +2070,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - vshTableFree(table); virshDomainListFree(list); return ret; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index fe2bfdaed0..f72ec36f6f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6983,7 +6983,7 @@ virshVcpuPinQuery(vshControl *ctl, size_t i; int ncpus; bool ret =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if ((ncpus =3D virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) { if (ncpus =3D=3D -1) { @@ -7038,7 +7038,6 @@ virshVcpuPinQuery(vshControl *ctl, =20 ret =3D true; cleanup: - vshTableFree(table); VIR_FREE(cpumap); return ret; } @@ -7604,7 +7603,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) virDomainIOThreadInfoPtr *info =3D NULL; size_t i; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; bool ret =3D false; int rc; =20 @@ -7655,7 +7654,6 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < niothreads; i++) virDomainIOThreadInfoFree(info[i]); VIR_FREE(info); - vshTableFree(table); return ret; } =20 @@ -13907,7 +13905,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) int rc =3D -1; size_t i, j; virDomainFSInfoPtr *info =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; size_t ninfos =3D 0; bool ret =3D false; =20 @@ -13962,7 +13960,6 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) virDomainFSInfoFree(info[i]); VIR_FREE(info); } - vshTableFree(table); return ret; } =20 diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 71cc265efc..f88ec188f1 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -348,7 +348,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) struct virshInterfaceList *list =3D NULL; size_t i; bool ret =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, inactive); =20 @@ -381,7 +381,6 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshInterfaceListFree(list); return ret; } diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 152df1086b..d641606dde 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -711,7 +711,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) bool optUUID =3D vshCommandOptBool(cmd, "uuid"); char uuid[VIR_UUID_STRING_BUFLEN]; unsigned int flags =3D VIR_CONNECT_LIST_NETWORKS_ACTIVE; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags =3D VIR_CONNECT_LIST_NETWORKS_INACTIVE; @@ -782,7 +782,6 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNetworkListFree(list); return ret; } @@ -1407,7 +1406,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) size_t i; unsigned int flags =3D 0; virNetworkPtr network =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0) return false; @@ -1461,7 +1460,6 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - vshTableFree(table); if (leases) { for (i =3D 0; i < nleases; i++) virNetworkDHCPLeaseFree(leases[i]); @@ -1754,7 +1752,7 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd) bool optUUID =3D vshCommandOptBool(cmd, "uuid"); char uuid[VIR_UUID_STRING_BUFLEN]; unsigned int flags =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (optTable + optUUID > 1) { vshError(ctl, "%s", @@ -1795,7 +1793,6 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - vshTableFree(table); virshNetworkPortListFree(list); return ret; } diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 640e54446e..acb35e8aa1 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -354,7 +354,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) char uuid[VIR_UUID_STRING_BUFLEN]; bool ret =3D false; struct virshNWFilterList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (!(list =3D virshNWFilterListCollect(ctl, 0))) return false; @@ -378,7 +378,6 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNWFilterListFree(list); return ret; } @@ -717,7 +716,7 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *c= md G_GNUC_UNUSED) size_t i; bool ret =3D false; struct virshNWFilterBindingList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (!(list =3D virshNWFilterBindingListCollect(ctl, 0))) return false; @@ -740,7 +739,6 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *c= md G_GNUC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNWFilterBindingListFree(list); return ret; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 18f3839a4c..5bce5cf06c 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1135,7 +1135,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) bool inactive, all; bool uuid =3D false; bool name =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 inactive =3D vshCommandOptBool(cmd, "inactive"); all =3D vshCommandOptBool(cmd, "all"); @@ -1390,7 +1390,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); if (list && list->npools) { for (i =3D 0; i < list->npools; i++) { VIR_FREE(poolInfoTexts[i].state); diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index cfecbb9b95..4f433fae9c 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -551,7 +551,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) struct virshSecretList *list =3D NULL; bool ret =3D false; unsigned int flags =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "ephemeral")) flags |=3D VIR_CONNECT_LIST_SECRETS_EPHEMERAL; @@ -605,7 +605,6 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); virshSecretListFree(list); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 6a1fe6785b..af93998d57 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -1415,7 +1415,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) }; struct volInfoText *volInfoTexts =3D NULL; struct virshStorageVolList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* Look up the pool information given to us by the user */ if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) @@ -1513,7 +1513,6 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); =20 /* Safely free the memory allocated in this function */ if (list && list->nvols) { diff --git a/tools/virt-admin.c b/tools/virt-admin.c index dd17743b9d..c8e7ee794a 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -332,7 +332,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) char *uri =3D NULL; virAdmServerPtr *srvs =3D NULL; vshAdmControl *priv =3D ctl->privData; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* Obtain a list of available servers on the daemon */ if ((nsrvs =3D virAdmConnectListServers(priv->conn, &srvs, 0)) < 0) { @@ -361,7 +361,6 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) =20 ret =3D true; cleanup: - vshTableFree(table); if (srvs) { for (i =3D 0; i < nsrvs; i++) virAdmServerFree(srvs[i]); @@ -580,7 +579,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv =3D NULL; virAdmClientPtr *clts =3D NULL; vshAdmControl *priv =3D ctl->privData; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; @@ -621,7 +620,6 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); if (clts) { for (i =3D 0; i < nclts; i++) virAdmClientFree(clts[i]); --=20 2.31.1