]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: cmdDesc: Use 'vshTempFile' type to simplify cleanup
authorPeter Krempa <pkrempa@redhat.com>
Tue, 1 Mar 2022 16:02:59 +0000 (17:02 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 3 Mar 2022 10:06:57 +0000 (11:06 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index cac50dba51e8002b4966f684854b62432af64e7b..dcf0f712f66d711e64d7ab6d2dd36539e682a1cd 100644 (file)
@@ -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;
 }