From 0f729b6ce071ea9ae7f26faa70daf4c9adf6bfa2 Mon Sep 17 00:00:00 2001 From: Kristina Hanicova Date: Thu, 21 Jul 2022 12:45:51 +0200 Subject: [PATCH] domain_conf: use early return in virDomainObjAssignDef() Signed-off-by: Kristina Hanicova Reviewed-by: Martin Kletzander --- 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.39.5