[libvirt] [PATCH v2 1/2] virsh: Slightly rework cmdDomblklist

Martin Kletzander mkletzan at redhat.com
Mon Sep 7 07:23:12 UTC 2015


On Wed, Sep 02, 2015 at 05:58:18PM +0200, Michal Privoznik wrote:
>Let's move some variables from an inside loop to global function
>declaration header block. It's going to be easier for next
>patches. At the same time, order the cleanup calls at the
>function's end so it's easier to track which variables are freed
>and which not.
>
>Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
>---
> tools/virsh-domain-monitor.c | 29 ++++++++++++++---------------
> 1 file changed, 14 insertions(+), 15 deletions(-)
>

I did not follow the discussion around 2/2, but this one does not do
any functional change and cleans up the code nicely, so ACK ... [1]

>diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
>index 340a8e2..d4e500b 100644
>--- a/tools/virsh-domain-monitor.c
>+++ b/tools/virsh-domain-monitor.c
>@@ -549,24 +544,28 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
>         if (details) {
>             vshPrint(ctl, "%-10s %-10s %-10s %s\n", type, device,
>                      target, source ? source : "-");
>-            VIR_FREE(type);
>-            VIR_FREE(device);
>         } else {
>             vshPrint(ctl, "%-10s %s\n", target, source ? source : "-");
>         }
>
>-        VIR_FREE(target);
>         VIR_FREE(source);
>+        VIR_FREE(target);
>+        VIR_FREE(device);
>+        VIR_FREE(type);
>     }
>
>     ret = true;
>
>  cleanup:
>+    VIR_FREE(source);
>+    VIR_FREE(target);
>+    VIR_FREE(device);
>+    VIR_FREE(type);
>     VIR_FREE(disks);
>-    virDomainFree(dom);
>-    VIR_FREE(xml);
>-    xmlFreeDoc(xmldoc);
>     xmlXPathFreeContext(ctxt);
>+    xmlFreeDoc(xmldoc);
>+    VIR_FREE(xml);
>+    virDomainFree(dom);

[1] ... even though I don't understand why these are reordered.

>     return ret;
> }
>
>--
>2.4.6
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150907/34df36fb/attachment-0001.sig>


More information about the libvir-list mailing list