提交 9bb9cbf6 编写于 作者: J Jiri Denemark

cpu_x86: Use g_auto* in x86Decode

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 bc62d7a4
...@@ -2032,15 +2032,12 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2032,15 +2032,12 @@ x86Decode(virCPUDefPtr cpu,
const char *preferred, const char *preferred,
bool migratable) bool migratable)
{ {
int ret = -1;
virCPUx86MapPtr map; virCPUx86MapPtr map;
virCPUx86ModelPtr candidate; virCPUx86ModelPtr candidate;
virCPUDefPtr cpuCandidate; virCPUDefPtr cpuCandidate;
virCPUx86ModelPtr model = NULL; virCPUx86ModelPtr model = NULL;
virCPUDefPtr cpuModel = NULL; g_autoptr(virCPUDef) cpuModel = NULL;
virCPUx86Data data = VIR_CPU_X86_DATA_INIT; g_auto(virCPUx86Data) data = VIR_CPU_X86_DATA_INIT;
virCPUx86Data copy = VIR_CPU_X86_DATA_INIT;
virCPUx86Data features = VIR_CPU_X86_DATA_INIT;
virCPUx86VendorPtr vendor; virCPUx86VendorPtr vendor;
virDomainCapsCPUModelPtr hvModel = NULL; virDomainCapsCPUModelPtr hvModel = NULL;
g_autofree char *sigs = NULL; g_autofree char *sigs = NULL;
...@@ -2054,7 +2051,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2054,7 +2051,7 @@ x86Decode(virCPUDefPtr cpu,
x86DataCopy(&data, cpuData); x86DataCopy(&data, cpuData);
if (!(map = virCPUx86GetMap())) if (!(map = virCPUx86GetMap()))
goto cleanup; return -1;
vendor = x86DataToVendor(&data, map); vendor = x86DataToVendor(&data, map);
signature = x86DataToSignature(&data); signature = x86DataToSignature(&data);
...@@ -2073,7 +2070,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2073,7 +2070,7 @@ x86Decode(virCPUDefPtr cpu,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("CPU model %s is not supported by hypervisor"), _("CPU model %s is not supported by hypervisor"),
preferred); preferred);
goto cleanup; return -1;
} else { } else {
VIR_WARN("Preferred CPU model %s not allowed by" VIR_WARN("Preferred CPU model %s not allowed by"
" hypervisor; closest supported model will be" " hypervisor; closest supported model will be"
...@@ -2096,7 +2093,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2096,7 +2093,7 @@ x86Decode(virCPUDefPtr cpu,
} }
if (!(cpuCandidate = x86DataToCPU(&data, candidate, map, hvModel))) if (!(cpuCandidate = x86DataToCPU(&data, candidate, map, hvModel)))
goto cleanup; return -1;
cpuCandidate->type = cpu->type; cpuCandidate->type = cpu->type;
if ((rc = x86DecodeUseCandidate(model, cpuModel, if ((rc = x86DecodeUseCandidate(model, cpuModel,
...@@ -2115,7 +2112,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2115,7 +2112,7 @@ x86Decode(virCPUDefPtr cpu,
if (!cpuModel) { if (!cpuModel) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Cannot find suitable CPU model for given data")); "%s", _("Cannot find suitable CPU model for given data"));
goto cleanup; return -1;
} }
/* Remove non-migratable features if requested /* Remove non-migratable features if requested
...@@ -2149,14 +2146,7 @@ x86Decode(virCPUDefPtr cpu, ...@@ -2149,14 +2146,7 @@ x86Decode(virCPUDefPtr cpu,
cpu->nfeatures_max = cpuModel->nfeatures_max; cpu->nfeatures_max = cpuModel->nfeatures_max;
cpuModel->nfeatures_max = 0; cpuModel->nfeatures_max = 0;
ret = 0; return 0;
cleanup:
virCPUDefFree(cpuModel);
virCPUx86DataClear(&data);
virCPUx86DataClear(&copy);
virCPUx86DataClear(&features);
return ret;
} }
static int static int
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册