[PATCH v2 05/37] Adapt to VIR_STRDUP in src/cpu/*

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

 



---
 src/cpu/cpu_generic.c |  6 +++---
 src/cpu/cpu_map.c     |  3 ++-
 src/cpu/cpu_powerpc.c | 10 +++++-----
 src/cpu/cpu_x86.c     |  6 +++---
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/cpu/cpu_generic.c b/src/cpu/cpu_generic.c
index 9d5117f..e907269 100644
--- a/src/cpu/cpu_generic.c
+++ b/src/cpu/cpu_generic.c
@@ -28,7 +28,7 @@
 #include "virhash.h"
 #include "cpu.h"
 #include "cpu_generic.h"
-
+#include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
@@ -131,7 +131,7 @@ genericBaseline(virCPUDefPtr *cpus,
     }
 
     if (VIR_ALLOC(cpu) < 0 ||
-        !(cpu->model = strdup(cpus[0]->model)) ||
+        VIR_STRDUP(cpu->model, cpus[0]->model) < 0 ||
         VIR_ALLOC_N(features, cpus[0]->nfeatures) < 0)
         goto no_memory;
 
@@ -183,7 +183,7 @@ genericBaseline(virCPUDefPtr *cpus,
         if (!features[i].name)
             continue;
 
-        if (!(cpu->features[j++].name = strdup(features[i].name)))
+        if (VIR_STRDUP(cpu->features[j++].name, features[i].name) < 0)
             goto no_memory;
     }
 
diff --git a/src/cpu/cpu_map.c b/src/cpu/cpu_map.c
index 015be2e..7c2bdec 100644
--- a/src/cpu/cpu_map.c
+++ b/src/cpu/cpu_map.c
@@ -27,6 +27,7 @@
 #include "cpu.h"
 #include "cpu_map.h"
 #include "configmake.h"
+#include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
@@ -149,7 +150,7 @@ cpuMapOverride(const char *path)
 {
     char *map;
 
-    if (!(map = strdup(path)))
+    if (VIR_STRDUP(map, path) < 0)
         return -1;
 
     VIR_FREE(cpumap);
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index b253db2..3aa7395 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -29,9 +29,9 @@
 #include "virlog.h"
 #include "viralloc.h"
 #include "cpu.h"
-
 #include "cpu_map.h"
 #include "virbuffer.h"
+#include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
@@ -333,8 +333,8 @@ ppcDecode(virCPUDefPtr cpu,
         goto cleanup;
     }
 
-    if (!(cpu->model = strdup(model->name)) ||
-        (model->vendor && !(cpu->vendor = strdup(model->vendor->name)))) {
+    if (VIR_STRDUP(cpu->model, model->name) < 0 ||
+        (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) {
         virReportOOMError();
         goto cleanup;
     }
@@ -449,10 +449,10 @@ ppcBaseline(virCPUDefPtr *cpus,
     }
 
     if (VIR_ALLOC(cpu) < 0 ||
-        !(cpu->model = strdup(model->name)))
+        VIR_STRDUP(cpu->model, model->name) < 0)
         goto no_memory;
 
-    if (vendor && !(cpu->vendor = strdup(vendor->name)))
+    if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
         goto no_memory;
 
     cpu->type = VIR_CPU_TYPE_GUEST;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 14d525e..009c2c0 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -449,13 +449,13 @@ x86DataToCPU(const union cpuData *data,
     const struct x86_vendor *vendor;
 
     if (VIR_ALLOC(cpu) < 0 ||
-        !(cpu->model = strdup(model->name)) ||
+        VIR_STRDUP(cpu->model, model->name) < 0 ||
         !(copy = x86DataCopy(data)) ||
         !(modelData = x86DataCopy(model->data)))
         goto no_memory;
 
     if ((vendor = x86DataToVendor(copy, map)) &&
-        !(cpu->vendor = strdup(vendor->name)))
+        VIR_STRDUP(cpu->vendor, vendor->name) < 0)
         goto no_memory;
 
     x86DataSubtract(copy, modelData);
@@ -767,7 +767,7 @@ x86ModelCopy(const struct x86_model *model)
     struct x86_model *copy;
 
     if (VIR_ALLOC(copy) < 0
-        || !(copy->name = strdup(model->name))
+        || VIR_STRDUP(copy->name, model->name) < 0
         || !(copy->data = x86DataCopy(model->data))) {
         x86ModelFree(copy);
         return NULL;
-- 
1.8.1.5

--
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]