---
src/network/bridge_driver.c | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index e828997..fb01ebf 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -378,8 +378,8 @@ networkStateInitialize(bool privileged,
"%s/log/libvirt/qemu", LOCALSTATEDIR) == -1)
goto out_of_memory;
- if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
- goto out_of_memory;
+ if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
+ goto error;
} else {
char *userdir = virGetUserCacheDirectory();
@@ -2824,9 +2824,8 @@ static int networkConnectListNetworks(virConnectPtr conn, char
**const names, in
for (i = 0 ; i < driver->networks.count && got < nnames ; i++) {
virNetworkObjLock(driver->networks.objs[i]);
if (virNetworkObjIsActive(driver->networks.objs[i])) {
- if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
+ if (VIR_STRDUP(names[got], driver->networks.objs[i]->def->name) <
0) {
virNetworkObjUnlock(driver->networks.objs[i]);
- virReportOOMError();
goto cleanup;
}
got++;
@@ -2868,9 +2867,8 @@ static int networkConnectListDefinedNetworks(virConnectPtr conn,
char **const na
for (i = 0 ; i < driver->networks.count && got < nnames ; i++) {
virNetworkObjLock(driver->networks.objs[i]);
if (!virNetworkObjIsActive(driver->networks.objs[i])) {
- if (!(names[got] = strdup(driver->networks.objs[i]->def->name))) {
+ if (VIR_STRDUP(names[got], driver->networks.objs[i]->def->name) <
0) {
virNetworkObjUnlock(driver->networks.objs[i]);
- virReportOOMError();
goto cleanup;
}
got++;
@@ -3499,9 +3497,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
goto cleanup;
}
- bridge = strdup(network->def->bridge);
- if (!bridge)
- virReportOOMError();
+ ignore_value(VIR_STRDUP(bridge, network->def->bridge));
cleanup:
if (network)
@@ -3689,13 +3685,9 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
(netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
netdef->forward.ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
if (vfname[ii]) {
- netdef->forward.ifs[ii].device.dev = strdup(vfname[ii]);
- if (!netdef->forward.ifs[ii].device.dev) {
- virReportOOMError();
+ if (VIR_STRDUP(netdef->forward.ifs[ii].device.dev, vfname[ii]) <
0)
goto finish;
- }
- }
- else {
+ } else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Direct mode types require interface
names"));
goto finish;
@@ -3838,11 +3830,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
}
iface->data.network.actual->type = actualType =
VIR_DOMAIN_NET_TYPE_BRIDGE;
- iface->data.network.actual->data.bridge.brname =
strdup(netdef->bridge);
- if (!iface->data.network.actual->data.bridge.brname) {
- virReportOOMError();
+ if (VIR_STRDUP(iface->data.network.actual->data.bridge.brname,
+ netdef->bridge) < 0)
goto error;
- }
/* merge virtualports from interface, network, and portgroup to
* arrive at actual virtualport to use
@@ -4059,11 +4049,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
netdef->name);
goto error;
}
- iface->data.network.actual->data.direct.linkdev =
strdup(dev->device.dev);
- if (!iface->data.network.actual->data.direct.linkdev) {
- virReportOOMError();
+ if (VIR_STRDUP(iface->data.network.actual->data.direct.linkdev,
+ dev->device.dev) < 0)
goto error;
- }
}
}
--
1.8.1.5