1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

cpu_arm.c: modernize virCPUarmUpdate

Use automatic cleanup of variables.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-3-danielhb413@gmail.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Daniel Henrique Barboza 2020-05-22 16:56:17 -03:00 committed by Jiri Denemark
parent 43da417b61
commit 05739fa1ad

View File

@ -415,8 +415,7 @@ static int
virCPUarmUpdate(virCPUDefPtr guest,
const virCPUDef *host)
{
int ret = -1;
virCPUDefPtr updated = NULL;
g_autoptr(virCPUDef) updated = NULL;
if (guest->mode != VIR_CPU_MODE_HOST_MODEL)
return 0;
@ -424,24 +423,21 @@ virCPUarmUpdate(virCPUDefPtr guest,
if (!host) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unknown host CPU model"));
goto cleanup;
return -1;
}
if (!(updated = virCPUDefCopyWithoutModel(guest)))
goto cleanup;
return -1;
updated->mode = VIR_CPU_MODE_CUSTOM;
if (virCPUDefCopyModel(updated, host, true) < 0)
goto cleanup;
return -1;
virCPUDefStealModel(guest, updated, false);
guest->mode = VIR_CPU_MODE_CUSTOM;
guest->match = VIR_CPU_MATCH_EXACT;
ret = 0;
cleanup:
virCPUDefFree(updated);
return ret;
return 0;
}