mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00: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 *
|
virCPUDef *
|
||||||
virCPUDefCopy(const virCPUDef *cpu)
|
virCPUDefCopy(const virCPUDef *cpu)
|
||||||
{
|
{
|
||||||
g_autoptr(virCPUDef) copy = NULL;
|
g_autoptr(virCPUDef) copy = virCPUDefCopyWithoutModel(cpu);
|
||||||
|
|
||||||
if (!cpu)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
copy = virCPUDefCopyWithoutModel(cpu);
|
|
||||||
|
|
||||||
virCPUDefCopyModel(copy, cpu, false);
|
virCPUDefCopyModel(copy, cpu, false);
|
||||||
|
|
||||||
|
@ -201,7 +201,8 @@ virCPUDefStealModel(virCPUDef *dst,
|
|||||||
bool keepVendor);
|
bool keepVendor);
|
||||||
|
|
||||||
virCPUDef *
|
virCPUDef *
|
||||||
virCPUDefCopy(const virCPUDef *cpu);
|
virCPUDefCopy(const virCPUDef *cpu)
|
||||||
|
ATTRIBUTE_NONNULL(1);
|
||||||
|
|
||||||
virCPUDef *
|
virCPUDef *
|
||||||
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||||
|
@ -406,8 +406,12 @@ ppc64Compute(virCPUDef *host,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
/* Ensure existing configurations are handled correctly */
|
/* Ensure existing configurations are handled correctly */
|
||||||
if (!(cpu = virCPUDefCopy(other)) ||
|
if (!other)
|
||||||
virCPUppc64ConvertLegacy(cpu) < 0)
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
|
cpu = virCPUDefCopy(other);
|
||||||
|
|
||||||
|
if (virCPUppc64ConvertLegacy(cpu) < 0)
|
||||||
return VIR_CPU_COMPARE_ERROR;
|
return VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
if (cpu->arch != VIR_ARCH_NONE) {
|
if (cpu->arch != VIR_ARCH_NONE) {
|
||||||
|
@ -3206,7 +3206,7 @@ static int
|
|||||||
virCPUx86ExpandFeatures(virCPUDef *cpu)
|
virCPUx86ExpandFeatures(virCPUDef *cpu)
|
||||||
{
|
{
|
||||||
virCPUx86Map *map;
|
virCPUx86Map *map;
|
||||||
g_autoptr(virCPUDef) expanded = NULL;
|
g_autoptr(virCPUDef) expanded = virCPUDefCopy(cpu);
|
||||||
g_autoptr(virCPUx86Model) model = NULL;
|
g_autoptr(virCPUx86Model) model = NULL;
|
||||||
bool host = cpu->type == VIR_CPU_TYPE_HOST;
|
bool host = cpu->type == VIR_CPU_TYPE_HOST;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -3214,9 +3214,6 @@ virCPUx86ExpandFeatures(virCPUDef *cpu)
|
|||||||
if (!(map = virCPUx86GetMap()))
|
if (!(map = virCPUx86GetMap()))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(expanded = virCPUDefCopy(cpu)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
virCPUDefFreeFeatures(expanded);
|
virCPUDefFreeFeatures(expanded);
|
||||||
|
|
||||||
if (!(model = x86ModelFind(map, cpu->model))) {
|
if (!(model = x86ModelFind(map, cpu->model))) {
|
||||||
|
@ -1856,17 +1856,14 @@ virQEMUCapsHostCPUDataCopy(virQEMUCapsHostCPUData *dst,
|
|||||||
!(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
|
!(dst->info = qemuMonitorCPUModelInfoCopy(src->info)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (src->reported &&
|
if (src->reported)
|
||||||
!(dst->reported = virCPUDefCopy(src->reported)))
|
dst->reported = virCPUDefCopy(src->reported);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (src->migratable &&
|
if (src->migratable)
|
||||||
!(dst->migratable = virCPUDefCopy(src->migratable)))
|
dst->migratable = virCPUDefCopy(src->migratable);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (src->full &&
|
if (src->full)
|
||||||
!(dst->full = virCPUDefCopy(src->full)))
|
dst->full = virCPUDefCopy(src->full);
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3886,8 +3883,9 @@ virQEMUCapsInitHostCPUModel(virQEMUCaps *qemuCaps,
|
|||||||
if (!(fullCPU = virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL)))
|
if (!(fullCPU = virQEMUCapsProbeHostCPU(qemuCaps->arch, NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(cpuExpanded = virCPUDefCopy(cpu)) ||
|
cpuExpanded = virCPUDefCopy(cpu);
|
||||||
virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
|
||||||
|
if (virCPUExpandFeatures(qemuCaps->arch, cpuExpanded) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < cpuExpanded->nfeatures; i++) {
|
for (i = 0; i < cpuExpanded->nfeatures; i++) {
|
||||||
|
@ -542,8 +542,7 @@ qemuMigrationCookieAddCPU(qemuMigrationCookie *mig,
|
|||||||
if (mig->cpu)
|
if (mig->cpu)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(mig->cpu = virCPUDefCopy(vm->def->cpu)))
|
mig->cpu = virCPUDefCopy(vm->def->cpu);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuDomainMakeCPUMigratable(mig->cpu) < 0)
|
if (qemuDomainMakeCPUMigratable(mig->cpu) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -4464,8 +4464,7 @@ qemuProcessUpdateLiveGuestCPU(virDomainObj *vm,
|
|||||||
!def->cpu->model))
|
!def->cpu->model))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!(orig = virCPUDefCopy(def->cpu)))
|
orig = virCPUDefCopy(def->cpu);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled)) < 0) {
|
if ((rc = virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -581,12 +581,11 @@ int qemuTestDriverInit(virQEMUDriver *driver)
|
|||||||
|
|
||||||
memset(driver, 0, sizeof(*driver));
|
memset(driver, 0, sizeof(*driver));
|
||||||
|
|
||||||
if (!(cpuDefault = virCPUDefCopy(&cpuDefaultData)) ||
|
cpuDefault = virCPUDefCopy(&cpuDefaultData);
|
||||||
!(cpuHaswell = virCPUDefCopy(&cpuHaswellData)) ||
|
cpuHaswell = virCPUDefCopy(&cpuHaswellData);
|
||||||
!(cpuPower8 = virCPUDefCopy(&cpuPower8Data)) ||
|
cpuPower8 = virCPUDefCopy(&cpuPower8Data);
|
||||||
!(cpuPower9 = virCPUDefCopy(&cpuPower9Data)) ||
|
cpuPower9 = virCPUDefCopy(&cpuPower9Data);
|
||||||
!(cpuPower10 = virCPUDefCopy(&cpuPower10Data)))
|
cpuPower10 = virCPUDefCopy(&cpuPower10Data);
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (virMutexInit(&driver->lock) < 0)
|
if (virMutexInit(&driver->lock) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user