qemu: refactor virQEMUCapsNewCopy

Use g_auto and remove pointless labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-23 16:34:59 +02:00
parent 37574d5f17
commit d45af4ea45

View File

@ -1953,7 +1953,7 @@ virQEMUCapsAccelCopy(virQEMUCapsAccel *dst,
virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps) virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
{ {
virQEMUCaps *ret = virQEMUCapsNewBinary(qemuCaps->binary); g_autoptr(virQEMUCaps) ret = virQEMUCapsNewBinary(qemuCaps->binary);
size_t i; size_t i;
if (!ret) if (!ret)
@ -1980,7 +1980,7 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 || if (virQEMUCapsAccelCopy(&ret->kvm, &qemuCaps->kvm) < 0 ||
virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0) virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0)
goto error; return NULL;
ret->gicCapabilities = g_new0(virGICCapability, qemuCaps->ngicCapabilities); ret->gicCapabilities = g_new0(virGICCapability, qemuCaps->ngicCapabilities);
ret->ngicCapabilities = qemuCaps->ngicCapabilities; ret->ngicCapabilities = qemuCaps->ngicCapabilities;
@ -1990,13 +1990,9 @@ virQEMUCaps *virQEMUCapsNewCopy(virQEMUCaps *qemuCaps)
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST) && if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST) &&
virQEMUCapsSEVInfoCopy(&ret->sevCapabilities, virQEMUCapsSEVInfoCopy(&ret->sevCapabilities,
qemuCaps->sevCapabilities) < 0) qemuCaps->sevCapabilities) < 0)
goto error; return NULL;
return ret; return g_steal_pointer(&ret);
error:
virObjectUnref(ret);
return NULL;
} }