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

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: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 8214abd6
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册