Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- 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 4cdc533a07..471f9974a1 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -478,7 +478,7 @@ virshDomainVcpuCompleter(vshControl *ctl, unsigned int flags) { g_autoptr(virshDomain) dom = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; int nvcpus = 0; unsigned int id; @@ -506,7 +506,6 @@ virshDomainVcpuCompleter(vshControl *ctl, ret = g_steal_pointer(&tmp); cleanup: - xmlFreeDoc(xml); return ret; } @@ -517,7 +516,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, unsigned int flags) { g_autoptr(virshDomain) dom = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; int nvcpus = 0; unsigned int id; @@ -549,7 +548,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, ret = virshCommaStringListComplete(vcpuid, (const char **)vcpulist); cleanup: - xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index cabf968393..fb52915cab 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -55,7 +55,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title, unsigned int flags) { char *desc = NULL; - xmlDocPtr doc = NULL; + g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; int type; @@ -92,7 +92,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title, desc = g_strdup(""); cleanup: - xmlFreeDoc(doc); return desc; } @@ -593,7 +592,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) { bool ret = false; unsigned int flags = 0; - xmlDocPtr xmldoc = NULL; + g_autoptr(xmlDoc) xmldoc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; int ndisks; xmlNodePtr *disks = NULL; @@ -693,7 +692,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) VIR_FREE(device); VIR_FREE(type); VIR_FREE(disks); - xmlFreeDoc(xmldoc); return ret; } @@ -720,7 +718,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) { bool ret = false; unsigned int flags = 0; - xmlDocPtr xmldoc = NULL; + g_autoptr(xmlDoc) xmldoc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; int ninterfaces; xmlNodePtr *interfaces = NULL; @@ -779,7 +777,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) cleanup: vshTableFree(table); VIR_FREE(interfaces); - xmlFreeDoc(xmldoc); return ret; } @@ -820,7 +817,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) char *xpath = NULL; virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] = ""; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr *interfaces = NULL; int ninterfaces; @@ -874,7 +871,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) VIR_FREE(state); VIR_FREE(interfaces); VIR_FREE(xpath); - xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0c60a4de99..fe2bfdaed0 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3064,7 +3064,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; unsigned int xmlflags = 0; size_t i; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(xmlXPathObject) obj = NULL; xmlNodePtr cur = NULL; @@ -3178,7 +3178,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } cleanup: - xmlFreeDoc(xml); VIR_FREE(xml_buf); return ret; @@ -3636,7 +3635,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) int nvol_list = 0; virshUndefineVolume *vols = NULL; /* info about the volumes to delete */ size_t nvols = 0; - xmlDocPtr doc = NULL; + g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr *vol_nodes = NULL; /* XML nodes of volumes of the guest */ int nvol_nodes; @@ -3953,7 +3952,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) VIR_FREE(vol_list); VIR_FREE(vol_nodes); - xmlFreeDoc(doc); return ret; error: @@ -6551,7 +6549,7 @@ virshCPUCountCollect(vshControl *ctl, int ret = -2; virDomainInfo info; int count; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; if (checkState && @@ -6611,7 +6609,6 @@ virshCPUCountCollect(vshControl *ctl, ret = count; cleanup: - xmlFreeDoc(xml); return ret; } @@ -6754,7 +6751,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, { unsigned int flags = 0; virBitmap *ret = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr *nodes = NULL; int nnodes; @@ -6812,7 +6809,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, cleanup: VIR_FREE(online); VIR_FREE(nodes); - xmlFreeDoc(xml); return ret; } @@ -11383,7 +11379,7 @@ static const vshCmdOptDef opts_domdisplay[] = { static bool cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(virshDomain) dom = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -11613,7 +11609,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(passwd); VIR_FREE(listen_addr); VIR_FREE(output); - xmlFreeDoc(xml); return ret; } @@ -11638,7 +11633,7 @@ static const vshCmdOptDef opts_vncdisplay[] = { static bool cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(virshDomain) dom = NULL; bool ret = false; @@ -11687,7 +11682,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(listen_addr); - xmlFreeDoc(xml); return ret; } @@ -11712,7 +11706,7 @@ static const vshCmdOptDef opts_ttyconsole[] = { static bool cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; bool ret = false; char *tty = NULL; @@ -11727,7 +11721,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: - xmlFreeDoc(xml); VIR_FREE(tty); return ret; } @@ -12068,7 +12061,7 @@ virshDomainDetachInterface(char *doc, const char *type, const char *mac) { - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathObject) obj = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr cur = NULL, matchNode = NULL; @@ -12143,7 +12136,6 @@ virshDomainDetachInterface(char *doc, cleanup: VIR_FREE(detach_xml); - xmlFreeDoc(xml); return ret == 0; } @@ -12247,7 +12239,7 @@ virshFindDisk(const char *doc, const char *path, int type) { - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathObject) obj = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr cur = NULL; @@ -12323,7 +12315,6 @@ virshFindDisk(const char *doc, vshError(NULL, _("No disk found whose source path or target is %s"), path); cleanup: - xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index b2d3a9c85f..a07f5adbfa 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -167,7 +167,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) bool cellno = vshCommandOptBool(cmd, "cellno"); size_t i; char *cap_xml = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; virshControl *priv = ctl->privData; @@ -243,7 +243,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: - xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(nodes_free); VIR_FREE(nodes_id); @@ -306,7 +305,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *nodes = NULL; int nodes_cnt; char *cap_xml = NULL; - xmlDocPtr doc = NULL; + g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; bool all = vshCommandOptBool(cmd, "all"); bool cellno = vshCommandOptBool(cmd, "cellno"); @@ -442,7 +441,6 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: - xmlFreeDoc(doc); VIR_FREE(cap_xml); VIR_FREE(nodes); VIR_FREE(counts); @@ -504,7 +502,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned long long pageCounts[1], tmp; unsigned int flags = 0; char *cap_xml = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr *nodes = NULL; virshControl *priv = ctl->privData; @@ -569,7 +567,6 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: - xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(cap_xml); return ret; @@ -603,7 +600,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) const char *type = NULL; int vcpus = -1; char *caps = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; virshControl *priv = ctl->privData; bool ret = false; @@ -628,7 +625,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) ret = true; cleanup: - xmlFreeDoc(xml); VIR_FREE(caps); return ret; } @@ -1120,7 +1116,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, char **cpus = NULL; char *buffer = NULL; char *xmlStr = NULL; - xmlDocPtr xml = NULL; + g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr *nodes = NULL; char *doc; @@ -1183,7 +1179,6 @@ vshExtractCPUDefXMLs(vshControl *ctl, cleanup: VIR_FREE(buffer); VIR_FREE(xmlStr); - xmlFreeDoc(xml); VIR_FREE(nodes); return cpus; diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 1a94eba1c3..71cc265efc 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -821,7 +821,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) char *if_xml = NULL; xmlChar *br_xml = NULL; int br_xml_size; - xmlDocPtr xml_doc = NULL; + g_autoptr(xmlDoc) xml_doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr top_node, br_node, if_node, cur; virshControl *priv = ctl->privData; @@ -1001,7 +1001,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) VIR_FREE(if_type); VIR_FREE(if2_name); VIR_FREE(delay_str); - xmlFreeDoc(xml_doc); return ret; } @@ -1042,7 +1041,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) char *br_xml = NULL; xmlChar *if_xml = NULL; int if_xml_size; - xmlDocPtr xml_doc = NULL; + g_autoptr(xmlDoc) xml_doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; xmlNodePtr top_node, if_node, cur; virshControl *priv = ctl->privData; @@ -1200,7 +1199,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) VIR_FREE(br_xml); VIR_FREE(if_type); VIR_FREE(if_name); - xmlFreeDoc(xml_doc); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 4b179d7d87..6a1fe6785b 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -525,7 +525,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) static xmlChar * virshMakeCloneXML(const char *origxml, const char *newname) { - xmlDocPtr doc = NULL; + g_autoptr(xmlDoc) doc = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; g_autoptr(xmlXPathObject) obj = NULL; xmlChar *newxml = NULL; @@ -544,7 +544,6 @@ virshMakeCloneXML(const char *origxml, const char *newname) xmlDocDumpMemory(doc, &newxml, &size); cleanup: - xmlFreeDoc(doc); return newxml; } -- 2.31.1