From: Peter Krempa Date: Thu, 19 Nov 2020 09:39:45 +0000 (+0100) Subject: virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom' X-Git-Tag: v6.10.0-rc1~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=62903cb11fa004a72ecfb6c7ae35ade89bbe0847;p=thirdparty%2Flibvirt.git virsh: cmdAttachDisk: Use automatic memory clearing for 'xml' and 'dom' Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index e27b779533..42a255cd6d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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; }