From 24ddb0cdfeab678cd00e22efaac1a1f7f904668e Mon Sep 17 00:00:00 2001 From: Kristina Hanicova Date: Fri, 24 Sep 2021 17:17:48 +0200 Subject: [PATCH] virsh: domain: use early return when possible Signed-off-by: Kristina Hanicova Reviewed-by: Michal Privoznik --- tools/virsh-domain.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 7dc669bc71..1102f044de 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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; }