提交 45248028 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

util: lease: use VIR_AUTOFREE instead of VIR_FREE for scalar types

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: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 c493af56
......@@ -55,7 +55,7 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
const char *ip_to_delete,
char **server_duid)
{
char *lease_entries = NULL;
VIR_AUTOFREE(char *) lease_entries = NULL;
virJSONValuePtr leases_array = NULL;
long long expirytime;
int custom_lease_file_len = 0;
......@@ -146,7 +146,6 @@ virLeaseReadCustomLeaseFile(virJSONValuePtr leases_array_new,
cleanup:
virJSONValueFree(leases_array);
VIR_FREE(lease_entries);
return ret;
}
......@@ -235,7 +234,7 @@ virLeaseNew(virJSONValuePtr *lease_ret,
virJSONValuePtr lease_new = NULL;
const char *exptime_tmp = virGetEnvAllowSUID("DNSMASQ_LEASE_EXPIRES");
long long expirytime = 0;
char *exptime = NULL;
VIR_AUTOFREE(char *) exptime = NULL;
int ret = -1;
/* In case hostname is still unknown, use the last known one */
......@@ -291,7 +290,6 @@ virLeaseNew(virJSONValuePtr *lease_ret,
*lease_ret = lease_new;
lease_new = NULL;
cleanup:
VIR_FREE(exptime);
virJSONValueFree(lease_new);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册