提交 43da417b 编写于 作者: D Daniel Henrique Barboza 提交者: Jiri Denemark

cpu_conf.c: modernize virCPUDefCopyWithoutModel and virCPUDefCopy

Use automatic cleanup of variables.
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20200522195620.3843442-2-danielhb413@gmail.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 f7187094
......@@ -227,7 +227,7 @@ virCPUDefStealModel(virCPUDefPtr dst,
virCPUDefPtr
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
{
virCPUDefPtr copy;
g_autoptr(virCPUDef) copy = NULL;
if (!cpu)
return NULL;
......@@ -246,42 +246,34 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
if (cpu->cache) {
if (VIR_ALLOC(copy->cache) < 0)
goto error;
return NULL;
*copy->cache = *cpu->cache;
}
if (cpu->tsc) {
if (VIR_ALLOC(copy->tsc) < 0)
goto error;
return NULL;
*copy->tsc = *cpu->tsc;
}
return copy;
error:
virCPUDefFree(copy);
return NULL;
return g_steal_pointer(&copy);
}
virCPUDefPtr
virCPUDefCopy(const virCPUDef *cpu)
{
virCPUDefPtr copy;
g_autoptr(virCPUDef) copy = NULL;
if (!(copy = virCPUDefCopyWithoutModel(cpu)))
return NULL;
if (virCPUDefCopyModel(copy, cpu, false) < 0)
goto error;
return copy;
return NULL;
error:
virCPUDefFree(copy);
return NULL;
return g_steal_pointer(&copy);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册