Modify code to use VIR_AUTOFREE macro wherever required.
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr(a)gmail.com>
---
src/util/virfirewall.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c
index 10c370a..568612c 100644
--- a/src/util/virfirewall.c
+++ b/src/util/virfirewall.c
@@ -512,7 +512,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);
@@ -526,13 +526,11 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
va_end(list);
- VIR_FREE(arg);
return;
no_memory:
firewall->err = ENOMEM;
va_end(list);
- VIR_FREE(arg);
}
@@ -679,7 +677,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule,
virCommandPtr cmd = NULL;
int status;
int ret = -1;
- char *error = NULL;
+ VIR_AUTOFREE(char *) error = NULL;
if (!bin) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -715,7 +713,6 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule,
ret = 0;
cleanup:
- VIR_FREE(error);
virCommandFree(cmd);
return ret;
}
@@ -808,12 +805,11 @@ virFirewallApplyRule(virFirewallPtr firewall,
virFirewallRulePtr rule,
bool ignoreErrors)
{
- char *output = NULL;
+ VIR_AUTOFREE(char *) output = NULL;
char **lines = NULL;
int ret = -1;
- char *str = virFirewallRuleToString(rule);
+ VIR_AUTOFREE(char *) str = virFirewallRuleToString(rule);
VIR_INFO("Applying rule '%s'", NULLSTR(str));
- VIR_FREE(str);
if (rule->ignoreErrors)
ignoreErrors = rule->ignoreErrors;
@@ -858,7 +854,6 @@ virFirewallApplyRule(virFirewallPtr firewall,
ret = 0;
cleanup:
virStringListFree(lines);
- VIR_FREE(output);
return ret;
}
--
1.8.3.1