[PATCH v2 6/8] domain_conf: use early return in virDomainObjAssignDef()

Kristina Hanicova khanicov at redhat.com
Thu Jul 21 10:45:51 UTC 2022


Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
---
 src/conf/domain_conf.c | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 41eb105a6c..507bff953c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3928,22 +3928,24 @@ void virDomainObjAssignDef(virDomainObj *domain,
         else
             virDomainDefFree(domain->newDef);
         domain->newDef = g_steal_pointer(def);
-    } else {
-        if (live) {
-            /* save current configuration to be restored on domain shutdown */
-            if (!domain->newDef)
-                domain->newDef = domain->def;
-            else
-                virDomainDefFree(domain->def);
-            domain->def = g_steal_pointer(def);
-        } else {
-            if (oldDef)
-                *oldDef = domain->def;
-            else
-                virDomainDefFree(domain->def);
-            domain->def = g_steal_pointer(def);
-        }
+        return;
+    }
+
+    if (live) {
+        /* save current configuration to be restored on domain shutdown */
+        if (!domain->newDef)
+            domain->newDef = domain->def;
+        else
+            virDomainDefFree(domain->def);
+        domain->def = g_steal_pointer(def);
+        return;
     }
+
+    if (oldDef)
+        *oldDef = domain->def;
+    else
+        virDomainDefFree(domain->def);
+    domain->def = g_steal_pointer(def);
 }
 
 
-- 
2.35.3



More information about the libvir-list mailing list