From: Fabiano Fidêncio Date: Thu, 19 Dec 2019 08:09:02 +0000 (+0100) Subject: tools: Use g_autofree in cmdCd() X-Git-Tag: v6.0.0-rc1~181 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd478cc5386edf3ad0a371dcac46b8c64fe8c08d;p=thirdparty%2Flibvirt.git tools: Use g_autofree in cmdCd() Signed-off-by: Fabiano Fidêncio Reviewed-by: Ján Tomko --- 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[] = {