Replace all occurrences of
if (VIR_STRDUP(a, b) < 0)
/* effectively dead code */
with:
a = g_strdup(b);
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/conf/capabilities.c | 33 +++----
src/conf/checkpoint_conf.c | 9 +-
src/conf/cpu_conf.c | 15 ++--
src/conf/domain_audit.c | 15 +---
src/conf/domain_capabilities.c | 8 +-
src/conf/domain_conf.c | 143 ++++++++++--------------------
src/conf/domain_event.c | 103 ++++++---------------
src/conf/domain_nwfilter.c | 14 ++-
src/conf/networkcommon_conf.c | 3 +-
src/conf/node_device_conf.c | 14 +--
src/conf/node_device_util.c | 3 +-
src/conf/nwfilter_conf.c | 4 +-
src/conf/nwfilter_ipaddrmap.c | 3 +-
src/conf/nwfilter_params.c | 12 +--
src/conf/object_event.c | 10 +--
src/conf/snapshot_conf.c | 9 +-
src/conf/storage_conf.c | 13 ++-
src/conf/virchrdev.c | 6 +-
src/conf/virdomainmomentobjlist.c | 7 +-
src/conf/virdomainobjlist.c | 10 +--
src/conf/virinterfaceobj.c | 11 +--
src/conf/virnetworkobj.c | 7 +-
src/conf/virnodedeviceobj.c | 10 +--
src/conf/virnwfilterbindingdef.c | 12 +--
src/conf/virnwfilterobj.c | 11 +--
src/conf/virstorageobj.c | 28 ++----
26 files changed, 153 insertions(+), 360 deletions(-)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1781c1df0a..697d464fe9 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -288,8 +288,7 @@ virCapabilitiesAddHostFeature(virCapsPtr caps,
caps->host.nfeatures, 1) < 0)
return -1;
- if (VIR_STRDUP(caps->host.features[caps->host.nfeatures], name) < 0)
- return -1;
+ caps->host.features[caps->host.nfeatures] = g_strdup(name);
caps->host.nfeatures++;
return 0;
@@ -310,8 +309,7 @@ virCapabilitiesAddHostMigrateTransport(virCapsPtr caps,
caps->host.nmigrateTrans, 1) < 0)
return -1;
- if (VIR_STRDUP(caps->host.migrateTrans[caps->host.nmigrateTrans], name) <
0)
- return -1;
+ caps->host.migrateTrans[caps->host.nmigrateTrans] = g_strdup(name);
caps->host.nmigrateTrans++;
return 0;
@@ -328,8 +326,7 @@ int
virCapabilitiesSetNetPrefix(virCapsPtr caps,
const char *prefix)
{
- if (VIR_STRDUP(caps->host.netprefix, prefix) < 0)
- return -1;
+ caps->host.netprefix = g_strdup(prefix);
return 0;
}
@@ -423,11 +420,11 @@ virCapabilitiesAllocMachines(const char *const *names, int nnames)
return NULL;
for (i = 0; i < nnames; i++) {
- if (VIR_ALLOC(machines[i]) < 0 ||
- VIR_STRDUP(machines[i]->name, names[i]) < 0) {
+ if (VIR_ALLOC(machines[i]) < 0) {
virCapabilitiesFreeMachines(machines, nnames);
return NULL;
}
+ machines[i]->name = g_strdup(names[i]);
}
return machines;
@@ -486,9 +483,8 @@ virCapabilitiesAddGuest(virCapsPtr caps,
guest->arch.id = arch;
guest->arch.wordsize = virArchGetWordSize(arch);
- if (VIR_STRDUP(guest->arch.defaultInfo.emulator, emulator) < 0 ||
- VIR_STRDUP(guest->arch.defaultInfo.loader, loader) < 0)
- goto error;
+ guest->arch.defaultInfo.emulator = g_strdup(emulator);
+ guest->arch.defaultInfo.loader = g_strdup(loader);
if (VIR_RESIZE_N(caps->guests, caps->nguests_max,
caps->nguests, 1) < 0)
@@ -534,9 +530,8 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest,
goto error;
dom->type = hvtype;
- if (VIR_STRDUP(dom->info.emulator, emulator) < 0 ||
- VIR_STRDUP(dom->info.loader, loader) < 0)
- goto error;
+ dom->info.emulator = g_strdup(emulator);
+ dom->info.loader = g_strdup(loader);
if (VIR_RESIZE_N(guest->arch.domains, guest->arch.ndomains_max,
guest->arch.ndomains, 1) < 0)
@@ -577,8 +572,7 @@ virCapabilitiesAddGuestFeature(virCapsGuestPtr guest,
if (VIR_ALLOC(feature) < 0)
goto no_memory;
- if (VIR_STRDUP(feature->name, name) < 0)
- goto no_memory;
+ feature->name = g_strdup(name);
feature->defaultOn = defaultOn;
feature->toggle = toggle;
@@ -612,11 +606,8 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModelPtr
secmodel,
if (type == NULL || label == NULL)
return -1;
- if (VIR_STRDUP(t, type) < 0)
- goto no_memory;
-
- if (VIR_STRDUP(l, label) < 0)
- goto no_memory;
+ t = g_strdup(type);
+ l = g_strdup(label);
if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0)
goto no_memory;
diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c
index b254dce7fd..4fa743e0b0 100644
--- a/src/conf/checkpoint_conf.c
+++ b/src/conf/checkpoint_conf.c
@@ -275,8 +275,7 @@ virDomainCheckpointDefAssignBitmapNames(virDomainCheckpointDefPtr
def)
disk->bitmap)
continue;
- if (VIR_STRDUP(disk->bitmap, def->parent.name) < 0)
- return -1;
+ disk->bitmap = g_strdup(def->parent.name);
}
return 0;
@@ -365,8 +364,7 @@ virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr def)
if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) {
VIR_FREE(disk->name);
- if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) <
0)
- goto cleanup;
+ disk->name = g_strdup(def->parent.dom->disks[idx]->dst);
}
}
@@ -382,8 +380,7 @@ virDomainCheckpointAlignDisks(virDomainCheckpointDefPtr def)
if (virBitmapIsBitSet(map, i))
continue;
disk = &def->disks[ndisks++];
- if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0)
- goto cleanup;
+ disk->name = g_strdup(def->parent.dom->disks[i]->dst);
disk->idx = i;
/* Don't checkpoint empty or readonly drives */
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 80b7687b86..1d9feb2f0a 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -136,11 +136,12 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
size_t i;
size_t n;
- 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)
+ if (VIR_ALLOC_N(dst->features, src->nfeatures) < 0)
return -1;
+
+ dst->model = g_strdup(src->model);
+ dst->vendor = g_strdup(src->vendor);
+ dst->vendor_id = g_strdup(src->vendor_id);
dst->microcodeVersion = src->microcodeVersion;
dst->nfeatures_max = src->nfeatures;
dst->nfeatures = 0;
@@ -161,8 +162,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
dst->features[n].policy = src->features[i].policy;
}
- if (VIR_STRDUP(dst->features[n].name, src->features[i].name) < 0)
- return -1;
+ dst->features[n].name = g_strdup(src->features[i].name);
}
return 0;
@@ -896,8 +896,7 @@ virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
def->nfeatures, 1) < 0)
return -1;
- if (VIR_STRDUP(def->features[def->nfeatures].name, name) < 0)
- return -1;
+ def->features[def->nfeatures].name = g_strdup(name);
def->features[def->nfeatures].policy = policy;
def->nfeatures++;
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index e455661e4f..2ae39e3698 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -414,16 +414,10 @@ virDomainAuditHostdev(virDomainObjPtr vm, virDomainHostdevDefPtr
hostdev,
break;
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
- if (VIR_STRDUP_QUIET(address, hostsrc->wwpn) < 0) {
- VIR_WARN("OOM while encoding audit message");
- goto cleanup;
- }
+ address = g_strdup(hostsrc->wwpn);
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV:
- if (VIR_STRDUP_QUIET(address, mdevsrc->uuidstr) < 0) {
- VIR_WARN("OOM while encoding audit message");
- goto cleanup;
- }
+ address = g_strdup(mdevsrc->uuidstr);
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
default:
@@ -518,10 +512,7 @@ virDomainAuditRedirdev(virDomainObjPtr vm, virDomainRedirdevDefPtr
redirdev,
switch (redirdev->bus) {
case VIR_DOMAIN_REDIRDEV_BUS_USB:
- if (VIR_STRDUP_QUIET(address, "USB redirdev") < 0) {
- VIR_WARN("OOM while encoding audit message");
- goto cleanup;
- }
+ address = g_strdup("USB redirdev");
break;
default:
VIR_WARN("Unexpected redirdev bus while encoding audit message: %d",
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index 43a778a505..3c4c7fd6d1 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -124,16 +124,12 @@ virDomainCapsNew(const char *path,
if (!(caps = virObjectLockableNew(virDomainCapsClass)))
return NULL;
- if (VIR_STRDUP(caps->path, path) < 0 ||
- VIR_STRDUP(caps->machine, machine) < 0)
- goto error;
+ caps->path = g_strdup(path);
+ caps->machine = g_strdup(machine);
caps->arch = arch;
caps->virttype = virttype;
return caps;
- error:
- virObjectUnref(caps);
- return NULL;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d0dd7b3fa9..afa997b381 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2548,30 +2548,19 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
case VIR_DOMAIN_CHR_TYPE_PIPE:
if (src->type == VIR_DOMAIN_CHR_TYPE_FILE)
dest->data.file.append = src->data.file.append;
- if (VIR_STRDUP(dest->data.file.path, src->data.file.path) < 0)
- return -1;
+ dest->data.file.path = g_strdup(src->data.file.path);
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
- if (VIR_STRDUP(dest->data.udp.bindHost, src->data.udp.bindHost) < 0)
- return -1;
-
- if (VIR_STRDUP(dest->data.udp.bindService, src->data.udp.bindService) <
0)
- return -1;
-
- if (VIR_STRDUP(dest->data.udp.connectHost, src->data.udp.connectHost) <
0)
- return -1;
-
- if (VIR_STRDUP(dest->data.udp.connectService, src->data.udp.connectService)
< 0)
- return -1;
+ dest->data.udp.bindHost = g_strdup(src->data.udp.bindHost);
+ dest->data.udp.bindService = g_strdup(src->data.udp.bindService);
+ dest->data.udp.connectHost = g_strdup(src->data.udp.connectHost);
+ dest->data.udp.connectService = g_strdup(src->data.udp.connectService);
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
- if (VIR_STRDUP(dest->data.tcp.host, src->data.tcp.host) < 0)
- return -1;
-
- if (VIR_STRDUP(dest->data.tcp.service, src->data.tcp.service) < 0)
- return -1;
+ dest->data.tcp.host = g_strdup(src->data.tcp.host);
+ dest->data.tcp.service = g_strdup(src->data.tcp.service);
dest->data.tcp.haveTLS = src->data.tcp.haveTLS;
dest->data.tcp.tlsFromConfig = src->data.tcp.tlsFromConfig;
@@ -2581,18 +2570,15 @@ virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
- if (VIR_STRDUP(dest->data.nix.path, src->data.nix.path) < 0)
- return -1;
+ dest->data.nix.path = g_strdup(src->data.nix.path);
dest->data.nix.reconnect.enabled = src->data.nix.reconnect.enabled;
dest->data.nix.reconnect.timeout = src->data.nix.reconnect.timeout;
break;
case VIR_DOMAIN_CHR_TYPE_NMDM:
- if (VIR_STRDUP(dest->data.nmdm.master, src->data.nmdm.master) < 0)
- return -1;
- if (VIR_STRDUP(dest->data.nmdm.slave, src->data.nmdm.slave) < 0)
- return -1;
+ dest->data.nmdm.master = g_strdup(src->data.nmdm.master);
+ dest->data.nmdm.slave = g_strdup(src->data.nmdm.slave);
break;
}
@@ -5066,8 +5052,7 @@ virDomainRNGDefPostParse(virDomainRNGDefPtr rng)
/* set default path for virtio-rng "random" backend to /dev/random */
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM &&
!rng->source.file) {
- if (VIR_STRDUP(rng->source.file, "/dev/random") < 0)
- return -1;
+ rng->source.file = g_strdup("/dev/random");
}
return 0;
@@ -8854,8 +8839,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
/* Copy model from host. */
VIR_DEBUG("Found seclabel without a model, using '%s'",
host->secModels[0].model);
- if (VIR_STRDUP(def->seclabels[0]->model, host->secModels[0].model)
< 0)
- goto error;
+ def->seclabels[0]->model = g_strdup(host->secModels[0].model);
if (STREQ(def->seclabels[0]->model, "none") &&
flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
@@ -9188,8 +9172,7 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
src->volume = src->path;
- if (VIR_STRDUP(src->path, tmp + 1) < 0)
- return -1;
+ src->path = g_strdup(tmp + 1);
tmp[0] = '\0';
}
@@ -11244,9 +11227,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
*/
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
- if (!addrtype && virXPathNode("./source/vendor", ctxt)
&&
- VIR_STRDUP(addrtype, "usb") < 0)
- goto error;
+ if (!addrtype && virXPathNode("./source/vendor", ctxt))
+ addrtype = g_strdup("usb");
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
hostdev, flags) < 0) {
@@ -11877,9 +11859,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
*/
addrtype = virXPathString("string(./source/address/@type)", ctxt);
/* if not explicitly stated, source/vendor implies usb device */
- if (!addrtype && virXPathNode("./source/vendor", ctxt)
&&
- VIR_STRDUP(addrtype, "usb") < 0)
- goto error;
+ if (!addrtype && virXPathNode("./source/vendor", ctxt))
+ addrtype = g_strdup("usb");
hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype,
hostdev, flags) < 0) {
@@ -14972,8 +14953,7 @@ virSysinfoSystemParseXML(xmlNodePtr node,
* properly so that it's used correctly later.
*/
virUUIDFormat(uuidbuf, uuidstr);
- if (VIR_STRDUP(def->uuid, uuidstr) < 0)
- goto cleanup;
+ def->uuid = g_strdup(uuidstr);
}
def->sku =
virXPathString("string(entry[@name='sku'])", ctxt);
@@ -17986,8 +17966,7 @@ virDomainDefGetDefaultEmulator(virDomainDefPtr def,
def->os.arch, def->virtType, NULL, NULL)))
return NULL;
- if (VIR_STRDUP(retemu, capsdata->emulator) < 0)
- return NULL;
+ retemu = g_strdup(capsdata->emulator);
return retemu;
}
@@ -19011,9 +18990,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
_("No data supplied for <initarg>
element"));
return -1;
}
- if (VIR_STRDUP(def->os.initargv[i],
- (const char*) nodes[i]->children->content) < 0)
- return -1;
+ def->os.initargv[i] = g_strdup((const char
*)nodes[i]->children->content);
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
@@ -19042,9 +19019,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
return -1;
def->os.initenv[i]->name = name;
- if (VIR_STRDUP(def->os.initenv[i]->value,
- (const char*) nodes[i]->children->content) < 0)
- return -1;
+ def->os.initenv[i]->value = g_strdup((const char
*)nodes[i]->children->content);
}
def->os.initenv[n] = NULL;
VIR_FREE(nodes);
@@ -19407,8 +19382,7 @@ virDomainResctrlMonDefParse(virDomainDefPtr def,
if (rv == 1) {
const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
- if (VIR_STRDUP(id, alloc_id) < 0)
- goto cleanup;
+ id = g_strdup(alloc_id);
} else {
if (!(tmp = virBitmapFormat(domresmon->vcpus)))
goto cleanup;
@@ -19633,9 +19607,8 @@ virDomainDefParseCaps(virDomainDefPtr def,
} else {
if (!def->os.arch)
def->os.arch = capsdata->arch;
- if ((!def->os.machine &&
- VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0))
- return -1;
+ if (!def->os.machine)
+ def->os.machine = g_strdup(capsdata->machinetype);
}
return 0;
@@ -29809,8 +29782,7 @@ virDomainNetSetModelString(virDomainNetDefPtr net,
return -1;
}
- if (VIR_STRDUP(net->modelstr, model) < 0)
- return -1;
+ net->modelstr = g_strdup(model);
return 0;
}
@@ -29847,8 +29819,7 @@ virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def,
glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
- if (VIR_STRDUP(glisten.address, address) < 0)
- goto error;
+ glisten.address = g_strdup(address);
if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0)
goto error;
@@ -29870,8 +29841,7 @@ virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def,
glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
- if (VIR_STRDUP(glisten.socket, socketPath) < 0)
- goto error;
+ glisten.socket = g_strdup(socketPath);
if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0)
goto error;
@@ -30165,13 +30135,11 @@ virDomainObjGetMetadata(virDomainObjPtr vm,
switch ((virDomainMetadataType) type) {
case VIR_DOMAIN_METADATA_DESCRIPTION:
- if (VIR_STRDUP(ret, def->description) < 0)
- return NULL;
+ ret = g_strdup(def->description);
break;
case VIR_DOMAIN_METADATA_TITLE:
- if (VIR_STRDUP(ret, def->title) < 0)
- return NULL;
+ ret = g_strdup(def->title);
break;
case VIR_DOMAIN_METADATA_ELEMENT:
@@ -30216,16 +30184,16 @@ virDomainDefSetMetadata(virDomainDefPtr def,
switch ((virDomainMetadataType) type) {
case VIR_DOMAIN_METADATA_DESCRIPTION:
- if (STRNEQ_NULLABLE(metadata, "") && VIR_STRDUP(tmp, metadata)
< 0)
- goto cleanup;
+ if (STRNEQ_NULLABLE(metadata, ""))
+ tmp = g_strdup(metadata);
VIR_FREE(def->description);
def->description = tmp;
break;
case VIR_DOMAIN_METADATA_TITLE:
- if (STRNEQ_NULLABLE(metadata, "") && VIR_STRDUP(tmp, metadata)
< 0)
- goto cleanup;
+ if (STRNEQ_NULLABLE(metadata, ""))
+ tmp = g_strdup(metadata);
VIR_FREE(def->title);
def->title = tmp;
@@ -30511,8 +30479,7 @@ virDomainDiskSetBlockIOTune(virDomainDiskDefPtr disk,
{
char *tmp_group = NULL;
- if (VIR_STRDUP(tmp_group, info->group_name) < 0)
- return -1;
+ tmp_group = g_strdup(info->group_name);
VIR_FREE(disk->blkdeviotune.group_name);
disk->blkdeviotune = *info;
@@ -30640,11 +30607,9 @@ virDomainNetDefToNetworkPort(virDomainDefPtr dom,
}
memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN);
- if (VIR_STRDUP(port->ownername, dom->name) < 0)
- return NULL;
+ port->ownername = g_strdup(dom->name);
- if (VIR_STRDUP(port->group, iface->data.network.portgroup) < 0)
- return NULL;
+ port->group = g_strdup(iface->data.network.portgroup);
memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN);
@@ -30684,25 +30649,19 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDefPtr iface,
case VIR_NETWORK_PORT_PLUG_TYPE_NETWORK:
actual->type = VIR_DOMAIN_NET_TYPE_NETWORK;
- if (VIR_STRDUP(actual->data.bridge.brname,
- port->plug.bridge.brname) < 0)
- goto error;
+ actual->data.bridge.brname = g_strdup(port->plug.bridge.brname);
actual->data.bridge.macTableManager = port->plug.bridge.macTableManager;
break;
case VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE:
actual->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
- if (VIR_STRDUP(actual->data.bridge.brname,
- port->plug.bridge.brname) < 0)
- goto error;
+ actual->data.bridge.brname = g_strdup(port->plug.bridge.brname);
actual->data.bridge.macTableManager = port->plug.bridge.macTableManager;
break;
case VIR_NETWORK_PORT_PLUG_TYPE_DIRECT:
actual->type = VIR_DOMAIN_NET_TYPE_DIRECT;
- if (VIR_STRDUP(actual->data.direct.linkdev,
- port->plug.direct.linkdev) < 0)
- goto error;
+ actual->data.direct.linkdev = g_strdup(port->plug.direct.linkdev);
actual->data.direct.mode = port->plug.direct.mode;
break;
@@ -30810,36 +30769,28 @@ virDomainNetDefActualToNetworkPort(virDomainDefPtr dom,
}
memcpy(port->owneruuid, dom->uuid, VIR_UUID_BUFLEN);
- if (VIR_STRDUP(port->ownername, dom->name) < 0)
- return NULL;
+ port->ownername = g_strdup(dom->name);
- if (VIR_STRDUP(port->group, iface->data.network.portgroup) < 0)
- return NULL;
+ port->group = g_strdup(iface->data.network.portgroup);
memcpy(&port->mac, &iface->mac, VIR_MAC_BUFLEN);
switch (virDomainNetGetActualType(iface)) {
case VIR_DOMAIN_NET_TYPE_NETWORK:
port->plugtype = VIR_NETWORK_PORT_PLUG_TYPE_NETWORK;
- if (VIR_STRDUP(port->plug.bridge.brname,
- actual->data.bridge.brname) < 0)
- return NULL;
+ port->plug.bridge.brname = g_strdup(actual->data.bridge.brname);
port->plug.bridge.macTableManager = actual->data.bridge.macTableManager;
break;
case VIR_DOMAIN_NET_TYPE_BRIDGE:
port->plugtype = VIR_NETWORK_PORT_PLUG_TYPE_BRIDGE;
- if (VIR_STRDUP(port->plug.bridge.brname,
- actual->data.bridge.brname) < 0)
- return NULL;
+ port->plug.bridge.brname = g_strdup(actual->data.bridge.brname);
port->plug.bridge.macTableManager = actual->data.bridge.macTableManager;
break;
case VIR_DOMAIN_NET_TYPE_DIRECT:
port->plugtype = VIR_NETWORK_PORT_PLUG_TYPE_DIRECT;
- if (VIR_STRDUP(port->plug.direct.linkdev,
- actual->data.direct.linkdev) < 0)
- return NULL;
+ port->plug.direct.linkdev = g_strdup(actual->data.direct.linkdev);
port->plug.direct.mode = actual->data.direct.mode;
break;
@@ -31235,8 +31186,7 @@ virDomainDiskAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
if (VIR_ALLOC_N(def->src->hosts, def->src->nhosts) < 0)
goto cleanup;
- if (VIR_STRDUP(def->src->hosts[0].name, pooldef->source.hosts[0].name) <
0)
- goto cleanup;
+ def->src->hosts[0].name = g_strdup(pooldef->source.hosts[0].name);
def->src->hosts[0].port = pooldef->source.hosts[0].port ?
pooldef->source.hosts[0].port : 3260;
@@ -31308,8 +31258,7 @@ virDomainDiskTranslateISCSIDirect(virDomainDiskDefPtr def,
if (def->src->auth && !def->src->auth->secrettype) {
const char *secrettype =
virSecretUsageTypeToString(VIR_SECRET_USAGE_TYPE_ISCSI);
- if (VIR_STRDUP(def->src->auth->secrettype, secrettype) < 0)
- return -1;
+ def->src->auth->secrettype = g_strdup(secrettype);
}
if (virDomainDiskAddISCSIPoolSourceHost(def, pooldef) < 0)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index c0dcf8f716..644f6eb595 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -753,12 +753,9 @@ virDomainEventIOErrorNewFromDomImpl(int event,
return NULL;
ev->action = action;
- if (VIR_STRDUP(ev->srcPath, srcPath) < 0 ||
- VIR_STRDUP(ev->devAlias, devAlias) < 0 ||
- VIR_STRDUP(ev->reason, reason) < 0) {
- virObjectUnref(ev);
- ev = NULL;
- }
+ ev->srcPath = g_strdup(srcPath);
+ ev->devAlias = g_strdup(devAlias);
+ ev->reason = g_strdup(reason);
return (virObjectEventPtr)ev;
}
@@ -782,12 +779,9 @@ virDomainEventIOErrorNewFromObjImpl(int event,
return NULL;
ev->action = action;
- if (VIR_STRDUP(ev->srcPath, srcPath) < 0 ||
- VIR_STRDUP(ev->devAlias, devAlias) < 0 ||
- VIR_STRDUP(ev->reason, reason) < 0) {
- virObjectUnref(ev);
- ev = NULL;
- }
+ ev->srcPath = g_strdup(srcPath);
+ ev->devAlias = g_strdup(devAlias);
+ ev->reason = g_strdup(reason);
return (virObjectEventPtr)ev;
}
@@ -858,10 +852,7 @@ virDomainEventGraphicsNewFromDom(virDomainPtr dom,
return NULL;
ev->phase = phase;
- if (VIR_STRDUP(ev->authScheme, authScheme) < 0) {
- virObjectUnref(ev);
- return NULL;
- }
+ ev->authScheme = g_strdup(authScheme);
ev->local = local;
ev->remote = remote;
ev->subject = subject;
@@ -889,10 +880,7 @@ virDomainEventGraphicsNewFromObj(virDomainObjPtr obj,
return NULL;
ev->phase = phase;
- if (VIR_STRDUP(ev->authScheme, authScheme) < 0) {
- virObjectUnref(ev);
- return NULL;
- }
+ ev->authScheme = g_strdup(authScheme);
ev->local = local;
ev->remote = remote;
ev->subject = subject;
@@ -919,10 +907,7 @@ virDomainEventBlockJobNew(int event,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->disk, disk) < 0) {
- virObjectUnref(ev);
- return NULL;
- }
+ ev->disk = g_strdup(disk);
ev->type = type;
ev->status = status;
@@ -1024,22 +1009,13 @@ virDomainEventDiskChangeNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
- goto error;
-
- if (VIR_STRDUP(ev->oldSrcPath, oldSrcPath) < 0)
- goto error;
-
- if (VIR_STRDUP(ev->newSrcPath, newSrcPath) < 0)
- goto error;
+ ev->devAlias = g_strdup(devAlias);
+ ev->oldSrcPath = g_strdup(oldSrcPath);
+ ev->newSrcPath = g_strdup(newSrcPath);
ev->reason = reason;
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1083,16 +1059,11 @@ virDomainEventTrayChangeNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
- goto error;
+ ev->devAlias = g_strdup(devAlias);
ev->reason = reason;
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1275,14 +1246,9 @@ virDomainEventDeviceRemovedNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
- goto error;
+ ev->devAlias = g_strdup(devAlias);
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1317,14 +1283,9 @@ virDomainEventDeviceAddedNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
- goto error;
+ ev->devAlias = g_strdup(devAlias);
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1360,14 +1321,9 @@ virDomainEventDeviceRemovalFailedNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->devAlias, devAlias) < 0)
- goto error;
+ ev->devAlias = g_strdup(devAlias);
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1587,14 +1543,10 @@ virDomainEventMetadataChangeNew(int id,
return NULL;
ev->type = type;
- if (nsuri && VIR_STRDUP(ev->nsuri, nsuri) < 0)
- goto error;
+ if (nsuri)
+ ev->nsuri = g_strdup(nsuri);
return (virObjectEventPtr)ev;
-
- error:
- virObjectUnref(ev);
- return NULL;
}
virObjectEventPtr
@@ -1635,11 +1587,8 @@ virDomainEventBlockThresholdNew(int id,
id, name, uuid)))
return NULL;
- if (VIR_STRDUP(ev->dev, dev) < 0 ||
- VIR_STRDUP(ev->path, path) < 0) {
- virObjectUnref(ev);
- return NULL;
- }
+ ev->dev = g_strdup(dev);
+ ev->path = g_strdup(path);
ev->threshold = threshold;
ev->excess = excess;
@@ -1986,12 +1935,13 @@ virDomainQemuMonitorEventNew(int id,
return NULL;
/* event is mandatory, details are optional */
- if (VIR_STRDUP(ev->event, event) <= 0)
+ if (!event)
goto error;
+
+ ev->event = g_strdup(event);
ev->seconds = seconds;
ev->micros = micros;
- if (VIR_STRDUP(ev->details, details) < 0)
- goto error;
+ ev->details = g_strdup(details);
return (virObjectEventPtr)ev;
@@ -2318,9 +2268,8 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPtr conn,
VIR_FREE(data);
return -1;
}
- } else if (VIR_STRDUP(data->event, event) < 0) {
- VIR_FREE(data);
- return -1;
+ } else {
+ data->event = g_strdup(event);
}
}
data->opaque = opaque;
diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c
index 495fafcd61..a72db6f876 100644
--- a/src/conf/domain_nwfilter.c
+++ b/src/conf/domain_nwfilter.c
@@ -47,22 +47,18 @@ virNWFilterBindingDefForNet(const char *vmname,
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (VIR_STRDUP(ret->ownername, vmname) < 0)
- goto error;
+ ret->ownername = g_strdup(vmname);
memcpy(ret->owneruuid, vmuuid, sizeof(ret->owneruuid));
- if (VIR_STRDUP(ret->portdevname, net->ifname) < 0)
- goto error;
+ ret->portdevname = g_strdup(net->ifname);
- if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT &&
- VIR_STRDUP(ret->linkdevname, net->data.direct.linkdev) < 0)
- goto error;
+ if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT)
+ ret->linkdevname = g_strdup(net->data.direct.linkdev);
ret->mac = net->mac;
- if (VIR_STRDUP(ret->filter, net->filter) < 0)
- goto error;
+ ret->filter = g_strdup(net->filter);
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
goto error;
diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c
index 6de4ab1f58..de807e2a54 100644
--- a/src/conf/networkcommon_conf.c
+++ b/src/conf/networkcommon_conf.c
@@ -47,8 +47,7 @@ virNetDevIPRouteCreate(const char *errorDetail,
if (VIR_ALLOC(def) < 0)
return NULL;
- if (VIR_STRDUP(def->family, family) < 0)
- goto error;
+ def->family = g_strdup(family);
def->prefix = prefix;
def->has_prefix = hasPrefix;
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 5b4bb34a5a..7eb52dbf85 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1944,8 +1944,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
goto error;
}
} else {
- if (VIR_STRDUP(def->name, "new device") < 0)
- goto error;
+ def->name = g_strdup("new device");
}
def->sysfs_path = virXPathString("string(./path[1])", ctxt);
@@ -2122,12 +2121,8 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
while (cap != NULL) {
if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
- 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;
- }
+ *wwnn = g_strdup(cap->data.scsi_host.wwnn);
+ *wwpn = g_strdup(cap->data.scsi_host.wwpn);
break;
}
@@ -2459,8 +2454,7 @@ virNodeDeviceGetSCSITargetCaps(const char *sysfsPath,
if (!(dir = mdir_name(sysfsPath)))
return -1;
- if (VIR_STRDUP(rport, last_component(dir)) < 0)
- goto cleanup;
+ rport = g_strdup(last_component(dir));
if (!virFCIsCapableRport(rport))
goto cleanup;
diff --git a/src/conf/node_device_util.c b/src/conf/node_device_util.c
index 3b1e8e487f..2728b8a510 100644
--- a/src/conf/node_device_util.c
+++ b/src/conf/node_device_util.c
@@ -85,8 +85,7 @@ virNodeDeviceCreateVport(virStorageAdapterFCHostPtr fchost)
NULLSTR(fchost->parent), fchost->wwnn, fchost->wwpn);
if (fchost->parent) {
- if (VIR_STRDUP(parent_hoststr, fchost->parent) < 0)
- goto cleanup;
+ parent_hoststr = g_strdup(fchost->parent);
} else if (fchost->parent_wwnn && fchost->parent_wwpn) {
if (!(parent_hoststr = virVHBAGetHostByWWN(NULL, fchost->parent_wwnn,
fchost->parent_wwpn))) {
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 0f025637ee..cd97eb87ac 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -2674,9 +2674,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt)
}
chain = NULL;
} else {
- if (VIR_STRDUP(ret->chainsuffix,
- virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT))
< 0)
- goto cleanup;
+ ret->chainsuffix =
g_strdup(virNWFilterChainSuffixTypeToString(VIR_NWFILTER_CHAINSUFFIX_ROOT));
}
uuid = virXPathString("string(./uuid)", ctxt);
diff --git a/src/conf/nwfilter_ipaddrmap.c b/src/conf/nwfilter_ipaddrmap.c
index eb1ed76af8..672a58be3a 100644
--- a/src/conf/nwfilter_ipaddrmap.c
+++ b/src/conf/nwfilter_ipaddrmap.c
@@ -53,8 +53,7 @@ virNWFilterIPAddrMapAddIPAddr(const char *ifname, char *addr)
char *addrCopy;
virNWFilterVarValuePtr val;
- if (VIR_STRDUP(addrCopy, addr) < 0)
- return -1;
+ addrCopy = g_strdup(addr);
virMutexLock(&ipAddressMapLock);
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 7640717948..7608d4960e 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -76,16 +76,14 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val)
switch (res->valType) {
case NWFILTER_VALUE_TYPE_SIMPLE:
- if (VIR_STRDUP(res->u.simple.value, val->u.simple.value) < 0)
- goto err_exit;
+ res->u.simple.value = g_strdup(val->u.simple.value);
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++) {
- if (VIR_STRDUP(str, val->u.array.values[i]) < 0)
- goto err_exit;
+ str = g_strdup(val->u.array.values[i]);
res->u.array.values[i] = str;
}
break;
@@ -126,8 +124,7 @@ virNWFilterVarValueCreateSimpleCopyValue(const char *value)
char *val;
virNWFilterVarValuePtr ret;
- if (VIR_STRDUP(val, value) < 0)
- return NULL;
+ val = g_strdup(value);
ret = virNWFilterVarValueCreateSimple(val);
if (!ret)
VIR_FREE(val);
@@ -255,8 +252,7 @@ int
virNWFilterVarValueAddValueCopy(virNWFilterVarValuePtr val, const char *value)
{
char *valdup;
- if (VIR_STRDUP(valdup, value) < 0)
- return -1;
+ valdup = g_strdup(value);
if (virNWFilterVarValueAddValue(val, valdup) < 0) {
VIR_FREE(valdup);
return -1;
diff --git a/src/conf/object_event.c b/src/conf/object_event.c
index 453fab74b1..408e0fd2b2 100644
--- a/src/conf/object_event.c
+++ b/src/conf/object_event.c
@@ -437,8 +437,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn,
if (key) {
cb->key_filter = true;
- if (VIR_STRDUP(cb->key, key) < 0)
- goto cleanup;
+ cb->key = g_strdup(key);
}
cb->filter = filter;
cb->filter_opaque = filter_opaque;
@@ -623,11 +622,8 @@ virObjectEventNew(virClassPtr klass,
event->eventID = eventID;
event->remoteID = -1;
- if (VIR_STRDUP(event->meta.name, name) < 0 ||
- VIR_STRDUP(event->meta.key, key) < 0) {
- virObjectUnref(event);
- return NULL;
- }
+ event->meta.name = g_strdup(name);
+ event->meta.key = g_strdup(key);
event->meta.id = id;
if (uuid)
memcpy(event->meta.uuid, uuid, VIR_UUID_BUFLEN);
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 0e9d307321..f9fbca3c07 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -612,8 +612,7 @@ virDomainSnapshotDefAssignExternalNames(virDomainSnapshotDefPtr def)
return -1;
}
- if (VIR_STRDUP(tmppath, origpath) < 0)
- return -1;
+ tmppath = g_strdup(origpath);
/* drop suffix of the file name */
if ((tmp = strrchr(tmppath, '.')) && !strchr(tmp, '/'))
@@ -741,8 +740,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
}
if (STRNEQ(disk->name, def->parent.dom->disks[idx]->dst)) {
VIR_FREE(disk->name);
- if (VIR_STRDUP(disk->name, def->parent.dom->disks[idx]->dst) <
0)
- goto cleanup;
+ disk->name = g_strdup(def->parent.dom->disks[idx]->dst);
}
}
@@ -760,8 +758,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
disk = &def->disks[ndisks++];
if (!(disk->src = virStorageSourceNew()))
goto cleanup;
- if (VIR_STRDUP(disk->name, def->parent.dom->disks[i]->dst) < 0)
- goto cleanup;
+ disk->name = g_strdup(def->parent.dom->disks[i]->dst);
disk->idx = i;
/* Don't snapshot empty drives */
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index ba3e3ec326..f212eefe25 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -640,9 +640,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
if (sourcedir)
source->dir = virFileSanitizePath(sourcedir);
/* In gluster, a missing dir defaults to "/" */
- if (!source->dir && pool_type == VIR_STORAGE_POOL_GLUSTER &&
- VIR_STRDUP(source->dir, "/") < 0)
- goto cleanup;
+ if (!source->dir && pool_type == VIR_STORAGE_POOL_GLUSTER)
+ source->dir = g_strdup("/");
if ((adapternode = virXPathNode("./adapter", ctxt))) {
if (virStorageAdapterParseXML(&source->adapter, adapternode, ctxt) <
0)
@@ -885,9 +884,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
def->name = virXPathString("string(./name)", ctxt);
if (def->name == NULL &&
- options->flags & VIR_STORAGE_POOL_SOURCE_NAME &&
- VIR_STRDUP(def->name, def->source.name) < 0)
- return NULL;
+ options->flags & VIR_STORAGE_POOL_SOURCE_NAME)
+ def->name = g_strdup(def->source.name);
if (def->name == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -934,8 +932,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
if (options->flags & VIR_STORAGE_POOL_SOURCE_NAME) {
if (def->source.name == NULL) {
/* source name defaults to pool name */
- if (VIR_STRDUP(def->source.name, def->name) < 0)
- return NULL;
+ def->source.name = g_strdup(def->name);
}
}
diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
index 59d4864735..1d02a4ad66 100644
--- a/src/conf/virchrdev.c
+++ b/src/conf/virchrdev.c
@@ -73,8 +73,7 @@ static char *virChrdevLockFilePath(const char *dev)
char *filename;
char *p;
- if (VIR_STRDUP(devCopy, dev) < 0)
- goto cleanup;
+ devCopy = g_strdup(dev);
/* skip the leading "/dev/" */
filename = STRSKIP(devCopy, "/dev");
@@ -407,8 +406,7 @@ int virChrdevOpen(virChrdevsPtr devs,
added = true;
cbdata->devs = devs;
- if (VIR_STRDUP(cbdata->path, path) < 0)
- goto error;
+ cbdata->path = g_strdup(path);
/* open the character device */
switch (source->type) {
diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c
index a4f9ce9c3f..ef702eb6aa 100644
--- a/src/conf/virdomainmomentobjlist.c
+++ b/src/conf/virdomainmomentobjlist.c
@@ -328,11 +328,8 @@ static int virDomainMomentObjListCopyNames(void *payload,
if (!data->filter(obj, data->filter_flags))
return 0;
- if (data->names && data->count < data->maxnames &&
- VIR_STRDUP(data->names[data->count], obj->def->name) < 0) {
- data->error = true;
- return 0;
- }
+ if (data->names && data->count < data->maxnames)
+ data->names[data->count] = g_strdup(obj->def->name);
data->count++;
return 0;
}
diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c
index fa1985f474..744dd87296 100644
--- a/src/conf/virdomainobjlist.c
+++ b/src/conf/virdomainobjlist.c
@@ -440,8 +440,7 @@ virDomainObjListRename(virDomainObjListPtr doms,
return ret;
}
- if (VIR_STRDUP(old_name, dom->def->name) < 0)
- return ret;
+ old_name = g_strdup(dom->def->name);
/* doms and dom locks must be attained in right order thus relock dom. */
/* dom reference is touched for the benefit of those callers that
@@ -761,11 +760,10 @@ virDomainObjListCopyInactiveNames(void *payload,
!data->filter(data->conn, obj->def))
goto cleanup;
if (!virDomainObjIsActive(obj) && data->numnames < data->maxnames)
{
- if (VIR_STRDUP(data->names[data->numnames], obj->def->name) < 0)
- data->oom = 1;
- else
- data->numnames++;
+ data->names[data->numnames] = g_strdup(obj->def->name);
+ data->numnames++;
}
+
cleanup:
virObjectUnlock(obj);
return 0;
diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index b77d4152f5..43ba395d2b 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -176,14 +176,10 @@ virInterfaceObjListFindByMACStringCb(void *payload,
virObjectLock(obj);
if (STRCASEEQ(obj->def->mac, data->matchStr)) {
- if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) {
- data->error = true;
- goto cleanup;
- }
+ data->names[data->nnames] = g_strdup(obj->def->name);
data->nnames++;
}
- cleanup:
virObjectUnlock(obj);
return 0;
}
@@ -544,10 +540,7 @@ virInterfaceObjListGetNamesCb(void *payload,
if (data->wantActive != virInterfaceObjIsActive(obj))
goto cleanup;
- if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) {
- data->error = true;
- goto cleanup;
- }
+ data->names[data->nnames] = g_strdup(obj->def->name);
data->nnames++;
diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 435f3611e9..e7017bffa9 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1522,11 +1522,8 @@ virNetworkObjListGetHelper(void *payload,
if ((data->active && virNetworkObjIsActive(obj)) ||
(!data->active && !virNetworkObjIsActive(obj))) {
- if (data->names &&
- VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) {
- data->error = true;
- goto cleanup;
- }
+ if (data->names)
+ data->names[data->nnames] = g_strdup(obj->def->name);
data->nnames++;
}
diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
index 7656a5eed2..3a34a324ca 100644
--- a/src/conf/virnodedeviceobj.c
+++ b/src/conf/virnodedeviceobj.c
@@ -761,14 +761,10 @@ virNodeDeviceObjListGetNamesCallback(void *payload,
if ((!filter || filter(data->conn, def)) &&
(!data->matchstr || virNodeDeviceObjHasCapStr(obj, data->matchstr))) {
- if (VIR_STRDUP(data->names[data->nnames], def->name) < 0) {
- data->error = true;
- goto cleanup;
- }
+ data->names[data->nnames] = g_strdup(def->name);
data->nnames++;
}
- cleanup:
virObjectUnlock(obj);
return 0;
}
@@ -869,12 +865,12 @@ virNodeDeviceObjListExportCallback(void *payload,
if ((!data->filter || data->filter(data->conn, def)) &&
virNodeDeviceObjMatch(obj, data->flags)) {
if (data->devices) {
- if (!(device = virGetNodeDevice(data->conn, def->name)) ||
- VIR_STRDUP(device->parentName, def->parent) < 0) {
+ if (!(device = virGetNodeDevice(data->conn, def->name))) {
virObjectUnref(device);
data->error = true;
goto cleanup;
}
+ device->parentName = g_strdup(def->parent);
data->devices[data->ndevices] = device;
}
data->ndevices++;
diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbindingdef.c
index 6f13bc581a..dbd0a9a04f 100644
--- a/src/conf/virnwfilterbindingdef.c
+++ b/src/conf/virnwfilterbindingdef.c
@@ -54,21 +54,17 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src)
if (VIR_ALLOC(ret) < 0)
return NULL;
- if (VIR_STRDUP(ret->ownername, src->ownername) < 0)
- goto error;
+ ret->ownername = g_strdup(src->ownername);
memcpy(ret->owneruuid, src->owneruuid, sizeof(ret->owneruuid));
- if (VIR_STRDUP(ret->portdevname, src->portdevname) < 0)
- goto error;
+ ret->portdevname = g_strdup(src->portdevname);
- if (VIR_STRDUP(ret->linkdevname, src->linkdevname) < 0)
- goto error;
+ ret->linkdevname = g_strdup(src->linkdevname);
ret->mac = src->mac;
- if (VIR_STRDUP(ret->filter, src->filter) < 0)
- goto error;
+ ret->filter = g_strdup(src->filter);
if (!(ret->filterparams = virNWFilterHashTableCreate(0)))
goto error;
diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c
index d2d957a1cc..c9e224061d 100644
--- a/src/conf/virnwfilterobj.c
+++ b/src/conf/virnwfilterobj.c
@@ -421,22 +421,13 @@ virNWFilterObjListGetNames(virNWFilterObjListPtr nwfilters,
virNWFilterObjLock(obj);
def = obj->def;
if (!filter || filter(conn, def)) {
- if (VIR_STRDUP(names[nnames], def->name) < 0) {
- virNWFilterObjUnlock(obj);
- goto failure;
- }
+ names[nnames] = g_strdup(def->name);
nnames++;
}
virNWFilterObjUnlock(obj);
}
return nnames;
-
- failure:
- while (--nnames >= 0)
- VIR_FREE(names[nnames]);
-
- return -1;
}
diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index e5ef9c8a68..a4fd330663 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -931,12 +931,8 @@ virStoragePoolObjVolumeGetNamesCb(void *payload,
!data->filter(data->conn, data->pooldef, volobj->voldef))
goto cleanup;
- if (data->names) {
- if (VIR_STRDUP(data->names[data->nnames], volobj->voldef->name) <
0) {
- data->error = true;
- goto cleanup;
- }
- }
+ if (data->names)
+ data->names[data->nnames] = g_strdup(volobj->voldef->name);
data->nnames++;
@@ -1642,17 +1638,9 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
def = NULL;
VIR_FREE(obj->configFile); /* for driver reload */
- if (VIR_STRDUP(obj->configFile, path) < 0) {
- virStoragePoolObjRemove(pools, obj);
- virStoragePoolObjEndAPI(&obj);
- return NULL;
- }
+ obj->configFile = g_strdup(path);
VIR_FREE(obj->autostartLink); /* for driver reload */
- if (VIR_STRDUP(obj->autostartLink, autostartLink) < 0) {
- virStoragePoolObjRemove(pools, obj);
- virStoragePoolObjEndAPI(&obj);
- return NULL;
- }
+ obj->autostartLink = g_strdup(autostartLink);
obj->autostart = virFileLinkPointsTo(obj->autostartLink,
obj->configFile);
@@ -1919,12 +1907,8 @@ virStoragePoolObjGetNamesCb(void *payload,
if (data->wantActive != virStoragePoolObjIsActive(obj))
goto cleanup;
- if (data->names) {
- if (VIR_STRDUP(data->names[data->nnames], obj->def->name) < 0) {
- data->error = true;
- goto cleanup;
- }
- }
+ if (data->names)
+ data->names[data->nnames] = g_strdup(obj->def->name);
data->nnames++;
--
2.21.0