virsh: domain: use early return when possible

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-09-24 17:17:48 +02:00 committed by Michal Privoznik
parent 6e1cdf928c
commit 24ddb0cdfe

View File

@ -5883,13 +5883,13 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd)
rv = virDomainShutdownFlags(dom, flags);
else
rv = virDomainShutdown(dom);
if (rv == 0) {
vshPrintExtra(ctl, _("Domain '%s' is being shutdown\n"), name);
} else {
if (rv != 0) {
vshError(ctl, _("Failed to shutdown domain '%s'"), name);
return false;
}
vshPrintExtra(ctl, _("Domain '%s' is being shutdown\n"), name);
return true;
}
@ -5959,13 +5959,12 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
return false;
if (virDomainReboot(dom, flags) == 0) {
vshPrintExtra(ctl, _("Domain '%s' is being rebooted\n"), name);
} else {
if (virDomainReboot(dom, flags) != 0) {
vshError(ctl, _("Failed to reboot domain '%s'"), name);
return false;
}
vshPrintExtra(ctl, _("Domain '%s' is being rebooted\n"), name);
return true;
}