mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
conf: cpu: Remove NULL check from virCPUDefCopyWithoutModel
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
8432392f51
commit
f9b97f6b10
@ -233,9 +233,6 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||
{
|
||||
g_autoptr(virCPUDef) copy = NULL;
|
||||
|
||||
if (!cpu)
|
||||
return NULL;
|
||||
|
||||
copy = virCPUDefNew();
|
||||
copy->type = cpu->type;
|
||||
copy->mode = cpu->mode;
|
||||
@ -276,9 +273,11 @@ virCPUDefCopy(const virCPUDef *cpu)
|
||||
{
|
||||
g_autoptr(virCPUDef) copy = NULL;
|
||||
|
||||
if (!(copy = virCPUDefCopyWithoutModel(cpu)))
|
||||
if (!cpu)
|
||||
return NULL;
|
||||
|
||||
copy = virCPUDefCopyWithoutModel(cpu);
|
||||
|
||||
virCPUDefCopyModel(copy, cpu, false);
|
||||
|
||||
return g_steal_pointer(©);
|
||||
|
@ -204,7 +204,8 @@ virCPUDef *
|
||||
virCPUDefCopy(const virCPUDef *cpu);
|
||||
|
||||
virCPUDef *
|
||||
virCPUDefCopyWithoutModel(const virCPUDef *cpu);
|
||||
virCPUDefCopyWithoutModel(const virCPUDef *cpu)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
||||
int
|
||||
virCPUDefParseXMLString(const char *xml,
|
||||
|
@ -450,7 +450,7 @@ virCPUarmUpdate(virCPUDef *guest,
|
||||
const virCPUDef *host,
|
||||
bool relative)
|
||||
{
|
||||
g_autoptr(virCPUDef) updated = NULL;
|
||||
g_autoptr(virCPUDef) updated = virCPUDefCopyWithoutModel(guest);
|
||||
|
||||
if (!relative || guest->mode != VIR_CPU_MODE_HOST_MODEL)
|
||||
return 0;
|
||||
@ -461,9 +461,6 @@ virCPUarmUpdate(virCPUDef *guest,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(updated = virCPUDefCopyWithoutModel(guest)))
|
||||
return -1;
|
||||
|
||||
updated->mode = VIR_CPU_MODE_CUSTOM;
|
||||
virCPUDefCopyModel(updated, host, true);
|
||||
|
||||
|
@ -44,7 +44,7 @@ virCPUs390Update(virCPUDef *guest,
|
||||
const virCPUDef *host,
|
||||
bool relative)
|
||||
{
|
||||
g_autoptr(virCPUDef) updated = NULL;
|
||||
g_autoptr(virCPUDef) updated = virCPUDefCopyWithoutModel(guest);
|
||||
size_t i;
|
||||
|
||||
if (!relative)
|
||||
@ -68,9 +68,6 @@ virCPUs390Update(virCPUDef *guest,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(updated = virCPUDefCopyWithoutModel(guest)))
|
||||
return -1;
|
||||
|
||||
updated->mode = VIR_CPU_MODE_CUSTOM;
|
||||
virCPUDefCopyModel(updated, host, true);
|
||||
|
||||
|
@ -2935,12 +2935,9 @@ static int
|
||||
x86UpdateHostModel(virCPUDef *guest,
|
||||
const virCPUDef *host)
|
||||
{
|
||||
g_autoptr(virCPUDef) updated = NULL;
|
||||
g_autoptr(virCPUDef) updated = virCPUDefCopyWithoutModel(host);
|
||||
size_t i;
|
||||
|
||||
if (!(updated = virCPUDefCopyWithoutModel(host)))
|
||||
return -1;
|
||||
|
||||
updated->type = VIR_CPU_TYPE_GUEST;
|
||||
updated->mode = VIR_CPU_MODE_CUSTOM;
|
||||
virCPUDefCopyModel(updated, host, true);
|
||||
@ -3169,7 +3166,7 @@ static int
|
||||
virCPUx86Translate(virCPUDef *cpu,
|
||||
virDomainCapsCPUModels *models)
|
||||
{
|
||||
g_autoptr(virCPUDef) translated = NULL;
|
||||
g_autoptr(virCPUDef) translated = virCPUDefCopyWithoutModel(cpu);
|
||||
virCPUx86Map *map;
|
||||
g_autoptr(virCPUx86Model) model = NULL;
|
||||
size_t i;
|
||||
@ -3191,9 +3188,6 @@ virCPUx86Translate(virCPUDef *cpu,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
|
||||
return -1;
|
||||
|
||||
if (x86Decode(translated, &model->data, models, NULL, false) < 0)
|
||||
return -1;
|
||||
|
||||
@ -3280,9 +3274,10 @@ virCPUx86CopyMigratable(virCPUDef *cpu)
|
||||
if (!(map = virCPUx86GetMap()))
|
||||
return NULL;
|
||||
|
||||
if (!(copy = virCPUDefCopyWithoutModel(cpu)))
|
||||
if (!cpu)
|
||||
return NULL;
|
||||
|
||||
copy = virCPUDefCopyWithoutModel(cpu);
|
||||
virCPUDefCopyModelFilter(copy, cpu, false, x86FeatureFilterMigratable, map);
|
||||
|
||||
return g_steal_pointer(©);
|
||||
|
@ -10822,9 +10822,6 @@ qemuDomainFixupCPUs(virDomainObj *vm,
|
||||
if (virCPUDefFindFeature(vm->def->cpu, "cmt")) {
|
||||
g_autoptr(virCPUDef) fixedCPU = virCPUDefCopyWithoutModel(vm->def->cpu);
|
||||
|
||||
if (!fixedCPU)
|
||||
return -1;
|
||||
|
||||
virCPUDefCopyModelFilter(fixedCPU, vm->def->cpu, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch);
|
||||
|
||||
@ -10835,9 +10832,6 @@ qemuDomainFixupCPUs(virDomainObj *vm,
|
||||
if (virCPUDefFindFeature(*origCPU, "cmt")) {
|
||||
g_autoptr(virCPUDef) fixedOrig = virCPUDefCopyWithoutModel(*origCPU);
|
||||
|
||||
if (!fixedOrig)
|
||||
return -1;
|
||||
|
||||
virCPUDefCopyModelFilter(fixedOrig, *origCPU, false,
|
||||
virQEMUCapsCPUFilterFeatures, &arch);
|
||||
|
||||
|
@ -12171,8 +12171,7 @@ qemuConnectBaselineCPU(virConnectPtr conn G_GNUC_UNUSED,
|
||||
!!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cpu = virCPUDefCopyWithoutModel(baseline)))
|
||||
goto cleanup;
|
||||
cpu = virCPUDefCopyWithoutModel(baseline);
|
||||
|
||||
virCPUDefCopyModelFilter(cpu, baseline, false, virQEMUCapsCPUFilterFeatures,
|
||||
&cpus[0]->arch);
|
||||
|
@ -8829,8 +8829,7 @@ qemuProcessRefreshCPU(virQEMUDriver *driver,
|
||||
if (!(hostmig = virCPUCopyMigratable(host->arch, host)))
|
||||
return -1;
|
||||
|
||||
if (!(cpu = virCPUDefCopyWithoutModel(hostmig)))
|
||||
return -1;
|
||||
cpu = virCPUDefCopyWithoutModel(hostmig);
|
||||
|
||||
virCPUDefCopyModelFilter(cpu, hostmig, false, virQEMUCapsCPUFilterFeatures,
|
||||
&host->arch);
|
||||
|
Loading…
Reference in New Issue
Block a user