qemuMigrationCookieXMLParse: Avoid VIR_FREE when parsing lockstate

Restructure the control-flow a bit using an temporary variable to avoid
the need to use VIR_FREE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2020-10-02 10:11:03 +02:00
parent 78d330bde1
commit 49530d5277

View File

@ -1215,15 +1215,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
if ((flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) &&
virXPathBoolean("count(./lockstate) > 0", ctxt)) {
g_autofree char *lockState = NULL;
mig->lockDriver = virXPathString("string(./lockstate[1]/@driver)", ctxt);
if (!mig->lockDriver) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing lock driver name in migration cookie"));
return -1;
}
mig->lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt);
if (mig->lockState && STREQ(mig->lockState, ""))
VIR_FREE(mig->lockState);
lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt);
if (STRNEQ_NULLABLE(lockState, ""))
mig->lockState = g_steal_pointer(&lockState);
}
if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&