]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: remove variable 'ret' and 'inactive'
authorKristina Hanicova <khanicov@redhat.com>
Thu, 23 Sep 2021 23:49:10 +0000 (01:49 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 Sep 2021 07:58:06 +0000 (09:58 +0200)
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-interface.c
tools/virsh-network.c

index 4bcc59b5807a70dd291a1316d958a1be51024065..f402119b6855b9f184539ee32d13e55a3e09b964 100644 (file)
@@ -485,26 +485,23 @@ static bool
 cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
 {
     virInterfacePtr iface;
-    bool ret = true;
     g_autofree char *dump = NULL;
     unsigned int flags = 0;
-    bool inactive = vshCommandOptBool(cmd, "inactive");
 
-    if (inactive)
+    if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_INTERFACE_XML_INACTIVE;
 
     if (!(iface = virshCommandOptInterface(ctl, cmd, NULL)))
         return false;
 
-    dump = virInterfaceGetXMLDesc(iface, flags);
-    if (dump != NULL) {
-        vshPrint(ctl, "%s", dump);
-    } else {
-        ret = false;
+    if (!(dump = virInterfaceGetXMLDesc(iface, flags))) {
+        virInterfaceFree(iface);
+        return false;
     }
 
+    vshPrint(ctl, "%s", dump);
     virInterfaceFree(iface);
-    return ret;
+    return true;
 }
 
 /*
index 198993ac33dd0113ad7f5c87784e911f15283611..1442210278afd055a35e38d2760bb53fca1eceb1 100644 (file)
@@ -360,28 +360,23 @@ static bool
 cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
 {
     virNetworkPtr network;
-    bool ret = true;
     g_autofree char *dump = NULL;
     unsigned int flags = 0;
-    int inactive;
 
     if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
         return false;
 
-    inactive = vshCommandOptBool(cmd, "inactive");
-    if (inactive)
+    if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_NETWORK_XML_INACTIVE;
 
-    dump = virNetworkGetXMLDesc(network, flags);
-
-    if (dump != NULL) {
-        vshPrint(ctl, "%s", dump);
-    } else {
-        ret = false;
+    if (!(dump = virNetworkGetXMLDesc(network, flags))) {
+        virNetworkFree(network);
+        return false;
     }
 
+    vshPrint(ctl, "%s", dump);
     virNetworkFree(network);
-    return ret;
+    return true;
 }
 
 /*