[libvirt] [PATCH 01/42] tools: Use g_autofree on cmdCd()

Fabiano Fidêncio fidencio at redhat.com
Thu Dec 19 10:04:06 UTC 2019


Signed-off-by: Fabiano Fidêncio <fidencio at redhat.com>
---
 tools/vsh.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index 5ccda5ab44..bbb6227130 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -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[] = {
-- 
2.24.1




More information about the libvir-list mailing list