nwfilter: replace VIR_ALLOC with g_new0

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Laine Stump 2020-06-24 16:55:23 -04:00
parent a082c3d1a1
commit 6f1af2fe25
5 changed files with 8 additions and 16 deletions

View File

@ -562,8 +562,7 @@ virNWFilterSnoopReqNew(const char *ifkey)
return NULL;
}
if (VIR_ALLOC(req) < 0)
return NULL;
req = g_new0(virNWFilterSnoopReq, 1);
req->threadStatus = THREAD_STATUS_NONE;
@ -737,8 +736,7 @@ virNWFilterSnoopReqLeaseAdd(virNWFilterSnoopReqPtr req,
virNWFilterSnoopReqUnlock(req);
if (VIR_ALLOC(pl) < 0)
return -1;
pl = g_new0(virNWFilterSnoopIPLease, 1);
*pl = *plnew;
/* protect req->threadkey */
@ -1160,8 +1158,7 @@ virNWFilterSnoopDHCPDecodeJobSubmit(virThreadPoolPtr pool,
if (len <= MIN_VALID_DHCP_PKT_SIZE || len > sizeof(job->packet))
return 0;
if (VIR_ALLOC(job) < 0)
return -1;
job = g_new0(virNWFilterDHCPDecodeJob, 1);
memcpy(job->packet, pep, len);
job->caplen = len;

View File

@ -193,8 +193,7 @@ nwfilterStateInitialize(bool privileged,
!(sysbus = virDBusGetSystemBus()))
return VIR_DRV_STATE_INIT_ERROR;
if (VIR_ALLOC(driver) < 0)
return VIR_DRV_STATE_INIT_ERROR;
driver = g_new0(virNWFilterDriverState, 1);
driver->lockFD = -1;
if (virMutexInit(&driver->lock) < 0)

View File

@ -3312,8 +3312,7 @@ ebtablesGetSubChainInsts(virHashTablePtr chains,
if ((int)idx < 0)
continue;
if (VIR_ALLOC(inst) < 0)
goto cleanup;
inst = g_new0(ebtablesSubChainInst, 1);
inst->priority = *(const virNWFilterChainPriority *)filter_names[i].value;
inst->incoming = incoming;
inst->protoidx = idx;

View File

@ -262,8 +262,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def,
virNWFilterRuleInstPtr ruleinst;
int ret = -1;
if (VIR_ALLOC(ruleinst) < 0)
goto cleanup;
ruleinst = g_new0(virNWFilterRuleInst, 1);
ruleinst->chainSuffix = def->chainsuffix;
ruleinst->chainPriority = def->chainPriority;

View File

@ -151,8 +151,7 @@ virNWFilterLockIface(const char *ifname)
ifaceLock = virHashLookup(ifaceLockMap, ifname);
if (!ifaceLock) {
if (VIR_ALLOC(ifaceLock) < 0)
goto error;
ifaceLock = g_new0(virNWFilterIfaceLock, 1);
if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -718,8 +717,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
return -1;
}
if (VIR_ALLOC(req) < 0)
return -1;
req = g_new0(virNWFilterIPAddrLearnReq, 1);
if (!(req->binding = virNWFilterBindingDefCopy(binding)))
goto err_free_req;