From 4d60e7fdd47802f8356497c2a6f55560872e2cdb Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 1 Oct 2019 08:00:26 +0200 Subject: [PATCH] conf: Don't reuse variable for different object in virDomainCheckpointRedefinePrep MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The 'other' variable was used to store the parent of the redefined checkpoint and then the existing version of the currently redefined checkpoint. Make it less confusing by adding a 'parent' variable for the first case. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/checkpoint_conf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 90cb565d70..62ec9ced41 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -534,6 +534,7 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, { virDomainCheckpointDefPtr def = *defptr; char uuidstr[VIR_UUID_STRING_BUFLEN]; + virDomainMomentObjPtr parent = NULL; virDomainMomentObjPtr other = NULL; virDomainCheckpointDefPtr otherdef = NULL; @@ -552,12 +553,13 @@ virDomainCheckpointRedefinePrep(virDomainObjPtr vm, if (virDomainCheckpointAlignDisks(def) < 0) return -1; - if (def->parent.parent_name) - other = virDomainCheckpointFindByName(vm->checkpoints, - def->parent.parent_name); - if (other == virDomainCheckpointGetCurrent(vm->checkpoints)) { - *update_current = true; - virDomainCheckpointSetCurrent(vm->checkpoints, NULL); + if (def->parent.parent_name && + (parent = virDomainCheckpointFindByName(vm->checkpoints, + def->parent.parent_name))) { + if (parent == virDomainCheckpointGetCurrent(vm->checkpoints)) { + *update_current = true; + virDomainCheckpointSetCurrent(vm->checkpoints, NULL); + } } other = virDomainCheckpointFindByName(vm->checkpoints, def->parent.name); -- 2.47.2