[libvirt PATCH 06/10] virNWFilterBindingDefForNet: Use automatic memory management

Tim Wiederhake twiederh at redhat.com
Tue Jul 13 14:44:37 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/domain_nwfilter.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c
index 5024d5fa03..cb35221a59 100644
--- a/src/conf/domain_nwfilter.c
+++ b/src/conf/domain_nwfilter.c
@@ -42,9 +42,7 @@ virNWFilterBindingDefForNet(const char *vmname,
                             const unsigned char *vmuuid,
                             virDomainNetDef *net)
 {
-    virNWFilterBindingDef *ret;
-
-    ret = g_new0(virNWFilterBindingDef, 1);
+    g_autoptr(virNWFilterBindingDef) ret = g_new0(virNWFilterBindingDef, 1);
 
     ret->ownername = g_strdup(vmname);
 
@@ -65,10 +63,9 @@ virNWFilterBindingDefForNet(const char *vmname,
         virNWFilterHashTablePutAll(net->filterparams, ret->filterparams) < 0)
         goto error;
 
-    return ret;
+    return g_steal_pointer(&ret);
 
  error:
-    virNWFilterBindingDefFree(ret);
     return NULL;
 }
 
-- 
2.31.1




More information about the libvir-list mailing list