1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

test: Cleanup testDomainRenameCallback

Rather than have a need for old_dom_name, let's just VIR_FREE
the old name first, then use VIR_STEAL_PTR to handle the swap
from the old name to the new name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
John Ferlan 2019-02-07 08:11:03 -05:00
parent 1450b19269
commit 0082ee5b5e

View File

@ -2579,7 +2579,6 @@ testDomainRenameCallback(virDomainObjPtr privdom,
virObjectEventPtr event_old = NULL;
int ret = -1;
char *new_dom_name = NULL;
char *old_dom_name = NULL;
virCheckFlags(0, -1);
@ -2597,9 +2596,8 @@ testDomainRenameCallback(virDomainObjPtr privdom,
VIR_DOMAIN_EVENT_UNDEFINED_RENAMED);
/* Switch name in domain definition. */
old_dom_name = privdom->def->name;
privdom->def->name = new_dom_name;
new_dom_name = NULL;
VIR_FREE(privdom->def->name);
VIR_STEAL_PTR(privdom->def->name, new_dom_name);
event_new = virDomainEventLifecycleNewFromObj(privdom,
VIR_DOMAIN_EVENT_DEFINED,
@ -2607,7 +2605,6 @@ testDomainRenameCallback(virDomainObjPtr privdom,
ret = 0;
cleanup:
VIR_FREE(old_dom_name);
VIR_FREE(new_dom_name);
virObjectEventStateQueue(driver->eventState, event_old);
virObjectEventStateQueue(driver->eventState, event_new);