]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nwfilter: replace VIR_ALLOC with g_new0
authorLaine Stump <laine@redhat.com>
Wed, 24 Jun 2020 20:55:23 +0000 (16:55 -0400)
committerLaine Stump <laine@redhat.com>
Mon, 20 Jul 2020 23:13:22 +0000 (19:13 -0400)
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_driver.c
src/nwfilter/nwfilter_ebiptables_driver.c
src/nwfilter/nwfilter_gentech_driver.c
src/nwfilter/nwfilter_learnipaddr.c

index 6de41ff2090f007908dcd0b312b1766ae0a0ac44..4bc1607694a7fc22a81f54c2b8e1dafef9c3abfa 100644 (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;
index 1c407727dbb1ed4fbeae8b3e41466e3d0a123fab..39d0a2128e49c607e7e02579bb431da52cc7ef41 100644 (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)
index 8ac3a7271e2c5728840c947a028fae829946259a..177e7e62b904f1779796404d794da8014d43969f 100644 (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;
index 400d0647248c47f227aee4c0beb2d081984ff86e..acd5614987f7c36e93d9c7aaa8c079d9cc927ae0 100644 (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;
index 95e21050b419f3ed4c8ab1ef0232b06fd756f650..63fac37132b2cb8b24761c1244c92645ffac52a4 100644 (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;