From c344784b886dfc9c15024fdd15044be44570bda8 Mon Sep 17 00:00:00 2001 From: Peter Krempa <pkrempa@redhat.com> Date: Tue, 1 Mar 2022 17:02:59 +0100 Subject: [PATCH] virsh: cmdDesc: Use 'vshTempFile' type to simplify cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> --- tools/virsh-domain.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index cac50dba51..dcf0f712f6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8335,7 +8335,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) int type; char *desc = NULL; char *desc_edited = NULL; - char *tmp = NULL; char *tmpstr; const vshCmdOpt *opt = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -8379,6 +8378,8 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) } if (edit) { + g_autoptr(vshTempFile) tmp = NULL; + /* Create and open the temporary file. */ if (!(tmp = vshEditWriteToTempFile(ctl, desc))) goto cleanup; @@ -8439,10 +8440,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(desc_edited); VIR_FREE(desc); - if (tmp) { - unlink(tmp); - VIR_FREE(tmp); - } return ret; }