From dd478cc5386edf3ad0a371dcac46b8c64fe8c08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 19 Dec 2019 09:09:02 +0100 Subject: [PATCH] tools: Use g_autofree in cmdCd() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabiano Fidêncio Reviewed-by: Ján Tomko --- 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[] = { -- GitLab