From: Peter Krempa Date: Tue, 1 Oct 2019 06:00:26 +0000 (+0200) Subject: conf: Don't reuse variable for different object in virDomainCheckpointRedefinePrep X-Git-Tag: v5.9.0-rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d60e7fdd47802f8356497c2a6f55560872e2cdb;p=thirdparty%2Flibvirt.git conf: Don't reuse variable for different object in virDomainCheckpointRedefinePrep 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 --- 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);