This patch also includes use of an early return in case of an error. I think the changes make the functions more readable. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- tools/virsh-domain.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 3c496d845a..94ed786751 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13608,10 +13608,10 @@ static bool cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom = NULL; - int ret = -1; const vshCmdOpt *opt = NULL; g_autofree const char **mountpoints = NULL; size_t nmountpoints = 0; + int count = 0; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13621,16 +13621,13 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] = opt->data; } - ret = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0)) < 0) { vshError(ctl, _("Unable to freeze filesystems")); - goto cleanup; + return false; } - vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret); - - cleanup: - return ret >= 0; + vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), count); + return true; } static const vshCmdInfo info_domfsthaw[] = { @@ -13656,10 +13653,10 @@ static bool cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom = NULL; - int ret = -1; const vshCmdOpt *opt = NULL; g_autofree const char **mountpoints = NULL; size_t nmountpoints = 0; + int count = 0; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -13669,16 +13666,13 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) mountpoints[nmountpoints-1] = opt->data; } - ret = virDomainFSThaw(dom, mountpoints, nmountpoints, 0); - if (ret < 0) { + if ((count = virDomainFSThaw(dom, mountpoints, nmountpoints, 0)) < 0) { vshError(ctl, _("Unable to thaw filesystems")); - goto cleanup; + return false; } - vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret); - - cleanup: - return ret >= 0; + vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), count); + return true; } static const vshCmdInfo info_domfsinfo[] = { -- 2.31.1