mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 10:35:20 +00:00
virsh: domain: remove 'ret' variable and use 'count' instead
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@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
24ddb0cdfe
commit
bd82e3d81a
@ -13602,10 +13602,10 @@ static bool
|
|||||||
cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
|
cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
int ret = -1;
|
|
||||||
const vshCmdOpt *opt = NULL;
|
const vshCmdOpt *opt = NULL;
|
||||||
g_autofree const char **mountpoints = NULL;
|
g_autofree const char **mountpoints = NULL;
|
||||||
size_t nmountpoints = 0;
|
size_t nmountpoints = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
@ -13615,16 +13615,13 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd)
|
|||||||
mountpoints[nmountpoints-1] = opt->data;
|
mountpoints[nmountpoints-1] = opt->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0);
|
if ((count = virDomainFSFreeze(dom, mountpoints, nmountpoints, 0)) < 0) {
|
||||||
if (ret < 0) {
|
|
||||||
vshError(ctl, _("Unable to freeze filesystems"));
|
vshError(ctl, _("Unable to freeze filesystems"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret);
|
vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), count);
|
||||||
|
return true;
|
||||||
cleanup:
|
|
||||||
return ret >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const vshCmdInfo info_domfsthaw[] = {
|
static const vshCmdInfo info_domfsthaw[] = {
|
||||||
@ -13650,10 +13647,10 @@ static bool
|
|||||||
cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
|
cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
g_autoptr(virshDomain) dom = NULL;
|
g_autoptr(virshDomain) dom = NULL;
|
||||||
int ret = -1;
|
|
||||||
const vshCmdOpt *opt = NULL;
|
const vshCmdOpt *opt = NULL;
|
||||||
g_autofree const char **mountpoints = NULL;
|
g_autofree const char **mountpoints = NULL;
|
||||||
size_t nmountpoints = 0;
|
size_t nmountpoints = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
@ -13663,16 +13660,13 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd)
|
|||||||
mountpoints[nmountpoints-1] = opt->data;
|
mountpoints[nmountpoints-1] = opt->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virDomainFSThaw(dom, mountpoints, nmountpoints, 0);
|
if ((count = virDomainFSThaw(dom, mountpoints, nmountpoints, 0)) < 0) {
|
||||||
if (ret < 0) {
|
|
||||||
vshError(ctl, _("Unable to thaw filesystems"));
|
vshError(ctl, _("Unable to thaw filesystems"));
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret);
|
vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), count);
|
||||||
|
return true;
|
||||||
cleanup:
|
|
||||||
return ret >= 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const vshCmdInfo info_domfsinfo[] = {
|
static const vshCmdInfo info_domfsinfo[] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user