util: netdevmacvlan: 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: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Sukrit Bhatnagar 2018-07-28 23:31:30 +05:30 committed by Erik Skultety
parent 8214abd60e
commit b7ef069ec7

View File

@ -308,7 +308,6 @@ virNetDevMacVLanCreate(const char *ifname,
int *retry)
{
int rc = -1;
struct nlmsghdr *resp = NULL;
struct nlmsgerr *err;
struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
int ifindex;
@ -316,6 +315,7 @@ virNetDevMacVLanCreate(const char *ifname,
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;
@ -403,7 +403,6 @@ virNetDevMacVLanCreate(const char *ifname,
rc = 0;
cleanup:
nlmsg_free(nl_msg);
VIR_FREE(resp);
return rc;
malformed_resp:
@ -452,8 +451,8 @@ virNetDevMacVLanTapOpen(const char *ifname,
{
int ret = -1;
int ifindex;
char *tapname = NULL;
size_t i = 0;
VIR_AUTOFREE(char *) tapname = NULL;
if (virNetDevGetIndex(ifname, &ifindex) < 0)
return -1;
@ -487,7 +486,6 @@ virNetDevMacVLanTapOpen(const char *ifname,
while (i--)
VIR_FORCE_CLOSE(tapfd[i]);
}
VIR_FREE(tapname);
return ret;
}