mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
cpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy
Use automatic cleanup of variables. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Message-Id: <20200522195620.3843442-2-danielhb413@gmail.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
f718709431
commit
43da417b61
@ -227,7 +227,7 @@ virCPUDefStealModel(virCPUDefPtr dst,
|
|||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||||
{
|
{
|
||||||
virCPUDefPtr copy;
|
g_autoptr(virCPUDef) copy = NULL;
|
||||||
|
|
||||||
if (!cpu)
|
if (!cpu)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -246,42 +246,34 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
|||||||
|
|
||||||
if (cpu->cache) {
|
if (cpu->cache) {
|
||||||
if (VIR_ALLOC(copy->cache) < 0)
|
if (VIR_ALLOC(copy->cache) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
*copy->cache = *cpu->cache;
|
*copy->cache = *cpu->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpu->tsc) {
|
if (cpu->tsc) {
|
||||||
if (VIR_ALLOC(copy->tsc) < 0)
|
if (VIR_ALLOC(copy->tsc) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
*copy->tsc = *cpu->tsc;
|
*copy->tsc = *cpu->tsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return copy;
|
return g_steal_pointer(©);
|
||||||
|
|
||||||
error:
|
|
||||||
virCPUDefFree(copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
virCPUDefCopy(const virCPUDef *cpu)
|
virCPUDefCopy(const virCPUDef *cpu)
|
||||||
{
|
{
|
||||||
virCPUDefPtr copy;
|
g_autoptr(virCPUDef) copy = NULL;
|
||||||
|
|
||||||
if (!(copy = virCPUDefCopyWithoutModel(cpu)))
|
if (!(copy = virCPUDefCopyWithoutModel(cpu)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virCPUDefCopyModel(copy, cpu, false) < 0)
|
if (virCPUDefCopyModel(copy, cpu, false) < 0)
|
||||||
goto error;
|
return NULL;
|
||||||
|
|
||||||
return copy;
|
return g_steal_pointer(©);
|
||||||
|
|
||||||
error:
|
|
||||||
virCPUDefFree(copy);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user