mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
conf: cpu: Remove NULL check from virCPUDefCopy
Make all callers always pass a valid pointer which in turn allows us to remove return value check from the callers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f9b97f6b10
commit
f6967e2b77
@ -271,12 +271,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||
virCPUDef *
|
||||
virCPUDefCopy(const virCPUDef *cpu)
|
||||
{
|
||||
g_autoptr(virCPUDef) copy = NULL;
|
||||
|
||||
if (!cpu)
|
||||
return NULL;
|
||||
|
||||
copy = virCPUDefCopyWithoutModel(cpu);
|
||||
g_autoptr(virCPUDef) copy = virCPUDefCopyWithoutModel(cpu);
|
||||
|
||||
virCPUDefCopyModel(copy, cpu, false);
|
||||
|
||||
|
@ -201,7 +201,8 @@ virCPUDefStealModel(virCPUDef *dst,
|
||||
bool keepVendor);
|
||||
|
||||
virCPUDef *
|
||||
virCPUDefCopy(const virCPUDef *cpu);
|
||||
virCPUDefCopy(const virCPUDef *cpu)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
virCPUDef *
|
||||
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||
|
@ -406,8 +406,12 @@ ppc64Compute(virCPUDef *host,
|
||||
size_t i;
|
||||
|
||||
/* Ensure existing configurations are handled correctly */
|
||||
if (!(cpu = virCPUDefCopy(other)) ||
|
||||
virCPUppc64ConvertLegacy(cpu) < 0)
|
||||
if (!other)
|
||||
return VIR_CPU_COMPARE_ERROR;
|
||||
|
||||
cpu = virCPUDefCopy(other);
|
||||
|
||||
if (virCPUppc64ConvertLegacy(cpu) < 0)
|
||||
return VIR_CPU_COMPARE_ERROR;
|
||||
|
||||
if (cpu->arch != VIR_ARCH_NONE) {
|
||||
|
@ -3206,7 +3206,7 @@ static int
|
||||
virCPUx86ExpandFeatures(virCPUDef *cpu)
|
||||
{
|
||||
virCPUx86Map *map;
|
||||
g_autoptr(virCPUDef) expanded = NULL;
|
||||
g_autoptr(virCPUDef) expanded = virCPUDefCopy(cpu);
|
||||
g_autoptr(virCPUx86Model) model = NULL;
|
||||
bool host = cpu->type == VIR_CPU_TYPE_HOST;
|
||||
size_t i;
|
||||
@ -3214,9 +3214,6 @@ virCPUx86ExpandFeatures(virCPUDef *cpu)
|
||||
if (!(map = virCPUx86GetMap()))
|
||||
return -1;
|
||||
|
||||
if (!(expanded = virCPUDefCopy(cpu)))
|
||||
return -1;
|
||||
|
||||
virCPUDefFreeFeatures(expanded);
|
||||
|
||||
if (!(model = x86ModelFind(map, cpu->model))) {
|
||||
|
@ -1856,17 +1856,14 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUData *dst,
|
||||
!(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
|
||||
return -1;
|
||||
|
||||
if (src->reported &&
|
||||
!(dst->reported = virCPUDefCopy(src->reported)))
|
||||
return -1;
|
||||
if (src->reported)
|
||||
dst->reported = virCPUDefCopy(src->reported);
|
||||
|
||||
if (src->migratable &&
|
||||
!(dst->migratable = virCPUDefCopy(src->migratable)))
|
||||
return -1;
|
||||
if (src->migratable)
|
||||
dst->migratable = virCPUDefCopy(src->migratable);
|
||||
|
||||
if (src->full &&
|
||||
!(dst->full = virCPUDefCopy(src->full)))
|
||||
return -1;
|
||||
if (src->full)
|
||||
dst->full = virCPUDefCopy(src->full);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -3886,8 +3883,9 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps,
|
||||
if (!(fullCPU = virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL)))
|
||||
goto error;
|
||||
|
||||
if (!(cpuExpanded = virCPUDefCopy(cpu)) ||
|
||||
virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
||||
cpuExpanded = virCPUDefCopy(cpu);
|
||||
|
||||
if (virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < cpuExpanded->nfeatures; i++) {
|
||||
|
@ -542,8 +542,7 @@ qemuMigrationCookieAddCPU(qemuMigrationCookie *mig,
|
||||
if (mig->cpu)
|
||||
return 0;
|
||||
|
||||
if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
|
||||
return -1;
|
||||
mig->cpu = virCPUDefCopy(vm->def->cpu);
|
||||
|
||||
if (qemuDomainMakeCPUMigratable(mig->cpu) < 0)
|
||||
return -1;
|
||||
|
@ -4464,8 +4464,7 @@ qemuProcessUpdateLiveGuestCPU(virDomainObj *vm,
|
||||
!def->cpu->model))
|
||||
return 0;
|
||||
|
||||
if (!(orig = virCPUDefCopy(def->cpu)))
|
||||
return -1;
|
||||
orig = virCPUDefCopy(def->cpu);
|
||||
|
||||
if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled)) < 0) {
|
||||
return -1;
|
||||
|
@ -581,12 +581,11 @@ int qemuTestDriverInit(virQEMUDriver *driver)
|
||||
|
||||
memset(driver, 0, sizeof(*driver));
|
||||
|
||||
if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
|
||||
!(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) ||
|
||||
!(cpuPower8 = virCPUDefCopy(&cpuPower8Data)) ||
|
||||
!(cpuPower9 = virCPUDefCopy(&cpuPower9Data)) ||
|
||||
!(cpuPower10 = virCPUDefCopy(&cpuPower10Data)))
|
||||
return -1;
|
||||
cpuDefault = virCPUDefCopy(&cpuDefaultData);
|
||||
cpuHaswell = virCPUDefCopy(&cpuHaswellData);
|
||||
cpuPower8 = virCPUDefCopy(&cpuPower8Data);
|
||||
cpuPower9 = virCPUDefCopy(&cpuPower9Data);
|
||||
cpuPower10 = virCPUDefCopy(&cpuPower10Data);
|
||||
|
||||
if (virMutexInit(&driver->lock) < 0)
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user