]> xenbits.xensource.com Git - libvirt.git/commitdiff
domain_conf: use early return in virDomainObjAssignDef()
authorKristina Hanicova <khanicov@redhat.com>
Thu, 21 Jul 2022 10:45:51 +0000 (12:45 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 22 Jul 2022 10:57:05 +0000 (12:57 +0200)
Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/conf/domain_conf.c

index 41eb105a6c20f59b595ea72eb2d76b91257ffd73..507bff953c11547b6d86d5584e2a8d3667d032ad 100644 (file)
@@ -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);
 }