[libvirt PATCH 02/10] virNWFilterCreateVarsFrom: Use automatic memory management

Tim Wiederhake twiederh at redhat.com
Fri Jul 9 08:27:31 UTC 2021


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

diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewalltest.c
index 3b7190b5cd..26d4a936ad 100644
--- a/tests/nwfilterxml2firewalltest.c
+++ b/tests/nwfilterxml2firewalltest.c
@@ -148,7 +148,7 @@ static GHashTable *
 virNWFilterCreateVarsFrom(GHashTable *vars1,
                           GHashTable *vars2)
 {
-    GHashTable *res = virHashNew(virNWFilterVarValueHashFree);
+    g_autoptr(GHashTable) res = virHashNew(virNWFilterVarValueHashFree);
 
     if (virNWFilterHashTablePutAll(vars1, res) < 0)
         goto err_exit;
@@ -156,10 +156,9 @@ virNWFilterCreateVarsFrom(GHashTable *vars1,
     if (virNWFilterHashTablePutAll(vars2, res) < 0)
         goto err_exit;
 
-    return res;
+    return g_steal_pointer(&res);
 
  err_exit:
-    virHashFree(res);
     return NULL;
 }
 
-- 
2.31.1




More information about the libvir-list mailing list