Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
tools/virsh-interface.c | 15 ++++++---------
tools/virsh-network.c | 17 ++++++-----------
2 files changed, 12 insertions(+), 20 deletions(-)
diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
index 4bcc59b580..f402119b68 100644
--- a/tools/virsh-interface.c
+++ b/tools/virsh-interface.c
@@ -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;
}
/*
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 198993ac33..1442210278 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -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;
}
/*
--
2.31.1