]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: domain: use early return when possible
authorKristina Hanicova <khanicov@redhat.com>
Fri, 24 Sep 2021 15:17:48 +0000 (17:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Sat, 25 Sep 2021 07:30:09 +0000 (09:30 +0200)
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain.c

index 7dc669bc71d346974500ad6aae19b209584d5f65..1102f044de3ce22a46d03413a644bcd4db950566 100644 (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;
 }