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@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
int *retry)
{
int rc = -1;
- struct nlmsghdr *resp = NULL;
struct nlmsgerr *err;
struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
int ifindex;
struct nl_msg *nl_msg;
struct nlattr *linkinfo, *info_data;
char macstr[VIR_MAC_STRING_BUFLEN];
+ VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
if (virNetDevGetIndex(srcdev, &ifindex) < 0)
return -1;
rc = 0;
cleanup:
nlmsg_free(nl_msg);
- VIR_FREE(resp);
return rc;
malformed_resp:
{
int ret = -1;
int ifindex;
- char *tapname = NULL;
size_t i = 0;
+ VIR_AUTOFREE(char *) tapname = NULL;
if (virNetDevGetIndex(ifname, &ifindex) < 0)
return -1;
while (i--)
VIR_FORCE_CLOSE(tapfd[i]);
}
- VIR_FREE(tapname);
return ret;
}