mirror of https://gitee.com/openkylin/libvirt.git
Adapt to VIR_STRDUP and VIR_STRNDUP in src/cpu/*
This commit is contained in:
parent
df5c9e6984
commit
0d013184d1
|
@ -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,8 +183,8 @@ genericBaseline(virCPUDefPtr *cpus,
|
|||
if (!features[i].name)
|
||||
continue;
|
||||
|
||||
if (!(cpu->features[j++].name = strdup(features[i].name)))
|
||||
goto no_memory;
|
||||
if (VIR_STRDUP(cpu->features[j++].name, features[i].name) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "virlog.h"
|
||||
#include "viralloc.h"
|
||||
#include "cpu.h"
|
||||
|
||||
#include "virstring.h"
|
||||
#include "cpu_map.h"
|
||||
#include "virbuffer.h"
|
||||
|
||||
|
@ -333,9 +333,8 @@ ppcDecode(virCPUDefPtr cpu,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!(cpu->model = strdup(model->name)) ||
|
||||
(model->vendor && !(cpu->vendor = strdup(model->vendor->name)))) {
|
||||
virReportOOMError();
|
||||
if (VIR_STRDUP(cpu->model, model->name) < 0 ||
|
||||
(model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -449,11 +448,11 @@ 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)))
|
||||
goto no_memory;
|
||||
if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
|
||||
goto error;
|
||||
|
||||
cpu->type = VIR_CPU_TYPE_GUEST;
|
||||
cpu->match = VIR_CPU_MATCH_EXACT;
|
||||
|
|
|
@ -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);
|
||||
|
@ -766,9 +766,9 @@ x86ModelCopy(const struct x86_model *model)
|
|||
{
|
||||
struct x86_model *copy;
|
||||
|
||||
if (VIR_ALLOC(copy) < 0
|
||||
|| !(copy->name = strdup(model->name))
|
||||
|| !(copy->data = x86DataCopy(model->data))) {
|
||||
if (VIR_ALLOC(copy) < 0 ||
|
||||
VIR_STRDUP(copy->name, model->name) < 0 ||
|
||||
!(copy->data = x86DataCopy(model->data))) {
|
||||
x86ModelFree(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue