[PATCH v3 20/52] conf: Drop virDomainCapsCPUModelsAddSteal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both virDomainCapsCPUModelsAdd and virDomainCapsCPUModelsAddSteal are so
simple we can just squash the code in a single function.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change
    
    Version 3:
    - g_steal_pointer

 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 fdeb468570..da47643f34 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -181,27 +181,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,
@@ -210,6 +189,7 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
 {
     g_autofree char * nameCopy = NULL;
     VIR_AUTOSTRINGLIST blockersCopy = NULL;
+    virDomainCapsCPUModelPtr cpu;
 
     if (VIR_STRDUP(nameCopy, name) < 0)
         return -1;
@@ -217,10 +197,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;
+    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 d989f76d41..d93c06c2e1 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -196,10 +196,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 fe42c6769f..df9d07d297 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -191,7 +191,6 @@ virDomainAuditVcpu;
 
 # conf/domain_capabilities.h
 virDomainCapsCPUModelsAdd;
-virDomainCapsCPUModelsAddSteal;
 virDomainCapsCPUModelsCopy;
 virDomainCapsCPUModelsGet;
 virDomainCapsCPUModelsNew;
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux