[PATCH] qemu: Simplify interface handling in qemuConnectDomainXMLToNative()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Firstly, VIR_STRDUP() accepts NULL, so there is no need to check
if the string we want to duplicate is not-NULL. Secondly,
virDomainNetSetModelString() also accepts NULL. Thirdly, we have
VIR_AUTOFREE().

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0fb90c4049..c443c881d5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7411,12 +7411,11 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
     for (i = 0; i < vm->def->nnets; i++) {
         virDomainNetDefPtr net = vm->def->nets[i];
         unsigned int bootIndex = net->info.bootIndex;
-        char *model = NULL;
+        VIR_AUTOFREE(char *) model = NULL;
         virMacAddr mac = net->mac;
         char *script = net->script;
 
-        if (virDomainNetGetModelString(net) &&
-            VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
+        if (VIR_STRDUP(model, virDomainNetGetModelString(net)) < 0)
             goto cleanup;
 
         net->script = NULL;
@@ -7428,11 +7427,8 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
         net->mac = mac;
         net->script = script;
 
-        if (model && virDomainNetSetModelString(net, model) < 0) {
-            VIR_FREE(model);
+        if (virDomainNetSetModelString(net, model) < 0)
             goto cleanup;
-        }
-        VIR_FREE(model);
     }
 
     if (!(cmd = qemuProcessCreatePretendCmd(driver, vm, NULL,
-- 
2.21.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux