Adapt to VIR_STRDUP and VIR_STRNDUP in src/cpu/*

This commit is contained in:
Michal Privoznik 2013-05-03 14:41:23 +02:00
parent df5c9e6984
commit 0d013184d1
4 changed files with 17 additions and 17 deletions

View File

@ -28,7 +28,7 @@
#include "virhash.h" #include "virhash.h"
#include "cpu.h" #include "cpu.h"
#include "cpu_generic.h" #include "cpu_generic.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_CPU #define VIR_FROM_THIS VIR_FROM_CPU
@ -131,7 +131,7 @@ genericBaseline(virCPUDefPtr *cpus,
} }
if (VIR_ALLOC(cpu) < 0 || 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) VIR_ALLOC_N(features, cpus[0]->nfeatures) < 0)
goto no_memory; goto no_memory;
@ -183,8 +183,8 @@ genericBaseline(virCPUDefPtr *cpus,
if (!features[i].name) if (!features[i].name)
continue; continue;
if (!(cpu->features[j++].name = strdup(features[i].name))) if (VIR_STRDUP(cpu->features[j++].name, features[i].name) < 0)
goto no_memory; goto error;
} }
cleanup: cleanup:

View File

@ -27,6 +27,7 @@
#include "cpu.h" #include "cpu.h"
#include "cpu_map.h" #include "cpu_map.h"
#include "configmake.h" #include "configmake.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_CPU #define VIR_FROM_THIS VIR_FROM_CPU
@ -149,7 +150,7 @@ cpuMapOverride(const char *path)
{ {
char *map; char *map;
if (!(map = strdup(path))) if (VIR_STRDUP(map, path) < 0)
return -1; return -1;
VIR_FREE(cpumap); VIR_FREE(cpumap);

View File

@ -29,7 +29,7 @@
#include "virlog.h" #include "virlog.h"
#include "viralloc.h" #include "viralloc.h"
#include "cpu.h" #include "cpu.h"
#include "virstring.h"
#include "cpu_map.h" #include "cpu_map.h"
#include "virbuffer.h" #include "virbuffer.h"
@ -333,9 +333,8 @@ ppcDecode(virCPUDefPtr cpu,
goto cleanup; goto cleanup;
} }
if (!(cpu->model = strdup(model->name)) || if (VIR_STRDUP(cpu->model, model->name) < 0 ||
(model->vendor && !(cpu->vendor = strdup(model->vendor->name)))) { (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) {
virReportOOMError();
goto cleanup; goto cleanup;
} }
@ -449,11 +448,11 @@ ppcBaseline(virCPUDefPtr *cpus,
} }
if (VIR_ALLOC(cpu) < 0 || if (VIR_ALLOC(cpu) < 0 ||
!(cpu->model = strdup(model->name))) VIR_STRDUP(cpu->model, model->name) < 0)
goto no_memory; goto no_memory;
if (vendor && !(cpu->vendor = strdup(vendor->name))) if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
goto no_memory; goto error;
cpu->type = VIR_CPU_TYPE_GUEST; cpu->type = VIR_CPU_TYPE_GUEST;
cpu->match = VIR_CPU_MATCH_EXACT; cpu->match = VIR_CPU_MATCH_EXACT;

View File

@ -449,13 +449,13 @@ x86DataToCPU(const union cpuData *data,
const struct x86_vendor *vendor; const struct x86_vendor *vendor;
if (VIR_ALLOC(cpu) < 0 || if (VIR_ALLOC(cpu) < 0 ||
!(cpu->model = strdup(model->name)) || VIR_STRDUP(cpu->model, model->name) < 0 ||
!(copy = x86DataCopy(data)) || !(copy = x86DataCopy(data)) ||
!(modelData = x86DataCopy(model->data))) !(modelData = x86DataCopy(model->data)))
goto no_memory; goto no_memory;
if ((vendor = x86DataToVendor(copy, map)) && if ((vendor = x86DataToVendor(copy, map)) &&
!(cpu->vendor = strdup(vendor->name))) VIR_STRDUP(cpu->vendor, vendor->name) < 0)
goto no_memory; goto no_memory;
x86DataSubtract(copy, modelData); x86DataSubtract(copy, modelData);
@ -766,9 +766,9 @@ x86ModelCopy(const struct x86_model *model)
{ {
struct x86_model *copy; struct x86_model *copy;
if (VIR_ALLOC(copy) < 0 if (VIR_ALLOC(copy) < 0 ||
|| !(copy->name = strdup(model->name)) VIR_STRDUP(copy->name, model->name) < 0 ||
|| !(copy->data = x86DataCopy(model->data))) { !(copy->data = x86DataCopy(model->data))) {
x86ModelFree(copy); x86ModelFree(copy);
return NULL; return NULL;
} }