[PATCH 3/7] util: Use g_auto/g_autofree in virFirewallAddRuleFullV()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
---
 src/util/virfirewall.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 00b1bd0a97..d6fff31318 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -257,6 +257,7 @@ virFirewallRuleFree(virFirewallRulePtr rule)
     VIR_FREE(rule);
 }
 
+G_DEFINE_AUTO_CLEANUP_FREE_FUNC(virFirewallRulePtr, virFirewallRuleFree, NULL);
 
 static void
 virFirewallGroupFree(virFirewallGroupPtr group)
@@ -335,8 +336,8 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
                         va_list args)
 {
     virFirewallGroupPtr group;
-    virFirewallRulePtr rule;
-    char *str;
+    g_auto(virFirewallRulePtr) rule = NULL;
+    g_autofree char *str = NULL;
 
     VIR_FIREWALL_RETURN_NULL_IF_ERROR(firewall);
 
@@ -348,7 +349,7 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
 
 
     if (VIR_ALLOC(rule) < 0)
-        goto cleanup;
+        return NULL;
 
     rule->layer = layer;
     rule->queryCB = cb;
@@ -379,19 +380,18 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
         if (VIR_APPEND_ELEMENT_COPY(group->rollback,
                                     group->nrollback,
                                     rule) < 0)
-            goto cleanup;
+            return NULL;
     } else {
         if (VIR_APPEND_ELEMENT_COPY(group->action,
                                     group->naction,
                                     rule) < 0)
-            goto cleanup;
+            return NULL;
     }
 
 
-    return rule;
+    return g_steal_pointer(&rule);
 
  cleanup:
-    virFirewallRuleFree(rule);
     return NULL;
 }
 
-- 
2.24.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux