From nobody Sun Feb 8 18:43:59 2026 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=1628757679; cv=none; d=zohomail.com; s=zohoarc; b=AO/tRTKMbBEMmr+J/3vi2u3l4rXWeGhs5tNSx9XkKaAM1zxHbpo0QfzOm5L5Kx6JhSvFRTl5Ct0SVEBRNBMeWpzmWhg99gI4U+xcez1E7NWo6SVg7QW+N3awkgBEr5Cky4zCmRyA244/CNDdH31zCa8rYlwsETYZ7P4ZZLybZ/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757679; 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=V0zRXkeDTF6IKuZgqpouXFEUpgnnwu+YHzgwoytPCPA=; b=lNgDhAqhW0LBf+XVWHeyIdE0z9AhPerlrGC+/QdLin0kIOwyJefz+5MTJc9QDZqjN66/L2ds52ZZ3a8wjypZD/fJfg2G8AIBNpN5ZOtfdW6hZzOu1NbINmiQRAapbvuZFuU9rJi24Zc8BVi53CSJNWskjpS9Iq77sgQuJ5yAnwc= 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 1628757679618254.4511758019322; Thu, 12 Aug 2021 01:41:19 -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-353-XifNFpiTPAeO4SmKGFxHwA-1; Thu, 12 Aug 2021 04:39:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1422190A7A0; Thu, 12 Aug 2021 08:39:31 +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 AE8312855E; Thu, 12 Aug 2021 08:39:31 +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 6FE414A7C8; Thu, 12 Aug 2021 08:39:31 +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 17C8X8Af003655 for ; Thu, 12 Aug 2021 04:33:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 81F4410013C1; Thu, 12 Aug 2021 08:33:08 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A16F1036D3F for ; Thu, 12 Aug 2021 08:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757678; 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=V0zRXkeDTF6IKuZgqpouXFEUpgnnwu+YHzgwoytPCPA=; b=Bccj3gspMoozRYHuy79ebVz9DSdqnvnexyLaC7yGzoJtfeX59RitIXFMtFhsN7TdLxugHD ojzjxp6Vt8SpVZsMfJt7cZ+OzjjQHu44cvKcZVWsJ6ChkvhCeTiSCAK1VpEPLQDCVCQDc1 5CCSmpEmmlA3bT+XGYwSq7akRPj4YuQ= X-MC-Unique: XifNFpiTPAeO4SmKGFxHwA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/12] tools: virsh: use automatic cleanup for xmlXPathContext Date: Thu, 12 Aug 2021 10:32:43 +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.84 on 10.5.11.23 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: 1628757681061100001 Signed-off-by: J=C3=A1n Tomko --- tools/virsh-completer-domain.c | 6 ++---- tools/virsh-domain-monitor.c | 12 ++++-------- tools/virsh-domain.c | 27 +++++++++------------------ tools/virsh-host.c | 15 +++++---------- tools/virsh-interface.c | 6 ++---- tools/virsh-volume.c | 3 +-- 6 files changed, 23 insertions(+), 46 deletions(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index d1430c951a..4cdc533a07 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -479,7 +479,7 @@ virshDomainVcpuCompleter(vshControl *ctl, { g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; char **ret =3D NULL; @@ -506,7 +506,6 @@ virshDomainVcpuCompleter(vshControl *ctl, ret =3D g_steal_pointer(&tmp); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -519,7 +518,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, { g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; g_auto(GStrv) vcpulist =3D NULL; @@ -550,7 +549,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, ret =3D virshCommaStringListComplete(vcpuid, (const char **)vcpulist); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d79f807d8b..cabf968393 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -56,7 +56,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, { char *desc =3D NULL; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int type; =20 if (title) @@ -92,7 +92,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, desc =3D g_strdup(""); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); =20 return desc; @@ -595,7 +594,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; xmlDocPtr xmldoc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int ndisks; xmlNodePtr *disks =3D NULL; size_t i; @@ -694,7 +693,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) VIR_FREE(device); VIR_FREE(type); VIR_FREE(disks); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xmldoc); return ret; } @@ -723,7 +721,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; xmlDocPtr xmldoc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int ninterfaces; xmlNodePtr *interfaces =3D NULL; size_t i; @@ -782,7 +780,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) vshTableFree(table); VIR_FREE(interfaces); xmlFreeDoc(xmldoc); - xmlXPathFreeContext(ctxt); return ret; } =20 @@ -824,7 +821,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *interfaces =3D NULL; int ninterfaces; unsigned int flags =3D 0; @@ -877,7 +874,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) VIR_FREE(state); VIR_FREE(interfaces); VIR_FREE(xpath); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); =20 return ret; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b671ae398f..398190bb5b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3065,7 +3065,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) unsigned int xmlflags =3D 0; size_t i; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlXPathObjectPtr obj =3D NULL; xmlNodePtr cur =3D NULL; char *xml_buf =3D NULL; @@ -3179,7 +3179,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(xml_buf); =20 @@ -3639,7 +3638,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) virshUndefineVolume *vols =3D NULL; /* info about the volumes to delet= e */ size_t nvols =3D 0; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *vol_nodes =3D NULL; /* XML nodes of volumes of the guest= */ int nvol_nodes; char *source =3D NULL; @@ -3956,7 +3955,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) =20 VIR_FREE(vol_nodes); xmlFreeDoc(doc); - xmlXPathFreeContext(ctxt); return ret; =20 error: @@ -6555,7 +6553,7 @@ virshCPUCountCollect(vshControl *ctl, virDomainInfo info; int count; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; =20 if (checkState && ((flags & VIR_DOMAIN_AFFECT_LIVE && virDomainIsActive(dom) < 1) || @@ -6614,7 +6612,6 @@ virshCPUCountCollect(vshControl *ctl, =20 ret =3D count; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); =20 return ret; @@ -6759,7 +6756,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, unsigned int flags =3D 0; virBitmap *ret =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; int nnodes; size_t i; @@ -6816,7 +6813,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, cleanup: VIR_FREE(online); VIR_FREE(nodes); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11389,7 +11385,7 @@ static bool cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; @@ -11618,7 +11614,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(passwd); VIR_FREE(listen_addr); VIR_FREE(output); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11645,7 +11640,7 @@ static bool cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; int port =3D 0; @@ -11693,7 +11688,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(listen_addr); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11720,7 +11714,7 @@ static bool cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; bool ret =3D false; char *tty =3D NULL; =20 @@ -11734,7 +11728,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(tty); return ret; @@ -12078,7 +12071,7 @@ virshDomainDetachInterface(char *doc, { xmlDocPtr xml =3D NULL; xmlXPathObjectPtr obj =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; char *detach_xml =3D NULL; char buf[64]; @@ -12153,7 +12146,6 @@ virshDomainDetachInterface(char *doc, VIR_FREE(detach_xml); xmlFreeDoc(xml); xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); return ret =3D=3D 0; } =20 @@ -12259,7 +12251,7 @@ virshFindDisk(const char *doc, { xmlDocPtr xml =3D NULL; xmlXPathObjectPtr obj =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL; xmlNodePtr ret =3D NULL; size_t i; @@ -12334,7 +12326,6 @@ virshFindDisk(const char *doc, =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 7b47b7583d..b2d3a9c85f 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -168,7 +168,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) size_t i; char *cap_xml =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); @@ -243,7 +243,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(nodes_free); @@ -308,7 +307,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) int nodes_cnt; char *cap_xml =3D NULL; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; bool all =3D vshCommandOptBool(cmd, "all"); bool cellno =3D vshCommandOptBool(cmd, "cellno"); bool pagesz =3D vshCommandOptBool(cmd, "pagesize"); @@ -443,7 +442,6 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); VIR_FREE(cap_xml); VIR_FREE(nodes); @@ -507,7 +505,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; char *cap_xml =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -571,7 +569,6 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(cap_xml); @@ -607,7 +604,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) int vcpus =3D -1; char *caps =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; bool ret =3D false; =20 @@ -631,7 +628,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(caps); return ret; @@ -1125,7 +1121,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, char *buffer =3D NULL; char *xmlStr =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; char *doc; size_t i; @@ -1188,7 +1184,6 @@ vshExtractCPUDefXMLs(vshControl *ctl, VIR_FREE(buffer); VIR_FREE(xmlStr); xmlFreeDoc(xml); - xmlXPathFreeContext(ctxt); VIR_FREE(nodes); return cpus; =20 diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 41acae5dcb..1a94eba1c3 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -822,7 +822,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) xmlChar *br_xml =3D NULL; int br_xml_size; xmlDocPtr xml_doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, br_node, if_node, cur; virshControl *priv =3D ctl->privData; =20 @@ -1001,7 +1001,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) VIR_FREE(if_type); VIR_FREE(if2_name); VIR_FREE(delay_str); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml_doc); return ret; } @@ -1044,7 +1043,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) xmlChar *if_xml =3D NULL; int if_xml_size; xmlDocPtr xml_doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, if_node, cur; virshControl *priv =3D ctl->privData; =20 @@ -1201,7 +1200,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) VIR_FREE(br_xml); VIR_FREE(if_type); VIR_FREE(if_name); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml_doc); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index fe632b1b19..c9c4310cbd 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -526,7 +526,7 @@ static xmlChar * virshMakeCloneXML(const char *origxml, const char *newname) { xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlXPathObjectPtr obj =3D NULL; xmlChar *newxml =3D NULL; int size; @@ -545,7 +545,6 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return newxml; } --=20 2.31.1