提交 e6e54fce 编写于 作者: J Jiri Denemark

cpu_x86: Use g_auto* in x86Encode

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 5b45d2cf
...@@ -2188,12 +2188,12 @@ x86Encode(virArch arch, ...@@ -2188,12 +2188,12 @@ x86Encode(virArch arch,
virCPUDataPtr *vendor) virCPUDataPtr *vendor)
{ {
virCPUx86MapPtr map = NULL; virCPUx86MapPtr map = NULL;
virCPUDataPtr data_forced = NULL; g_autoptr(virCPUData) data_forced = NULL;
virCPUDataPtr data_required = NULL; g_autoptr(virCPUData) data_required = NULL;
virCPUDataPtr data_optional = NULL; g_autoptr(virCPUData) data_optional = NULL;
virCPUDataPtr data_disabled = NULL; g_autoptr(virCPUData) data_disabled = NULL;
virCPUDataPtr data_forbidden = NULL; g_autoptr(virCPUData) data_forbidden = NULL;
virCPUDataPtr data_vendor = NULL; g_autoptr(virCPUData) data_vendor = NULL;
if (forced) if (forced)
*forced = NULL; *forced = NULL;
...@@ -2209,37 +2209,37 @@ x86Encode(virArch arch, ...@@ -2209,37 +2209,37 @@ x86Encode(virArch arch,
*vendor = NULL; *vendor = NULL;
if (!(map = virCPUx86GetMap())) if (!(map = virCPUx86GetMap()))
goto error; return -1;
if (forced && if (forced &&
(!(data_forced = virCPUDataNew(arch)) || (!(data_forced = virCPUDataNew(arch)) ||
x86EncodePolicy(&data_forced->data.x86, cpu, map, x86EncodePolicy(&data_forced->data.x86, cpu, map,
VIR_CPU_FEATURE_FORCE) < 0)) VIR_CPU_FEATURE_FORCE) < 0))
goto error; return -1;
if (required && if (required &&
(!(data_required = virCPUDataNew(arch)) || (!(data_required = virCPUDataNew(arch)) ||
x86EncodePolicy(&data_required->data.x86, cpu, map, x86EncodePolicy(&data_required->data.x86, cpu, map,
VIR_CPU_FEATURE_REQUIRE) < 0)) VIR_CPU_FEATURE_REQUIRE) < 0))
goto error; return -1;
if (optional && if (optional &&
(!(data_optional = virCPUDataNew(arch)) || (!(data_optional = virCPUDataNew(arch)) ||
x86EncodePolicy(&data_optional->data.x86, cpu, map, x86EncodePolicy(&data_optional->data.x86, cpu, map,
VIR_CPU_FEATURE_OPTIONAL) < 0)) VIR_CPU_FEATURE_OPTIONAL) < 0))
goto error; return -1;
if (disabled && if (disabled &&
(!(data_disabled = virCPUDataNew(arch)) || (!(data_disabled = virCPUDataNew(arch)) ||
x86EncodePolicy(&data_disabled->data.x86, cpu, map, x86EncodePolicy(&data_disabled->data.x86, cpu, map,
VIR_CPU_FEATURE_DISABLE) < 0)) VIR_CPU_FEATURE_DISABLE) < 0))
goto error; return -1;
if (forbidden && if (forbidden &&
(!(data_forbidden = virCPUDataNew(arch)) || (!(data_forbidden = virCPUDataNew(arch)) ||
x86EncodePolicy(&data_forbidden->data.x86, cpu, map, x86EncodePolicy(&data_forbidden->data.x86, cpu, map,
VIR_CPU_FEATURE_FORBID) < 0)) VIR_CPU_FEATURE_FORBID) < 0))
goto error; return -1;
if (vendor) { if (vendor) {
virCPUx86VendorPtr v = NULL; virCPUx86VendorPtr v = NULL;
...@@ -2247,39 +2247,30 @@ x86Encode(virArch arch, ...@@ -2247,39 +2247,30 @@ x86Encode(virArch arch,
if (cpu->vendor && !(v = x86VendorFind(map, cpu->vendor))) { if (cpu->vendor && !(v = x86VendorFind(map, cpu->vendor))) {
virReportError(VIR_ERR_OPERATION_FAILED, virReportError(VIR_ERR_OPERATION_FAILED,
_("CPU vendor %s not found"), cpu->vendor); _("CPU vendor %s not found"), cpu->vendor);
goto error; return -1;
} }
if (!(data_vendor = virCPUDataNew(arch))) if (!(data_vendor = virCPUDataNew(arch)))
goto error; return -1;
if (v && virCPUx86DataAdd(data_vendor, &v->data) < 0) if (v && virCPUx86DataAdd(data_vendor, &v->data) < 0)
goto error; return -1;
} }
if (forced) if (forced)
*forced = data_forced; *forced = g_steal_pointer(&data_forced);
if (required) if (required)
*required = data_required; *required = g_steal_pointer(&data_required);
if (optional) if (optional)
*optional = data_optional; *optional = g_steal_pointer(&data_optional);
if (disabled) if (disabled)
*disabled = data_disabled; *disabled = g_steal_pointer(&data_disabled);
if (forbidden) if (forbidden)
*forbidden = data_forbidden; *forbidden = g_steal_pointer(&data_forbidden);
if (vendor) if (vendor)
*vendor = data_vendor; *vendor = g_steal_pointer(&data_vendor);
return 0; return 0;
error:
virCPUx86DataFree(data_forced);
virCPUx86DataFree(data_required);
virCPUx86DataFree(data_optional);
virCPUx86DataFree(data_disabled);
virCPUx86DataFree(data_forbidden);
virCPUx86DataFree(data_vendor);
return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册