Signed-off-by: Roland Schulz <schullzroll@gmail.com>
---
tools/virsh-completer.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index 1435d1d4c..c72f3bcad 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -576,6 +576,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
virshControlPtr priv = ctl->privData;
unsigned int npages = 0;
xmlNodePtr *pages = NULL;
+ xmlDocPtr doc = NULL;
double size = 0;
size_t i = 0;
const char *suffix = NULL;
@@ -595,7 +596,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
goto error;
- if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
+ if ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)) == NULL)
goto error;
if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) {
@@ -631,12 +632,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
cleanup:
xmlXPathFreeContext(ctxt);
- for (i = 0; i < npages; i++)
- VIR_FREE(pages[i]);
VIR_FREE(pages);
- VIR_FREE(cap_xml);
+ xmlFreeDoc(doc);
VIR_FREE(path);
VIR_FREE(pagesize);
+ VIR_FREE(cap_xml);
VIR_FREE(unit);
return ret;
--
2.17.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 05/23/2018 02:40 PM, Roland Schulz wrote:
> Signed-off-by: Roland Schulz <schullzroll@gmail.com>
> ---
> tools/virsh-completer.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
> index 1435d1d4c..c72f3bcad 100644
> --- a/tools/virsh-completer.c
> +++ b/tools/virsh-completer.c
> @@ -576,6 +576,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
> virshControlPtr priv = ctl->privData;
> unsigned int npages = 0;
> xmlNodePtr *pages = NULL;
> + xmlDocPtr doc = NULL;
> double size = 0;
> size_t i = 0;
> const char *suffix = NULL;
> @@ -595,7 +596,7 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
> if (!(cap_xml = virConnectGetCapabilities(priv->conn)))
> goto error;
>
> - if (!(virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)))
> + if ((doc = virXMLParseStringCtxt(cap_xml, _("capabilities"), &ctxt)) == NULL)
> goto error;
You can keep the !ptr comparison just like @cap_xml is tested a few
lines above.
>
> if (cellno && vshCommandOptStringQuiet(ctl, cmd, "cellno", &cellnum) > 0) {
> @@ -631,12 +632,11 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
>
> cleanup:
> xmlXPathFreeContext(ctxt);
> - for (i = 0; i < npages; i++)
> - VIR_FREE(pages[i]);
> VIR_FREE(pages);
> - VIR_FREE(cap_xml);
> + xmlFreeDoc(doc);
> VIR_FREE(path);
> VIR_FREE(pagesize);
> + VIR_FREE(cap_xml);
> VIR_FREE(unit);
>
> return ret;
>
ACKed and pushed. Thank you for addressing all the points I raised.
Michal
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.