]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: Use g_autofree in cmdCd()
authorFabiano Fidêncio <fidencio@redhat.com>
Thu, 19 Dec 2019 08:09:02 +0000 (09:09 +0100)
committerFabiano Fidêncio <fidencio@redhat.com>
Fri, 20 Dec 2019 08:38:43 +0000 (09:38 +0100)
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index 5ccda5ab4462520f92dc3ea4de513c39dbe7dca9..bbb6227130c22e8dbd1bbe7e64d0e947f6e06aac 100644 (file)
@@ -3175,8 +3175,7 @@ bool
 cmdCd(vshControl *ctl, const vshCmd *cmd)
 {
     const char *dir = NULL;
-    char *dir_malloced = NULL;
-    bool ret = true;
+    g_autofree char *dir_malloced = NULL;
     char ebuf[1024];
 
     if (!ctl->imode) {
@@ -3192,11 +3191,10 @@ cmdCd(vshControl *ctl, const vshCmd *cmd)
     if (chdir(dir) == -1) {
         vshError(ctl, _("cd: %s: %s"),
                  virStrerror(errno, ebuf, sizeof(ebuf)), dir);
-        ret = false;
+        return false;
     }
 
-    VIR_FREE(dir_malloced);
-    return ret;
+    return true;
 }
 
 const vshCmdOptDef opts_echo[] = {