#include "viruuid.h"
#include "cpu_conf.h"
#include "virerror.h"
-
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES
caps->host.nfeatures, 1) < 0)
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;
caps->host.nfeatures++;
caps->host.nmigrateTrans, 1) < 0)
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;
caps->host.nmigrateTrans++;
for (i = 0; i < nnames; i++) {
if (VIR_ALLOC(machines[i]) < 0 ||
- !(machines[i]->name = strdup(names[i]))) {
+ VIR_STRDUP(machines[i]->name, names[i]) < 0) {
virCapabilitiesFreeMachines(machines, nnames);
return NULL;
}
virCapsGuestPtr guest;
if (VIR_ALLOC(guest) < 0)
- goto no_memory;
+ goto error;
- if ((guest->ostype = strdup(ostype)) == NULL)
- goto no_memory;
+ if (VIR_STRDUP(guest->ostype, ostype) < 0)
+ goto error;
guest->arch.id = arch;
guest->arch.wordsize = virArchGetWordSize(arch);
- if (emulator &&
- (guest->arch.defaultInfo.emulator = strdup(emulator)) == NULL)
- goto no_memory;
- if (loader &&
- (guest->arch.defaultInfo.loader = strdup(loader)) == NULL)
- goto no_memory;
+ if (VIR_STRDUP(guest->arch.defaultInfo.emulator, emulator) < 0 ||
+ VIR_STRDUP(guest->arch.defaultInfo.loader, loader) < 0)
+ goto error;
if (VIR_RESIZE_N(caps->guests, caps->nguests_max,
caps->nguests, 1) < 0)
- goto no_memory;
+ goto error;
caps->guests[caps->nguests++] = guest;
if (nmachines) {
return guest;
- no_memory:
+error:
virCapabilitiesFreeGuest(guest);
return NULL;
}
virCapsGuestDomainPtr dom;
if (VIR_ALLOC(dom) < 0)
- goto no_memory;
+ goto error;
- if ((dom->type = strdup(hvtype)) == NULL)
- goto no_memory;
-
- if (emulator &&
- (dom->info.emulator = strdup(emulator)) == NULL)
- goto no_memory;
- if (loader &&
- (dom->info.loader = strdup(loader)) == NULL)
- goto no_memory;
+ if (VIR_STRDUP(dom->type, hvtype) < 0 ||
+ VIR_STRDUP(dom->info.emulator, emulator) < 0 ||
+ VIR_STRDUP(dom->info.loader, loader) < 0)
+ goto error;
if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
guest->arch.ndomains, 1) < 0)
- goto no_memory;
+ goto error;
guest->arch.domains[guest->arch.ndomains] = dom;
guest->arch.ndomains++;
return dom;
- no_memory:
+error:
virCapabilitiesFreeGuestDomain(dom);
return NULL;
}
if (VIR_ALLOC(feature) < 0)
goto no_memory;
- if ((feature->name = strdup(name)) == NULL)
+ if (VIR_STRDUP(feature->name, name) < 0)
goto no_memory;
feature->defaultOn = defaultOn;
feature->toggle = toggle;
{
unsigned int i;
- if ((src->model && !(dst->model = strdup(src->model)))
- || (src->vendor && !(dst->vendor = strdup(src->vendor)))
- || (src->vendor_id && !(dst->vendor_id = strdup(src->vendor_id)))
- || VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
+ if (VIR_STRDUP(dst->model, src->model) < 0 ||
+ VIR_STRDUP(dst->vendor, src->vendor) < 0 ||
+ VIR_STRDUP(dst->vendor_id, src->vendor_id) < 0 ||
+ VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
goto no_memory;
dst->nfeatures_max = dst->nfeatures = src->nfeatures;
dst->features[i].policy = src->features[i].policy;
}
- if (!(dst->features[i].name = strdup(src->features[i].name)))
- goto no_memory;
+ if (VIR_STRDUP(dst->features[i].name, src->features[i].name) < 0)
+ return -1;
}
return 0;
if (!copy->cells[i].cpumask)
goto no_memory;
- if (!(copy->cells[i].cpustr = strdup(cpu->cells[i].cpustr)))
- goto no_memory;
+ if (VIR_STRDUP(copy->cells[i].cpustr, cpu->cells[i].cpustr) < 0)
+ goto error;
}
copy->cells_cpus = cpu->cells_cpus;
}
if (def->type == VIR_CPU_TYPE_HOST)
policy = -1;
- if (!(def->features[def->nfeatures].name = strdup(name)))
- goto no_memory;
+ if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
+ return -1;
def->features[def->nfeatures].policy = policy;
def->nfeatures++;
case VIR_DOMAIN_CHR_TYPE_DEV:
case VIR_DOMAIN_CHR_TYPE_FILE:
case VIR_DOMAIN_CHR_TYPE_PIPE:
- if (src->data.file.path &&
- !(dest->data.file.path = strdup(src->data.file.path))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.file.path, src->data.file.path) < 0)
return -1;
- }
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
- if (src->data.udp.bindHost &&
- !(dest->data.udp.bindHost = strdup(src->data.udp.bindHost))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.udp.bindHost, src->data.udp.bindHost) < 0)
return -1;
- }
- if (src->data.udp.bindService &&
- !(dest->data.udp.bindService = strdup(src->data.udp.bindService))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.udp.bindService, src->data.udp.bindService) < 0)
return -1;
- }
- if (src->data.udp.connectHost &&
- !(dest->data.udp.connectHost = strdup(src->data.udp.connectHost))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.udp.connectHost, src->data.udp.connectHost) < 0)
return -1;
- }
-
- if (src->data.udp.connectService &&
- !(dest->data.udp.connectService = strdup(src->data.udp.connectService))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.udp.connectService, src->data.udp.connectService) < 0)
return -1;
- }
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
- if (src->data.tcp.host &&
- !(dest->data.tcp.host = strdup(src->data.tcp.host))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.tcp.host, src->data.tcp.host) < 0)
return -1;
- }
- if (src->data.tcp.service &&
- !(dest->data.tcp.service = strdup(src->data.tcp.service))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.tcp.service, src->data.tcp.service) < 0)
return -1;
- }
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
- if (src->data.nix.path &&
- !(dest->data.nix.path = strdup(src->data.nix.path))) {
- virReportOOMError();
+ if (VIR_STRDUP(dest->data.nix.path, src->data.nix.path) < 0)
return -1;
- }
break;
}
dst->alias = NULL;
dst->romfile = NULL;
- if (src->alias && !(dst->alias = strdup(src->alias))) {
- virReportOOMError();
- return -1;
- }
- if (src->romfile && !(dst->romfile = strdup(src->romfile))) {
- virReportOOMError();
+ if (VIR_STRDUP(dst->alias, src->alias) < 0 ||
+ VIR_STRDUP(dst->romfile, src->romfile) < 0)
return -1;
- }
return 0;
}
/* Copy model from host. */
VIR_DEBUG("Found seclabel without a model, using '%s'",
host->secModels[0].model);
- def->seclabels[0]->model = strdup(host->secModels[0].model);
- if (!def->seclabels[0]->model) {
- virReportOOMError();
+ if (VIR_STRDUP(def->seclabels[0]->model, host->secModels[0].model) < 0)
goto error;
- }
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing security model in domain seclabel"));
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
- (addrtype = strdup("usb")) == NULL) {
- virReportOOMError();
+ VIR_STRDUP(addrtype, "usb") < 0)
goto error;
- }
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
hostdev, flags) < 0) {
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
if (!addrtype && virXPathNode("./source/vendor", ctxt) &&
- ((addrtype = strdup("usb")) == NULL)) {
- virReportOOMError();
+ VIR_STRDUP(addrtype, "usb") < 0)
goto error;
- }
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
hostdev, flags) < 0) {
switch (def->type) {
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
path = virXPathString("string(./backend/device/@path)", ctxt);
- if (!path && !(path = strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE))) {
- virReportOOMError();
+ if (!path && VIR_STRDUP(path, VIR_DOMAIN_TPM_DEFAULT_DEVICE) < 0)
goto error;
- }
def->data.passthrough.source.data.file.path = path;
def->data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
path = NULL;
unsigned int minor;
unsigned int hex;
- if (!(version_copy = strdup(version))) {
- virReportOOMError();
+ if (VIR_STRDUP(version_copy, version) < 0)
return -1;
- }
len = strlen(version_copy);
/*
return NULL;
}
- if (!(retemu = strdup(emulator)))
- virReportOOMError();
-
+ ignore_value(VIR_STRDUP(retemu, emulator));
return retemu;
}
def->os.type = virXPathString("string(./os/type[1])", ctxt);
if (!def->os.type) {
if (def->os.bootloader) {
- def->os.type = strdup("xen");
- if (!def->os.type) {
- goto no_memory;
- }
+ if (VIR_STRDUP(def->os.type, "xen") < 0)
+ goto error;
} else {
virReportError(VIR_ERR_OS_TYPE,
"%s", _("no OS type"));
if (STREQ(def->os.type, "linux") &&
def->virtType == VIR_DOMAIN_VIRT_XEN) {
VIR_FREE(def->os.type);
- if (!(def->os.type = strdup("xen"))) {
- goto no_memory;
- }
+ if (VIR_STRDUP(def->os.type, "xen") < 0)
+ goto error;
}
if (!virCapabilitiesSupportsGuestOSType(caps, def->os.type)) {
def->os.type,
def->os.arch,
virDomainVirtTypeToString(def->virtType));
- if (defaultMachine != NULL) {
- if (!(def->os.machine = strdup(defaultMachine))) {
- goto no_memory;
- }
- }
+ if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
+ goto error;
}
/*
_("No data supplied for <initarg> element"));
goto error;
}
- if (!(def->os.initargv[i] = strdup((const char*)nodes[i]->children->content)))
- goto no_memory;
+ if (VIR_STRDUP(def->os.initargv[i],
+ (const char*) nodes[i]->children->content) < 0)
+ goto error;
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
virObjectLock(obj);
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;
else
data->numnames++;
if (data.oom) {
for (i = 0; i < data.numnames; i++)
VIR_FREE(data.names[i]);
- virReportOOMError();
return -1;
}
return 0;
}
- listenInfo->address = (len == -1) ? strdup(address) : strndup(address, len);
- if (!listenInfo->address) {
- virReportOOMError();
+ if (VIR_STRNDUP(listenInfo->address, address,
+ len == -1 ? strlen(address) : len) < 0)
return -1;
- }
-
return 0;
}
return 0;
}
- listenInfo->network = (len == -1) ? strdup(network) : strndup(network, len);
- if (!listenInfo->network) {
- virReportOOMError();
+ if (VIR_STRNDUP(listenInfo->network, network,
+ len == -1 ? strlen(network) : len) < 0)
return -1;
- }
-
return 0;
}
virSecurityLabelDefPtr seclabel = NULL;
if (VIR_ALLOC(seclabel) < 0 ||
- (model && !(seclabel->model = strdup(model)))) {
+ VIR_STRDUP(seclabel->model, model) < 0) {
virReportOOMError();
virSecurityLabelDefFree(seclabel);
seclabel = NULL;
virSecurityDeviceLabelDefPtr seclabel = NULL;
if (VIR_ALLOC(seclabel) < 0 ||
- (model && !(seclabel->model = strdup(model)))) {
+ VIR_STRDUP(seclabel->model, model) < 0) {
virReportOOMError();
virSecurityDeviceLabelDefFree(seclabel);
seclabel = NULL;
#include "datatypes.h"
#include "viralloc.h"
#include "virerror.h"
+#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_NONE
if (dom) {
if (VIR_ALLOC(event->dom) < 0)
goto no_memory;
- if (!(event->dom->name = strdup(dom->name)))
- goto no_memory;
+ if (VIR_STRDUP(event->dom->name, dom->name) < 0)
+ goto error;
memcpy(event->dom->uuid, dom->uuid, VIR_UUID_BUFLEN);
event->dom->id = dom->id;
}
no_memory:
virReportOOMError();
-
+error:
if (event) {
if (event->dom)
VIR_FREE(event->dom->name);
}
event->eventID = eventID;
- if (!(event->dom.name = strdup(name))) {
- virReportOOMError();
+ if (VIR_STRDUP(event->dom.name, name) < 0) {
VIR_FREE(event);
return NULL;
}
if (ev) {
ev->data.ioError.action = action;
- if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
- !(ev->data.ioError.devAlias = strdup(devAlias)) ||
- (reason && !(ev->data.ioError.reason = strdup(reason)))) {
+ if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
+ VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
+ VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
virDomainEventFree(ev);
ev = NULL;
}
if (ev) {
ev->data.ioError.action = action;
- if (!(ev->data.ioError.srcPath = strdup(srcPath)) ||
- !(ev->data.ioError.devAlias = strdup(devAlias)) ||
- (reason && !(ev->data.ioError.reason = strdup(reason)))) {
+ if (VIR_STRDUP(ev->data.ioError.srcPath, srcPath) < 0 ||
+ VIR_STRDUP(ev->data.ioError.devAlias, devAlias) < 0 ||
+ VIR_STRDUP(ev->data.ioError.reason, reason) < 0) {
virDomainEventFree(ev);
ev = NULL;
}
if (ev) {
ev->data.graphics.phase = phase;
- if (!(ev->data.graphics.authScheme = strdup(authScheme))) {
+ if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
virDomainEventFree(ev);
return NULL;
}
if (ev) {
ev->data.graphics.phase = phase;
- if (!(ev->data.graphics.authScheme = strdup(authScheme))) {
+ if (VIR_STRDUP(ev->data.graphics.authScheme, authScheme) < 0) {
virDomainEventFree(ev);
return NULL;
}
id, name, uuid);
if (ev) {
- if (!(ev->data.blockJob.path = strdup(path))) {
- virReportOOMError();
+ if (VIR_STRDUP(ev->data.blockJob.path, path) < 0) {
virDomainEventFree(ev);
return NULL;
}
id, name, uuid);
if (ev) {
- if (!(ev->data.diskChange.devAlias = strdup(devAlias)))
+ if (VIR_STRDUP(ev->data.diskChange.devAlias, devAlias) < 0)
goto error;
- if (oldSrcPath &&
- !(ev->data.diskChange.oldSrcPath = strdup(oldSrcPath)))
+ if (VIR_STRDUP(ev->data.diskChange.oldSrcPath, oldSrcPath) < 0)
goto error;
- if (newSrcPath &&
- !(ev->data.diskChange.newSrcPath = strdup(newSrcPath)))
+ if (VIR_STRDUP(ev->data.diskChange.newSrcPath, newSrcPath) < 0)
goto error;
ev->data.diskChange.reason = reason;
return ev;
error:
- virReportOOMError();
virDomainEventFree(ev);
return NULL;
}
id, name, uuid);
if (ev) {
- if (!(ev->data.trayChange.devAlias = strdup(devAlias)))
+ if (VIR_STRDUP(ev->data.trayChange.devAlias, devAlias) < 0)
goto error;
ev->data.trayChange.reason = reason;
return ev;
error:
- virReportOOMError();
virDomainEventFree(ev);
return NULL;
}
#include "virerror.h"
#include "datatypes.h"
#include "viralloc.h"
-
+#include "virstring.h"
#include "node_device_conf.h"
#include "virxml.h"
#include "virbuffer.h"
goto error;
}
} else {
- def->name = strdup("new device");
-
- if (!def->name) {
- virReportOOMError();
+ if (VIR_STRDUP(def->name, "new device") < 0)
goto error;
- }
}
/* Extract device parent, if any */
char **wwpn)
{
virNodeDevCapsDefPtr cap = NULL;
- int ret = 0;
+ int ret = -1;
cap = def->caps;
while (cap != NULL) {
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST &&
cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
- *wwnn = strdup(cap->data.scsi_host.wwnn);
- *wwpn = strdup(cap->data.scsi_host.wwpn);
+ if (VIR_STRDUP(*wwnn, cap->data.scsi_host.wwnn) < 0 ||
+ VIR_STRDUP(*wwpn, cap->data.scsi_host.wwpn) < 0) {
+ /* Free the other one, if allocated... */
+ VIR_FREE(*wwnn);
+ goto cleanup;
+ }
break;
}
if (cap == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Device is not a fibre channel HBA"));
- ret = -1;
- } else if (*wwnn == NULL || *wwpn == NULL) {
- /* Free the other one, if allocated... */
- VIR_FREE(*wwnn);
- VIR_FREE(*wwpn);
- ret = -1;
- virReportOOMError();
+ goto cleanup;
}
+ ret = 0;
+cleanup:
return ret;
}
return NULL;
}
- nwf->strings[nwf->nstrings] = strndup(string, maxstrlen);
-
- if (!nwf->strings[nwf->nstrings]) {
- virReportOOMError();
+ if (VIR_STRNDUP(nwf->strings[nwf->nstrings], string, maxstrlen) < 0)
return NULL;
- }
nwf->nstrings++;
}
chain = NULL;
} else {
- ret->chainsuffix = strdup(virNWFilterChainSuffixTypeToString(
- VIR_NWFILTER_CHAINSUFFIX_ROOT));
- if (ret->chainsuffix == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(ret->chainsuffix,
+ virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT)) < 0)
goto cleanup;
- }
}
uuid = virXPathString("string(./uuid)", ctxt);
}
VIR_FREE(nwfilter->configFile); /* for driver reload */
- nwfilter->configFile = strdup(path);
- if (nwfilter->configFile == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(nwfilter->configFile, path) < 0) {
virNWFilterDefFree(def);
return NULL;
}
switch (res->valType) {
case NWFILTER_VALUE_TYPE_SIMPLE:
- if (val->u.simple.value) {
- res->u.simple.value = strdup(val->u.simple.value);
- if (!res->u.simple.value)
- goto err_exit;
- }
+ if (VIR_STRDUP(res->u.simple.value, val->u.simple.value) < 0)
+ goto err_exit;
break;
case NWFILTER_VALUE_TYPE_ARRAY:
if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0)
goto err_exit;
res->u.array.nValues = val->u.array.nValues;
for (i = 0; i < val->u.array.nValues; i++) {
- str = strdup(val->u.array.values[i]);
- if (!str)
+ if (VIR_STRDUP(str, val->u.array.values[i]) < 0)
goto err_exit;
res->u.array.values[i] = str;
}
virNWFilterVarValuePtr
virNWFilterVarValueCreateSimpleCopyValue(const char *value)
{
- char *val = strdup(value);
+ char *val;
- if (!val) {
- virReportOOMError();
+ if (VIR_STRDUP(val, value) < 0)
return NULL;
- }
return virNWFilterVarValueCreateSimple(val);
}
{
if (!virHashLookup(table->hashTable, name)) {
if (copyName) {
- name = strdup(name);
- if (!name) {
- virReportOOMError();
+ char *newName;
+ if (VIR_STRDUP(newName, name) < 0)
return -1;
- }
if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
VIR_FREE(name);
return -1;
}
- table->names[table->nNames++] = (char *)name;
+ table->names[table->nNames++] = newName;
}
if (virHashAddEntry(table->hashTable, name, val) < 0) {
if (input[idx] == '\0') {
/* in the form 'IP', which is equivalent to IP[@0] */
- dest->varName = strndup(input, idx);
- if (!dest->varName) {
- virReportOOMError();
+ if (VIR_STRNDUP(dest->varName, input, idx) < 0)
goto err_exit;
- }
dest->accessType = VIR_NWFILTER_VAR_ACCESS_ITERATOR;
dest->u.iterId = 0;
return dest;
varNameLen = idx;
- dest->varName = strndup(input, varNameLen);
- if (!dest->varName) {
- virReportOOMError();
+ if (VIR_STRNDUP(dest->varName, input, varNameLen) < 0)
goto err_exit;
- }
input += idx + 1;
virSkipSpaces(&input);
}
if (STRNEQ(disk->name, def->dom->disks[idx]->dst)) {
VIR_FREE(disk->name);
- if (!(disk->name = strdup(def->dom->disks[idx]->dst))) {
- virReportOOMError();
+ if (VIR_STRDUP(disk->name, def->dom->disks[idx]->dst) < 0)
goto cleanup;
- }
}
}
if (inuse)
continue;
disk = &def->disks[ndisks++];
- if (!(disk->name = strdup(def->dom->disks[i]->dst))) {
- virReportOOMError();
+ if (VIR_STRDUP(disk->name, def->dom->disks[i]->dst) < 0)
goto cleanup;
- }
disk->index = i;
disk->snapshot = def->dom->disks[i]->snapshot;
if (!disk->snapshot)
return;
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;
- virReportOOMError();
return;
}
data->count++;
if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) {
if (ret->source.name == NULL) {
/* source name defaults to pool name */
- ret->source.name = strdup(ret->name);
- if (ret->source.name == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(ret->source.name, ret->name) < 0)
goto cleanup;
- }
}
}
}
VIR_FREE(pool->configFile); /* for driver reload */
- pool->configFile = strdup(path);
- if (pool->configFile == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(pool->configFile, path) < 0) {
virStoragePoolDefFree(def);
return NULL;
}
VIR_FREE(pool->autostartLink); /* for driver reload */
- pool->autostartLink = strdup(autostartLink);
- if (pool->autostartLink == NULL) {
- virReportOOMError();
+ if (VIR_STRDUP(pool->autostartLink, autostartLink) < 0) {
virStoragePoolDefFree(def);
return NULL;
}
typedef virChrdevStreamInfo *virChrdevStreamInfoPtr;
struct _virChrdevStreamInfo {
virChrdevsPtr devs;
- const char *path;
+ char *path;
};
#ifdef VIR_CHRDEV_LOCK_FILE_PATH
char *filename;
char *p;
- if (!(devCopy = strdup(dev))) {
- virReportOOMError();
+ if (VIR_STRDUP(devCopy, dev) < 0)
goto cleanup;
- }
/* skip the leading "/dev/" */
filename = STRSKIP(devCopy, "/dev");
{
virChrdevStreamInfoPtr cbdata = NULL;
virStreamPtr savedStream;
- const char *path;
+ char *path;
int ret;
switch (source->type) {
goto error;
cbdata->devs = devs;
- if (!(cbdata->path = strdup(path))) {
- virReportOOMError();
+ if (VIR_STRDUP(cbdata->path, path) < 0)
goto error;
- }
/* open the character device */
switch (source->type) {