]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom'
authorPeter Krempa <pkrempa@redhat.com>
Thu, 19 Nov 2020 09:39:45 +0000 (10:39 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 23 Nov 2020 13:44:39 +0000 (14:44 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
tools/virsh-domain.c

index e27b779533d66884b6c9605fb6e160a46644a479..42a255cd6de6a5eb724d5fb3ec3fb2c28d851bc3 100644 (file)
@@ -561,7 +561,7 @@ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr)
 static bool
 cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 {
-    virDomainPtr dom = NULL;
+    g_autoptr(virshDomain) dom = NULL;
     const char *source = NULL;
     const char *target = NULL;
     const char *driver = NULL;
@@ -583,7 +583,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
     const char *stype = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    char *xml = NULL;
+    g_autofree char *xml = NULL;
     struct stat st;
     bool current = vshCommandOptBool(cmd, "current");
     bool config = vshCommandOptBool(cmd, "config");
@@ -783,8 +783,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     }
 
  cleanup:
-    VIR_FREE(xml);
-    virshDomainFree(dom);
     return functionReturn;
 }