[PATCH v2 4/5] util: Adapt ADD_ARG() macro

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

 



As VIR_RESIZE_N() macro already aborts in case of OOM, there's no reason
to check for its output in the ADD_ARG() macro.

By doing this, we can simply get rid of a all no_memory labels spread in
the virfirewall.c file.

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

diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 564e2fe0be..7c8040880c 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -320,11 +320,9 @@ void virFirewallFree(virFirewallPtr firewall)
 
 #define ADD_ARG(rule, str) \
     do { \
-        if (VIR_RESIZE_N(rule->args, \
-                         rule->argsAlloc, \
-                         rule->argsLen, 1) < 0) \
-            goto no_memory; \
- \
+        ignore_value(VIR_RESIZE_N(rule->args, \
+                                  rule->argsAlloc, \
+                                  rule->argsLen, 1)); \
         rule->args[rule->argsLen++] = g_strdup(str); \
     } while (0)
 
@@ -391,9 +389,6 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
 
 
     return g_steal_pointer(&rule);
-
- no_memory:
-    return NULL;
 }
 
 
@@ -491,9 +486,6 @@ void virFirewallRuleAddArg(virFirewallPtr firewall,
     VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule);
 
     ADD_ARG(rule, arg);
-
- no_memory:
-    return;
 }
 
 
@@ -511,9 +503,6 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
     va_end(list);
 
     ADD_ARG(rule, arg);
-
- no_memory:
-    return;
 }
 
 
@@ -527,9 +516,6 @@ void virFirewallRuleAddArgSet(virFirewallPtr firewall,
         ADD_ARG(rule, *args);
         args++;
     }
-
- no_memory:
-    return;
 }
 
 
@@ -547,7 +533,6 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall,
     while ((str = va_arg(list, char *)) != NULL)
         ADD_ARG(rule, str);
 
- no_memory:
     va_end(list);
 }
 
-- 
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