On a Tuesday in 2020, Laine Stump wrote:
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/network/bridge_driver.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 713763130b..ab359acdb5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -177,8 +177,7 @@ networkDnsmasqDefNamespaceParseOptions(networkDnsmasqXmlNsDefPtr
nsdef,
if (nnodes == 0)
return 0;
- if (VIR_ALLOC_N(nsdef->options, nnodes) < 0)
- return -1;
+ nsdef->options = g_new0(char *, nnodes);
for (i = 0; i < nnodes; i++) {
if (!(nsdef->options[nsdef->noptions++] = virXMLPropString(nodes[i],
"value"))) {
@@ -196,12 +195,9 @@ static int
networkDnsmasqDefNamespaceParse(xmlXPathContextPtr ctxt,
void **data)
{
- networkDnsmasqXmlNsDefPtr nsdata = NULL;
+ networkDnsmasqXmlNsDefPtr nsdata = g_new0(networkDnsmasqXmlNsDef, 1);
int ret = -1;
- if (VIR_ALLOC(nsdata) < 0)
- return -1;
-
if (networkDnsmasqDefNamespaceParseOptions(nsdata, ctxt))
goto cleanup;
@@ -733,8 +729,7 @@ networkStateInitialize(bool privileged,
return -1;
}
- if (VIR_ALLOC(network_driver) < 0)
- goto error;
+ network_driver = g_new0(virNetworkDriverState, 1);
network_driver->lockFD = -1;
if (virMutexInit(&network_driver->lock) < 0) {
@@ -2753,8 +2748,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef)
goto cleanup;
}
- if (VIR_ALLOC_N(netdef->forward.ifs, numVirtFns) < 0)
- goto cleanup;
+ netdef->forward.ifs = g_new0(virNetworkForwardIfDef, numVirtFns);
for (i = 0; i < numVirtFns; i++) {
virPCIDeviceAddressPtr thisVirtFn = virtFns[i];
@@ -4323,8 +4317,7 @@ networkGetDHCPLeases(virNetworkPtr net,
continue;
if (need_results) {
- if (VIR_ALLOC(lease) < 0)
- goto error;
+ lease = g_new0(virNetworkDHCPLease, 1);
lease->expirytime = expirytime_tmp;
@@ -4378,9 +4371,8 @@ networkGetDHCPLeases(virNetworkPtr net,
if (leases_ret) {
/* NULL terminated array */
- ignore_value(VIR_REALLOC_N(leases_ret, nleases + 1));
- *leases = leases_ret;
- leases_ret = NULL;
+ leases_ret = g_renew(virNetworkDHCPLeasePtr, leases_ret, nleases + 1);
Double space before nleases.
Also, this is a faithful conversion, but neither VIR_REALLOC_N nor
g_renew guarantee that the memory will be zeroed.
+ *leases = g_steal_pointer(&leases_ret);
}
rv = nleases;
With the double space removed:
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano