On Sat, Jul 21, 2018 at 05:36:47PM +0530, Sukrit Bhatnagar wrote:
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr(a)gmail.com>
---
src/util/virfirewall.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index dfd792f..b4a4d06 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -511,7 +511,7 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
virFirewallRulePtr rule,
const char *fmt, ...)
{
- char *arg;
+ VIR_AUTOFREE(char *) arg = NULL;
va_list list;
VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule);
@@ -525,13 +525,11 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
va_end(list);
- VIR_FREE(arg);
return;
no_memory:
firewall->err = ENOMEM;
va_end(list);
- VIR_FREE(arg);
There could be an additional patch replacing the no_memory label with 'cleanup'
with the obvious adjustments.
With an additional patch in place:
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>