Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so simple we can just squash the code in a single function.
Signed-off-by: Jiri Denemark <jdene...@redhat.com> --- src/conf/domain_capabilities.c | 33 ++++++++++----------------------- src/conf/domain_capabilities.h | 4 ---- src/libvirt_private.syms | 1 - 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index e3bed42e59..8536fa7bfa 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -185,27 +185,6 @@ virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old) } -int -virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, - char **name, - virDomainCapsCPUUsable usable, - char ***blockers) -{ - if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, - cpuModels->nmodels, 1) < 0) - return -1; - - cpuModels->models[cpuModels->nmodels].usable = usable; - VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].name, *name); - - if (blockers) - VIR_STEAL_PTR(cpuModels->models[cpuModels->nmodels].blockers, *blockers); - - cpuModels->nmodels++; - return 0; -} - - int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, const char *name, @@ -214,6 +193,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, { VIR_AUTOFREE(char *) nameCopy = NULL; VIR_AUTOSTRINGLIST blockersCopy = NULL; + virDomainCapsCPUModelPtr cpu; if (VIR_STRDUP(nameCopy, name) < 0) return -1; @@ -221,10 +201,17 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, if (virStringListCopy(&blockersCopy, (const char **)blockers) < 0) return -1; - if (virDomainCapsCPUModelsAddSteal(cpuModels, &nameCopy, - usable, &blockersCopy) < 0) + if (VIR_RESIZE_N(cpuModels->models, cpuModels->nmodels_max, + cpuModels->nmodels, 1) < 0) return -1; + cpu = cpuModels->models + cpuModels->nmodels; + cpuModels->nmodels++; + + cpu->usable = usable; + VIR_STEAL_PTR(cpu->name, nameCopy); + VIR_STEAL_PTR(cpu->blockers, blockersCopy); + return 0; } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index ad5b22ca9a..ed47a81772 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -192,10 +192,6 @@ virDomainCapsPtr virDomainCapsNew(const char *path, virDomainCapsCPUModelsPtr virDomainCapsCPUModelsNew(size_t nmodels); virDomainCapsCPUModelsPtr virDomainCapsCPUModelsCopy(virDomainCapsCPUModelsPtr old); -int virDomainCapsCPUModelsAddSteal(virDomainCapsCPUModelsPtr cpuModels, - char **name, - virDomainCapsCPUUsable usable, - char ***blockers); int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, const char *name, virDomainCapsCPUUsable usable, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6069a3efd4..4b28ee4b28 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -190,7 +190,6 @@ virDomainAuditVcpu; # conf/domain_capabilities.h virDomainCapsCPUModelsAdd; -virDomainCapsCPUModelsAddSteal; virDomainCapsCPUModelsCopy; virDomainCapsCPUModelsGet; virDomainCapsCPUModelsNew; -- 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list