mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
Adapt to VIR_STRDUP and VIR_STRNDUP in src/conf/*
This commit is contained in:
parent
25a2d944df
commit
bf1fe848c7
@ -31,7 +31,7 @@
|
|||||||
#include "viruuid.h"
|
#include "viruuid.h"
|
||||||
#include "cpu_conf.h"
|
#include "cpu_conf.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
|
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ virCapabilitiesAddHostFeature(virCapsPtr caps,
|
|||||||
caps->host.nfeatures, 1) < 0)
|
caps->host.nfeatures, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((caps->host.features[caps->host.nfeatures] = strdup(name)) == NULL)
|
if (VIR_STRDUP(caps->host.features[caps->host.nfeatures], name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
caps->host.nfeatures++;
|
caps->host.nfeatures++;
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
|
|||||||
caps->host.nmigrateTrans, 1) < 0)
|
caps->host.nmigrateTrans, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if ((caps->host.migrateTrans[caps->host.nmigrateTrans] = strdup(name)) == NULL)
|
if (VIR_STRDUP(caps->host.migrateTrans[caps->host.nmigrateTrans], name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
caps->host.nmigrateTrans++;
|
caps->host.nmigrateTrans++;
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ virCapabilitiesAllocMachines(const char *const *names, int nnames)
|
|||||||
|
|
||||||
for (i = 0; i < nnames; i++) {
|
for (i = 0; i < nnames; i++) {
|
||||||
if (VIR_ALLOC(machines[i]) < 0 ||
|
if (VIR_ALLOC(machines[i]) < 0 ||
|
||||||
!(machines[i]->name = strdup(names[i]))) {
|
VIR_STRDUP(machines[i]->name, names[i]) < 0) {
|
||||||
virCapabilitiesFreeMachines(machines, nnames);
|
virCapabilitiesFreeMachines(machines, nnames);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -390,24 +390,21 @@ virCapabilitiesAddGuest(virCapsPtr caps,
|
|||||||
virCapsGuestPtr guest;
|
virCapsGuestPtr guest;
|
||||||
|
|
||||||
if (VIR_ALLOC(guest) < 0)
|
if (VIR_ALLOC(guest) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if ((guest->ostype = strdup(ostype)) == NULL)
|
if (VIR_STRDUP(guest->ostype, ostype) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
guest->arch.id = arch;
|
guest->arch.id = arch;
|
||||||
guest->arch.wordsize = virArchGetWordSize(arch);
|
guest->arch.wordsize = virArchGetWordSize(arch);
|
||||||
|
|
||||||
if (emulator &&
|
if (VIR_STRDUP(guest->arch.defaultInfo.emulator, emulator) < 0 ||
|
||||||
(guest->arch.defaultInfo.emulator = strdup(emulator)) == NULL)
|
VIR_STRDUP(guest->arch.defaultInfo.loader, loader) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
if (loader &&
|
|
||||||
(guest->arch.defaultInfo.loader = strdup(loader)) == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (VIR_RESIZE_N(caps->guests, caps->nguests_max,
|
if (VIR_RESIZE_N(caps->guests, caps->nguests_max,
|
||||||
caps->nguests, 1) < 0)
|
caps->nguests, 1) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
caps->guests[caps->nguests++] = guest;
|
caps->guests[caps->nguests++] = guest;
|
||||||
|
|
||||||
if (nmachines) {
|
if (nmachines) {
|
||||||
@ -417,7 +414,7 @@ virCapabilitiesAddGuest(virCapsPtr caps,
|
|||||||
|
|
||||||
return guest;
|
return guest;
|
||||||
|
|
||||||
no_memory:
|
error:
|
||||||
virCapabilitiesFreeGuest(guest);
|
virCapabilitiesFreeGuest(guest);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -446,21 +443,16 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
|
|||||||
virCapsGuestDomainPtr dom;
|
virCapsGuestDomainPtr dom;
|
||||||
|
|
||||||
if (VIR_ALLOC(dom) < 0)
|
if (VIR_ALLOC(dom) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if ((dom->type = strdup(hvtype)) == NULL)
|
if (VIR_STRDUP(dom->type, hvtype) < 0 ||
|
||||||
goto no_memory;
|
VIR_STRDUP(dom->info.emulator, emulator) < 0 ||
|
||||||
|
VIR_STRDUP(dom->info.loader, loader) < 0)
|
||||||
if (emulator &&
|
goto error;
|
||||||
(dom->info.emulator = strdup(emulator)) == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
if (loader &&
|
|
||||||
(dom->info.loader = strdup(loader)) == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
|
if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
|
||||||
guest->arch.ndomains, 1) < 0)
|
guest->arch.ndomains, 1) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
guest->arch.domains[guest->arch.ndomains] = dom;
|
guest->arch.domains[guest->arch.ndomains] = dom;
|
||||||
guest->arch.ndomains++;
|
guest->arch.ndomains++;
|
||||||
|
|
||||||
@ -471,7 +463,7 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
|
|||||||
|
|
||||||
return dom;
|
return dom;
|
||||||
|
|
||||||
no_memory:
|
error:
|
||||||
virCapabilitiesFreeGuestDomain(dom);
|
virCapabilitiesFreeGuestDomain(dom);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -497,7 +489,7 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
|
|||||||
if (VIR_ALLOC(feature) < 0)
|
if (VIR_ALLOC(feature) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if ((feature->name = strdup(name)) == NULL)
|
if (VIR_STRDUP(feature->name, name) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
feature->defaultOn = defaultOn;
|
feature->defaultOn = defaultOn;
|
||||||
feature->toggle = toggle;
|
feature->toggle = toggle;
|
||||||
|
@ -99,10 +99,10 @@ virCPUDefCopyModel(virCPUDefPtr dst,
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if ((src->model && !(dst->model = strdup(src->model)))
|
if (VIR_STRDUP(dst->model, src->model) < 0 ||
|
||||||
|| (src->vendor && !(dst->vendor = strdup(src->vendor)))
|
VIR_STRDUP(dst->vendor, src->vendor) < 0 ||
|
||||||
|| (src->vendor_id && !(dst->vendor_id = strdup(src->vendor_id)))
|
VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 ||
|
||||||
|| VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
|
VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
dst->nfeatures_max = dst->nfeatures = src->nfeatures;
|
dst->nfeatures_max = dst->nfeatures = src->nfeatures;
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ virCPUDefCopyModel(virCPUDefPtr dst,
|
|||||||
dst->features[i].policy = src->features[i].policy;
|
dst->features[i].policy = src->features[i].policy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dst->features[i].name = strdup(src->features[i].name)))
|
if (VIR_STRDUP(dst->features[i].name, src->features[i].name) < 0)
|
||||||
goto no_memory;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -167,8 +167,8 @@ virCPUDefCopy(const virCPUDefPtr cpu)
|
|||||||
if (!copy->cells[i].cpumask)
|
if (!copy->cells[i].cpumask)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (!(copy->cells[i].cpustr = strdup(cpu->cells[i].cpustr)))
|
if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
copy->cells_cpus = cpu->cells_cpus;
|
copy->cells_cpus = cpu->cells_cpus;
|
||||||
}
|
}
|
||||||
@ -694,8 +694,8 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|||||||
if (def->type == VIR_CPU_TYPE_HOST)
|
if (def->type == VIR_CPU_TYPE_HOST)
|
||||||
policy = -1;
|
policy = -1;
|
||||||
|
|
||||||
if (!(def->features[def->nfeatures].name = strdup(name)))
|
if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
|
||||||
goto no_memory;
|
return -1;
|
||||||
|
|
||||||
def->features[def->nfeatures].policy = policy;
|
def->features[def->nfeatures].policy = policy;
|
||||||
def->nfeatures++;
|
def->nfeatures++;
|
||||||
|
@ -1365,60 +1365,35 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
|
|||||||
case VIR_DOMAIN_CHR_TYPE_DEV:
|
case VIR_DOMAIN_CHR_TYPE_DEV:
|
||||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||||
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
||||||
if (src->data.file.path &&
|
if (VIR_STRDUP(dest->data.file.path, src->data.file.path) < 0)
|
||||||
!(dest->data.file.path = strdup(src->data.file.path))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_UDP:
|
case VIR_DOMAIN_CHR_TYPE_UDP:
|
||||||
if (src->data.udp.bindHost &&
|
if (VIR_STRDUP(dest->data.udp.bindHost, src->data.udp.bindHost) < 0)
|
||||||
!(dest->data.udp.bindHost = strdup(src->data.udp.bindHost))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (src->data.udp.bindService &&
|
if (VIR_STRDUP(dest->data.udp.bindService, src->data.udp.bindService) < 0)
|
||||||
!(dest->data.udp.bindService = strdup(src->data.udp.bindService))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (src->data.udp.connectHost &&
|
if (VIR_STRDUP(dest->data.udp.connectHost, src->data.udp.connectHost) < 0)
|
||||||
!(dest->data.udp.connectHost = strdup(src->data.udp.connectHost))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (VIR_STRDUP(dest->data.udp.connectService, src->data.udp.connectService) < 0)
|
||||||
if (src->data.udp.connectService &&
|
|
||||||
!(dest->data.udp.connectService = strdup(src->data.udp.connectService))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_TCP:
|
case VIR_DOMAIN_CHR_TYPE_TCP:
|
||||||
if (src->data.tcp.host &&
|
if (VIR_STRDUP(dest->data.tcp.host, src->data.tcp.host) < 0)
|
||||||
!(dest->data.tcp.host = strdup(src->data.tcp.host))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (src->data.tcp.service &&
|
if (VIR_STRDUP(dest->data.tcp.service, src->data.tcp.service) < 0)
|
||||||
!(dest->data.tcp.service = strdup(src->data.tcp.service))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
if (src->data.nix.path &&
|
if (VIR_STRDUP(dest->data.nix.path, src->data.nix.path) < 0)
|
||||||
!(dest->data.nix.path = strdup(src->data.nix.path))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2422,14 +2397,9 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst,
|
|||||||
dst->alias = NULL;
|
dst->alias = NULL;
|
||||||
dst->romfile = NULL;
|
dst->romfile = NULL;
|
||||||
|
|
||||||
if (src->alias && !(dst->alias = strdup(src->alias))) {
|
if (VIR_STRDUP(dst->alias, src->alias) < 0 ||
|
||||||
virReportOOMError();
|
VIR_STRDUP(dst->romfile, src->romfile) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if (src->romfile && !(dst->romfile = strdup(src->romfile))) {
|
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4282,11 +4252,8 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
|
|||||||
/* Copy model from host. */
|
/* Copy model from host. */
|
||||||
VIR_DEBUG("Found seclabel without a model, using '%s'",
|
VIR_DEBUG("Found seclabel without a model, using '%s'",
|
||||||
host->secModels[0].model);
|
host->secModels[0].model);
|
||||||
def->seclabels[0]->model = strdup(host->secModels[0].model);
|
if (VIR_STRDUP(def->seclabels[0]->model, host->secModels[0].model) < 0)
|
||||||
if (!def->seclabels[0]->model) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("missing security model in domain seclabel"));
|
_("missing security model in domain seclabel"));
|
||||||
@ -5924,10 +5891,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
|||||||
addrtype = virXPathString("string(./source/address/@type)", ctxt);
|
addrtype = virXPathString("string(./source/address/@type)", ctxt);
|
||||||
/* if not explicitly stated, source/vendor implies usb device */
|
/* if not explicitly stated, source/vendor implies usb device */
|
||||||
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
|
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
|
||||||
(addrtype = strdup("usb")) == NULL) {
|
VIR_STRDUP(addrtype, "usb") < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
||||||
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
|
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
|
||||||
hostdev, flags) < 0) {
|
hostdev, flags) < 0) {
|
||||||
@ -6318,10 +6283,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
addrtype = virXPathString("string(./source/address/@type)", ctxt);
|
addrtype = virXPathString("string(./source/address/@type)", ctxt);
|
||||||
/* if not explicitly stated, source/vendor implies usb device */
|
/* if not explicitly stated, source/vendor implies usb device */
|
||||||
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
|
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
|
||||||
((addrtype = strdup("usb")) == NULL)) {
|
VIR_STRDUP(addrtype, "usb") < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
||||||
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
|
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
|
||||||
hostdev, flags) < 0) {
|
hostdev, flags) < 0) {
|
||||||
@ -7206,10 +7169,8 @@ virDomainTPMDefParseXML(const xmlNodePtr node,
|
|||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
|
||||||
path = virXPathString("string(./backend/device/@path)", ctxt);
|
path = virXPathString("string(./backend/device/@path)", ctxt);
|
||||||
if (!path && !(path = strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE))) {
|
if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
def->data.passthrough.source.data.file.path = path;
|
def->data.passthrough.source.data.file.path = path;
|
||||||
def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
|
def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
|
||||||
path = NULL;
|
path = NULL;
|
||||||
@ -9025,10 +8986,8 @@ virDomainRedirFilterUsbVersionHelper(const char *version,
|
|||||||
unsigned int minor;
|
unsigned int minor;
|
||||||
unsigned int hex;
|
unsigned int hex;
|
||||||
|
|
||||||
if (!(version_copy = strdup(version))) {
|
if (VIR_STRDUP(version_copy, version) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
len = strlen(version_copy);
|
len = strlen(version_copy);
|
||||||
/*
|
/*
|
||||||
@ -9987,9 +9946,7 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(retemu = strdup(emulator)))
|
ignore_value(VIR_STRDUP(retemu, emulator));
|
||||||
virReportOOMError();
|
|
||||||
|
|
||||||
return retemu;
|
return retemu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11095,10 +11052,8 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
def->os.type = virXPathString("string(./os/type[1])", ctxt);
|
def->os.type = virXPathString("string(./os/type[1])", ctxt);
|
||||||
if (!def->os.type) {
|
if (!def->os.type) {
|
||||||
if (def->os.bootloader) {
|
if (def->os.bootloader) {
|
||||||
def->os.type = strdup("xen");
|
if (VIR_STRDUP(def->os.type, "xen") < 0)
|
||||||
if (!def->os.type) {
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
virReportError(VIR_ERR_OS_TYPE,
|
virReportError(VIR_ERR_OS_TYPE,
|
||||||
"%s", _("no OS type"));
|
"%s", _("no OS type"));
|
||||||
@ -11113,9 +11068,8 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
if (STREQ(def->os.type, "linux") &&
|
if (STREQ(def->os.type, "linux") &&
|
||||||
def->virtType == VIR_DOMAIN_VIRT_XEN) {
|
def->virtType == VIR_DOMAIN_VIRT_XEN) {
|
||||||
VIR_FREE(def->os.type);
|
VIR_FREE(def->os.type);
|
||||||
if (!(def->os.type = strdup("xen"))) {
|
if (VIR_STRDUP(def->os.type, "xen") < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) {
|
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) {
|
||||||
@ -11169,11 +11123,8 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
def->os.type,
|
def->os.type,
|
||||||
def->os.arch,
|
def->os.arch,
|
||||||
virDomainVirtTypeToString(def->virtType));
|
virDomainVirtTypeToString(def->virtType));
|
||||||
if (defaultMachine != NULL) {
|
if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
|
||||||
if (!(def->os.machine = strdup(defaultMachine))) {
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -11202,8 +11153,9 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
_("No data supplied for <initarg> element"));
|
_("No data supplied for <initarg> element"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!(def->os.initargv[i] = strdup((const char*)nodes[i]->children->content)))
|
if (VIR_STRDUP(def->os.initargv[i],
|
||||||
goto no_memory;
|
(const char*) nodes[i]->children->content) < 0)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
def->os.initargv[n] = NULL;
|
def->os.initargv[n] = NULL;
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
@ -16866,7 +16818,7 @@ virDomainObjListCopyInactiveNames(void *payload,
|
|||||||
|
|
||||||
virObjectLock(obj);
|
virObjectLock(obj);
|
||||||
if (!virDomainObjIsActive(obj) && data->numnames < data->maxnames) {
|
if (!virDomainObjIsActive(obj) && data->numnames < data->maxnames) {
|
||||||
if (!(data->names[data->numnames] = strdup(obj->def->name)))
|
if (VIR_STRDUP(data->names[data->numnames], obj->def->name) < 0)
|
||||||
data->oom = 1;
|
data->oom = 1;
|
||||||
else
|
else
|
||||||
data->numnames++;
|
data->numnames++;
|
||||||
@ -16888,7 +16840,6 @@ virDomainObjListGetInactiveNames(virDomainObjListPtr doms,
|
|||||||
if (data.oom) {
|
if (data.oom) {
|
||||||
for (i = 0; i < data.numnames; i++)
|
for (i = 0; i < data.numnames; i++)
|
||||||
VIR_FREE(data.names[i]);
|
VIR_FREE(data.names[i]);
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17419,12 +17370,9 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
listenInfo->address = (len == -1) ? strdup(address) : strndup(address, len);
|
if (VIR_STRNDUP(listenInfo->address, address,
|
||||||
if (!listenInfo->address) {
|
len == -1 ? strlen(address) : len) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17461,12 +17409,9 @@ virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
listenInfo->network = (len == -1) ? strdup(network) : strndup(network, len);
|
if (VIR_STRNDUP(listenInfo->network, network,
|
||||||
if (!listenInfo->network) {
|
len == -1 ? strlen(network) : len) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17801,7 +17746,7 @@ virDomainDefGenSecurityLabelDef(const char *model)
|
|||||||
virSecurityLabelDefPtr seclabel = NULL;
|
virSecurityLabelDefPtr seclabel = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(seclabel) < 0 ||
|
if (VIR_ALLOC(seclabel) < 0 ||
|
||||||
(model && !(seclabel->model = strdup(model)))) {
|
VIR_STRDUP(seclabel->model, model) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
virSecurityLabelDefFree(seclabel);
|
virSecurityLabelDefFree(seclabel);
|
||||||
seclabel = NULL;
|
seclabel = NULL;
|
||||||
@ -17816,7 +17761,7 @@ virDomainDiskDefGenSecurityLabelDef(const char *model)
|
|||||||
virSecurityDeviceLabelDefPtr seclabel = NULL;
|
virSecurityDeviceLabelDefPtr seclabel = NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC(seclabel) < 0 ||
|
if (VIR_ALLOC(seclabel) < 0 ||
|
||||||
(model && !(seclabel->model = strdup(model)))) {
|
VIR_STRDUP(seclabel->model, model) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
virSecurityDeviceLabelDefFree(seclabel);
|
virSecurityDeviceLabelDefFree(seclabel);
|
||||||
seclabel = NULL;
|
seclabel = NULL;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
|
#include "virstring.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
@ -385,8 +386,8 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
|
|||||||
if (dom) {
|
if (dom) {
|
||||||
if (VIR_ALLOC(event->dom) < 0)
|
if (VIR_ALLOC(event->dom) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
if (!(event->dom->name = strdup(dom->name)))
|
if (VIR_STRDUP(event->dom->name, dom->name) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
memcpy(event->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
|
memcpy(event->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
|
||||||
event->dom->id = dom->id;
|
event->dom->id = dom->id;
|
||||||
}
|
}
|
||||||
@ -416,7 +417,7 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
|
|||||||
|
|
||||||
no_memory:
|
no_memory:
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
|
error:
|
||||||
if (event) {
|
if (event) {
|
||||||
if (event->dom)
|
if (event->dom)
|
||||||
VIR_FREE(event->dom->name);
|
VIR_FREE(event->dom->name);
|
||||||
@ -668,8 +669,7 @@ static virDomainEventPtr virDomainEventNewInternal(int eventID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->eventID = eventID;
|
event->eventID = eventID;
|
||||||
if (!(event->dom.name = strdup(name))) {
|
if (VIR_STRDUP(event->dom.name, name) < 0) {
|
||||||
virReportOOMError();
|
|
||||||
VIR_FREE(event);
|
VIR_FREE(event);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -791,9 +791,9 @@ static virDomainEventPtr virDomainEventIOErrorNewFromDomImpl(int event,
|
|||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
ev->data.ioError.action = action;
|
ev->data.ioError.action = action;
|
||||||
if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
|
if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
|
||||||
!(ev->data.ioError.devAlias = strdup(devAlias)) ||
|
VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
|
||||||
(reason && !(ev->data.ioError.reason = strdup(reason)))) {
|
VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
ev = NULL;
|
ev = NULL;
|
||||||
}
|
}
|
||||||
@ -815,9 +815,9 @@ static virDomainEventPtr virDomainEventIOErrorNewFromObjImpl(int event,
|
|||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
ev->data.ioError.action = action;
|
ev->data.ioError.action = action;
|
||||||
if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
|
if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
|
||||||
!(ev->data.ioError.devAlias = strdup(devAlias)) ||
|
VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
|
||||||
(reason && !(ev->data.ioError.reason = strdup(reason)))) {
|
VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
ev = NULL;
|
ev = NULL;
|
||||||
}
|
}
|
||||||
@ -882,7 +882,7 @@ virDomainEventPtr virDomainEventGraphicsNewFromDom(virDomainPtr dom,
|
|||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
ev->data.graphics.phase = phase;
|
ev->data.graphics.phase = phase;
|
||||||
if (!(ev->data.graphics.authScheme = strdup(authScheme))) {
|
if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -907,7 +907,7 @@ virDomainEventPtr virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
|
|||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
ev->data.graphics.phase = phase;
|
ev->data.graphics.phase = phase;
|
||||||
if (!(ev->data.graphics.authScheme = strdup(authScheme))) {
|
if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -928,8 +928,7 @@ virDomainEventBlockJobNew(int id, const char *name, unsigned char *uuid,
|
|||||||
id, name, uuid);
|
id, name, uuid);
|
||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
if (!(ev->data.blockJob.path = strdup(path))) {
|
if (VIR_STRDUP(ev->data.blockJob.path, path) < 0) {
|
||||||
virReportOOMError();
|
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -987,15 +986,13 @@ virDomainEventDiskChangeNew(int id, const char *name,
|
|||||||
id, name, uuid);
|
id, name, uuid);
|
||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
if (!(ev->data.diskChange.devAlias = strdup(devAlias)))
|
if (VIR_STRDUP(ev->data.diskChange.devAlias, devAlias) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (oldSrcPath &&
|
if (VIR_STRDUP(ev->data.diskChange.oldSrcPath, oldSrcPath) < 0)
|
||||||
!(ev->data.diskChange.oldSrcPath = strdup(oldSrcPath)))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (newSrcPath &&
|
if (VIR_STRDUP(ev->data.diskChange.newSrcPath, newSrcPath) < 0)
|
||||||
!(ev->data.diskChange.newSrcPath = strdup(newSrcPath)))
|
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ev->data.diskChange.reason = reason;
|
ev->data.diskChange.reason = reason;
|
||||||
@ -1004,7 +1001,6 @@ virDomainEventDiskChangeNew(int id, const char *name,
|
|||||||
return ev;
|
return ev;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virReportOOMError();
|
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1042,7 +1038,7 @@ virDomainEventTrayChangeNew(int id, const char *name,
|
|||||||
id, name, uuid);
|
id, name, uuid);
|
||||||
|
|
||||||
if (ev) {
|
if (ev) {
|
||||||
if (!(ev->data.trayChange.devAlias = strdup(devAlias)))
|
if (VIR_STRDUP(ev->data.trayChange.devAlias, devAlias) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ev->data.trayChange.reason = reason;
|
ev->data.trayChange.reason = reason;
|
||||||
@ -1051,7 +1047,6 @@ virDomainEventTrayChangeNew(int id, const char *name,
|
|||||||
return ev;
|
return ev;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virReportOOMError();
|
|
||||||
virDomainEventFree(ev);
|
virDomainEventFree(ev);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "viralloc.h"
|
#include "viralloc.h"
|
||||||
|
#include "virstring.h"
|
||||||
#include "node_device_conf.h"
|
#include "node_device_conf.h"
|
||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
@ -1164,12 +1164,8 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
def->name = strdup("new device");
|
if (VIR_STRDUP(def->name, "new device") < 0)
|
||||||
|
|
||||||
if (!def->name) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract device parent, if any */
|
/* Extract device parent, if any */
|
||||||
@ -1284,14 +1280,18 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
|
|||||||
char **wwpn)
|
char **wwpn)
|
||||||
{
|
{
|
||||||
virNodeDevCapsDefPtr cap = NULL;
|
virNodeDevCapsDefPtr cap = NULL;
|
||||||
int ret = 0;
|
int ret = -1;
|
||||||
|
|
||||||
cap = def->caps;
|
cap = def->caps;
|
||||||
while (cap != NULL) {
|
while (cap != NULL) {
|
||||||
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST &&
|
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST &&
|
||||||
cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
|
cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
|
||||||
*wwnn = strdup(cap->data.scsi_host.wwnn);
|
if (VIR_STRDUP(*wwnn, cap->data.scsi_host.wwnn) < 0 ||
|
||||||
*wwpn = strdup(cap->data.scsi_host.wwpn);
|
VIR_STRDUP(*wwpn, cap->data.scsi_host.wwpn) < 0) {
|
||||||
|
/* Free the other one, if allocated... */
|
||||||
|
VIR_FREE(*wwnn);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1301,15 +1301,11 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
|
|||||||
if (cap == NULL) {
|
if (cap == NULL) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Device is not a fibre channel HBA"));
|
"%s", _("Device is not a fibre channel HBA"));
|
||||||
ret = -1;
|
goto cleanup;
|
||||||
} else if (*wwnn == NULL || *wwpn == NULL) {
|
|
||||||
/* Free the other one, if allocated... */
|
|
||||||
VIR_FREE(*wwnn);
|
|
||||||
VIR_FREE(*wwpn);
|
|
||||||
ret = -1;
|
|
||||||
virReportOOMError();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,12 +400,8 @@ virNWFilterRuleDefAddString(virNWFilterRuleDefPtr nwf,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nwf->strings[nwf->nstrings] = strndup(string, maxstrlen);
|
if (VIR_STRNDUP(nwf->strings[nwf->nstrings], string, maxstrlen) < 0)
|
||||||
|
|
||||||
if (!nwf->strings[nwf->nstrings]) {
|
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
nwf->nstrings++;
|
nwf->nstrings++;
|
||||||
|
|
||||||
@ -2556,12 +2552,9 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
chain = NULL;
|
chain = NULL;
|
||||||
} else {
|
} else {
|
||||||
ret->chainsuffix = strdup(virNWFilterChainSuffixTypeToString(
|
if (VIR_STRDUP(ret->chainsuffix,
|
||||||
VIR_NWFILTER_CHAINSUFFIX_ROOT));
|
virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT)) < 0)
|
||||||
if (ret->chainsuffix == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uuid = virXPathString("string(./uuid)", ctxt);
|
uuid = virXPathString("string(./uuid)", ctxt);
|
||||||
@ -3094,9 +3087,7 @@ virNWFilterObjLoad(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(nwfilter->configFile); /* for driver reload */
|
VIR_FREE(nwfilter->configFile); /* for driver reload */
|
||||||
nwfilter->configFile = strdup(path);
|
if (VIR_STRDUP(nwfilter->configFile, path) < 0) {
|
||||||
if (nwfilter->configFile == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
virNWFilterDefFree(def);
|
virNWFilterDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -79,19 +79,15 @@ virNWFilterVarValueCopy(const virNWFilterVarValuePtr val)
|
|||||||
|
|
||||||
switch (res->valType) {
|
switch (res->valType) {
|
||||||
case NWFILTER_VALUE_TYPE_SIMPLE:
|
case NWFILTER_VALUE_TYPE_SIMPLE:
|
||||||
if (val->u.simple.value) {
|
if (VIR_STRDUP(res->u.simple.value, val->u.simple.value) < 0)
|
||||||
res->u.simple.value = strdup(val->u.simple.value);
|
goto err_exit;
|
||||||
if (!res->u.simple.value)
|
|
||||||
goto err_exit;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NWFILTER_VALUE_TYPE_ARRAY:
|
case NWFILTER_VALUE_TYPE_ARRAY:
|
||||||
if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0)
|
if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
res->u.array.nValues = val->u.array.nValues;
|
res->u.array.nValues = val->u.array.nValues;
|
||||||
for (i = 0; i < val->u.array.nValues; i++) {
|
for (i = 0; i < val->u.array.nValues; i++) {
|
||||||
str = strdup(val->u.array.values[i]);
|
if (VIR_STRDUP(str, val->u.array.values[i]) < 0)
|
||||||
if (!str)
|
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
res->u.array.values[i] = str;
|
res->u.array.values[i] = str;
|
||||||
}
|
}
|
||||||
@ -133,12 +129,10 @@ virNWFilterVarValueCreateSimple(char *value)
|
|||||||
virNWFilterVarValuePtr
|
virNWFilterVarValuePtr
|
||||||
virNWFilterVarValueCreateSimpleCopyValue(const char *value)
|
virNWFilterVarValueCreateSimpleCopyValue(const char *value)
|
||||||
{
|
{
|
||||||
char *val = strdup(value);
|
char *val;
|
||||||
|
|
||||||
if (!val) {
|
if (VIR_STRDUP(val, value) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
return virNWFilterVarValueCreateSimple(val);
|
return virNWFilterVarValueCreateSimple(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,17 +648,15 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
|
|||||||
{
|
{
|
||||||
if (!virHashLookup(table->hashTable, name)) {
|
if (!virHashLookup(table->hashTable, name)) {
|
||||||
if (copyName) {
|
if (copyName) {
|
||||||
name = strdup(name);
|
char *newName;
|
||||||
if (!name) {
|
if (VIR_STRDUP(newName, name) < 0)
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
|
if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
|
||||||
VIR_FREE(name);
|
VIR_FREE(name);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
table->names[table->nNames++] = (char *)name;
|
table->names[table->nNames++] = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virHashAddEntry(table->hashTable, name, val) < 0) {
|
if (virHashAddEntry(table->hashTable, name, val) < 0) {
|
||||||
@ -1006,11 +998,8 @@ virNWFilterVarAccessParse(const char *varAccess)
|
|||||||
|
|
||||||
if (input[idx] == '\0') {
|
if (input[idx] == '\0') {
|
||||||
/* in the form 'IP', which is equivalent to IP[@0] */
|
/* in the form 'IP', which is equivalent to IP[@0] */
|
||||||
dest->varName = strndup(input, idx);
|
if (VIR_STRNDUP(dest->varName, input, idx) < 0)
|
||||||
if (!dest->varName) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
}
|
|
||||||
dest->accessType = VIR_NWFILTER_VAR_ACCESS_ITERATOR;
|
dest->accessType = VIR_NWFILTER_VAR_ACCESS_ITERATOR;
|
||||||
dest->u.iterId = 0;
|
dest->u.iterId = 0;
|
||||||
return dest;
|
return dest;
|
||||||
@ -1023,11 +1012,8 @@ virNWFilterVarAccessParse(const char *varAccess)
|
|||||||
|
|
||||||
varNameLen = idx;
|
varNameLen = idx;
|
||||||
|
|
||||||
dest->varName = strndup(input, varNameLen);
|
if (VIR_STRNDUP(dest->varName, input, varNameLen) < 0)
|
||||||
if (!dest->varName) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
}
|
|
||||||
|
|
||||||
input += idx + 1;
|
input += idx + 1;
|
||||||
virSkipSpaces(&input);
|
virSkipSpaces(&input);
|
||||||
|
@ -463,10 +463,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
|||||||
}
|
}
|
||||||
if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) {
|
if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) {
|
||||||
VIR_FREE(disk->name);
|
VIR_FREE(disk->name);
|
||||||
if (!(disk->name = strdup(def->dom->disks[idx]->dst))) {
|
if (VIR_STRDUP(disk->name, def->dom->disks[idx]->dst) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,10 +483,8 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
|
|||||||
if (inuse)
|
if (inuse)
|
||||||
continue;
|
continue;
|
||||||
disk = &def->disks[ndisks++];
|
disk = &def->disks[ndisks++];
|
||||||
if (!(disk->name = strdup(def->dom->disks[i]->dst))) {
|
if (VIR_STRDUP(disk->name, def->dom->disks[i]->dst) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
disk->index = i;
|
disk->index = i;
|
||||||
disk->snapshot = def->dom->disks[i]->snapshot;
|
disk->snapshot = def->dom->disks[i]->snapshot;
|
||||||
if (!disk->snapshot)
|
if (!disk->snapshot)
|
||||||
@ -768,9 +764,8 @@ static void virDomainSnapshotObjListCopyNames(void *payload,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (data->names && data->count < data->maxnames &&
|
if (data->names && data->count < data->maxnames &&
|
||||||
!(data->names[data->count] = strdup(obj->def->name))) {
|
VIR_STRDUP(data->names[data->count], obj->def->name) < 0) {
|
||||||
data->error = true;
|
data->error = true;
|
||||||
virReportOOMError();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data->count++;
|
data->count++;
|
||||||
|
@ -888,11 +888,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
|
|||||||
if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) {
|
if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) {
|
||||||
if (ret->source.name == NULL) {
|
if (ret->source.name == NULL) {
|
||||||
/* source name defaults to pool name */
|
/* source name defaults to pool name */
|
||||||
ret->source.name = strdup(ret->name);
|
if (VIR_STRDUP(ret->source.name, ret->name) < 0)
|
||||||
if (ret->source.name == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1705,16 +1702,12 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(pool->configFile); /* for driver reload */
|
VIR_FREE(pool->configFile); /* for driver reload */
|
||||||
pool->configFile = strdup(path);
|
if (VIR_STRDUP(pool->configFile, path) < 0) {
|
||||||
if (pool->configFile == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
virStoragePoolDefFree(def);
|
virStoragePoolDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
VIR_FREE(pool->autostartLink); /* for driver reload */
|
VIR_FREE(pool->autostartLink); /* for driver reload */
|
||||||
pool->autostartLink = strdup(autostartLink);
|
if (VIR_STRDUP(pool->autostartLink, autostartLink) < 0) {
|
||||||
if (pool->autostartLink == NULL) {
|
|
||||||
virReportOOMError();
|
|
||||||
virStoragePoolDefFree(def);
|
virStoragePoolDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ typedef struct _virChrdevStreamInfo virChrdevStreamInfo;
|
|||||||
typedef virChrdevStreamInfo *virChrdevStreamInfoPtr;
|
typedef virChrdevStreamInfo *virChrdevStreamInfoPtr;
|
||||||
struct _virChrdevStreamInfo {
|
struct _virChrdevStreamInfo {
|
||||||
virChrdevsPtr devs;
|
virChrdevsPtr devs;
|
||||||
const char *path;
|
char *path;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef VIR_CHRDEV_LOCK_FILE_PATH
|
#ifdef VIR_CHRDEV_LOCK_FILE_PATH
|
||||||
@ -73,10 +73,8 @@ static char *virChrdevLockFilePath(const char *dev)
|
|||||||
char *filename;
|
char *filename;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (!(devCopy = strdup(dev))) {
|
if (VIR_STRDUP(devCopy, dev) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
/* skip the leading "/dev/" */
|
/* skip the leading "/dev/" */
|
||||||
filename = STRSKIP(devCopy, "/dev");
|
filename = STRSKIP(devCopy, "/dev");
|
||||||
@ -341,7 +339,7 @@ int virChrdevOpen(virChrdevsPtr devs,
|
|||||||
{
|
{
|
||||||
virChrdevStreamInfoPtr cbdata = NULL;
|
virChrdevStreamInfoPtr cbdata = NULL;
|
||||||
virStreamPtr savedStream;
|
virStreamPtr savedStream;
|
||||||
const char *path;
|
char *path;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
switch (source->type) {
|
switch (source->type) {
|
||||||
@ -401,10 +399,8 @@ int virChrdevOpen(virChrdevsPtr devs,
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
cbdata->devs = devs;
|
cbdata->devs = devs;
|
||||||
if (!(cbdata->path = strdup(path))) {
|
if (VIR_STRDUP(cbdata->path, path) < 0)
|
||||||
virReportOOMError();
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
/* open the character device */
|
/* open the character device */
|
||||||
switch (source->type) {
|
switch (source->type) {
|
||||||
|
Loading…
Reference in New Issue
Block a user