From 1f58d101974e33573f0a8804f9f1ff75189a1e52 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Fri, 20 Sep 2019 23:08:55 +0200 Subject: [PATCH] conf: Drop virDomainCapsCPUModelsAddSteal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so simple we can just squash the code in a single function. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- 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 164b87caab..0979711fea 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -190,27 +190,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; - cpuModels->models[cpuModels->nmodels].name = g_steal_pointer(&*name); - - if (blockers) - cpuModels->models[cpuModels->nmodels].blockers = g_steal_pointer(&*blockers); - - cpuModels->nmodels++; - return 0; -} - - int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, const char *name, @@ -219,16 +198,24 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels, { g_autofree char * nameCopy = NULL; VIR_AUTOSTRINGLIST blockersCopy = NULL; + virDomainCapsCPUModelPtr cpu; nameCopy = g_strdup(name); 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; + cpu->name = g_steal_pointer(&nameCopy); + cpu->blockers = g_steal_pointer(&blockersCopy); + return 0; } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 86cfd10e40..d69bf8d13e 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -203,10 +203,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 d03498e40f..3416438841 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -192,7 +192,6 @@ virDomainAuditVcpu; # conf/domain_capabilities.h virDomainCapsCPUModelsAdd; -virDomainCapsCPUModelsAddSteal; virDomainCapsCPUModelsCopy; virDomainCapsCPUModelsGet; virDomainCapsCPUModelsNew; -- GitLab