g_autoptr(virCPUppc64Map) map = NULL;
g_autoptr(virCPUppc64Model) host_model = NULL;
g_autoptr(virCPUppc64Model) guest_model = NULL;
- virCPUDefPtr cpu = NULL;
- virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
+ g_autoptr(virCPUDef) cpu = NULL;
virArch arch;
size_t i;
/* Ensure existing configurations are handled correctly */
if (!(cpu = virCPUDefCopy(other)) ||
virCPUppc64ConvertLegacy(cpu) < 0)
- goto cleanup;
+ return VIR_CPU_COMPARE_ERROR;
if (cpu->arch != VIR_ARCH_NONE) {
bool found = false;
*message = g_strdup_printf(_("CPU arch %s does not match host arch"),
virArchToString(cpu->arch));
- ret = VIR_CPU_COMPARE_INCOMPATIBLE;
- goto cleanup;
+ return VIR_CPU_COMPARE_INCOMPATIBLE;
}
arch = cpu->arch;
} else {
cpu->vendor);
}
- ret = VIR_CPU_COMPARE_INCOMPATIBLE;
- goto cleanup;
+ return VIR_CPU_COMPARE_INCOMPATIBLE;
}
if (!(map = ppc64LoadMap()))
- goto cleanup;
+ return VIR_CPU_COMPARE_ERROR;
/* Host CPU information */
if (!(host_model = ppc64ModelFromCPU(host, map)))
- goto cleanup;
+ return VIR_CPU_COMPARE_ERROR;
if (cpu->type == VIR_CPU_TYPE_GUEST) {
/* Guest CPU information */
/* host-model only:
* we need to take compatibility modes into account */
tmp = ppc64CheckCompatibilityMode(host->model, cpu->model);
- if (tmp != VIR_CPU_COMPARE_IDENTICAL) {
- ret = tmp;
- goto cleanup;
- }
+ if (tmp != VIR_CPU_COMPARE_IDENTICAL)
+ return tmp;
G_GNUC_FALLTHROUGH;
case VIR_CPU_MODE_HOST_PASSTHROUGH:
}
if (!guest_model)
- goto cleanup;
+ return VIR_CPU_COMPARE_ERROR;
if (STRNEQ(guest_model->name, host_model->name)) {
VIR_DEBUG("host CPU model does not match required CPU model %s",
guest_model->name);
}
- ret = VIR_CPU_COMPARE_INCOMPATIBLE;
- goto cleanup;
+ return VIR_CPU_COMPARE_INCOMPATIBLE;
}
if (guestData)
if (!(*guestData = ppc64MakeCPUData(arch, &guest_model->data)))
- goto cleanup;
+ return VIR_CPU_COMPARE_ERROR;
- ret = VIR_CPU_COMPARE_IDENTICAL;
-
- cleanup:
- virCPUDefFree(cpu);
- return ret;
+ return VIR_CPU_COMPARE_IDENTICAL;
}
static virCPUCompareResult
g_autoptr(virCPUppc64Map) map = NULL;
const virCPUppc64Model *model;
const virCPUppc64Vendor *vendor = NULL;
- virCPUDefPtr cpu = NULL;
+ g_autoptr(virCPUDef) cpu = NULL;
size_t i;
if (!(map = ppc64LoadMap()))
- goto error;
+ return NULL;
if (!(model = ppc64ModelFind(map, cpus[0]->model))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown CPU model %s"), cpus[0]->model);
- goto error;
+ return NULL;
}
for (i = 0; i < ncpus; i++) {
if (STRNEQ(cpus[i]->model, model->name)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("CPUs are incompatible"));
- goto error;
+ return NULL;
}
if (!cpus[i]->vendor)
if (!(vnd = ppc64VendorFind(map, cpus[i]->vendor))) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("Unknown CPU vendor %s"), cpus[i]->vendor);
- goto error;
+ return NULL;
}
if (model->vendor) {
"vendor %s"),
model->vendor->name, model->name,
vnd->name);
- goto error;
+ return NULL;
}
} else if (vendor) {
if (vendor != vnd) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("CPU vendors do not match"));
- goto error;
+ return NULL;
}
} else {
vendor = vnd;
cpu->match = VIR_CPU_MATCH_EXACT;
cpu->fallback = VIR_CPU_FALLBACK_FORBID;
- return cpu;
-
- error:
- virCPUDefFree(cpu);
- cpu = NULL;
- return NULL;
+ return g_steal_pointer(&cpu);
}
static int