Re: [libvirt PATCH v2 13/15] nwfilter: replace VIR_ALLOC with g_new0

2020-07-15 Thread Ján Tomko

On a Tuesday in 2020, Laine Stump wrote:

Signed-off-by: Laine Stump 
---
src/nwfilter/nwfilter_dhcpsnoop.c | 9 +++--
src/nwfilter/nwfilter_driver.c| 3 +--
src/nwfilter/nwfilter_ebiptables_driver.c | 3 +--
src/nwfilter/nwfilter_gentech_driver.c| 3 +--
src/nwfilter/nwfilter_learnipaddr.c   | 6 ++
5 files changed, 8 insertions(+), 16 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


[libvirt PATCH v2 13/15] nwfilter: replace VIR_ALLOC with g_new0

2020-07-07 Thread Laine Stump
Signed-off-by: Laine Stump 
---
 src/nwfilter/nwfilter_dhcpsnoop.c | 9 +++--
 src/nwfilter/nwfilter_driver.c| 3 +--
 src/nwfilter/nwfilter_ebiptables_driver.c | 3 +--
 src/nwfilter/nwfilter_gentech_driver.c| 3 +--
 src/nwfilter/nwfilter_learnipaddr.c   | 6 ++
 5 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c 
b/src/nwfilter/nwfilter_dhcpsnoop.c
index 6de41ff209..4bc1607694 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -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;
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 1c407727db..39d0a2128e 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -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(>lock) < 0)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c 
b/src/nwfilter/nwfilter_ebiptables_driver.c
index 8ac3a7271e..177e7e62b9 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -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;
diff --git a/src/nwfilter/nwfilter_gentech_driver.c 
b/src/nwfilter/nwfilter_gentech_driver.c
index 400d064724..acd5614987 100644
--- a/src/nwfilter/nwfilter_gentech_driver.c
+++ b/src/nwfilter/nwfilter_gentech_driver.c
@@ -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;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c 
b/src/nwfilter/nwfilter_learnipaddr.c
index 95e21050b4..63fac37132 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -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(>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;
-- 
2.25.4