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

util: netdevopenvswitch: 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>
上级 bad48ac0
......@@ -149,10 +149,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
char macaddrstr[VIR_MAC_STRING_BUFLEN];
char ifuuidstr[VIR_UUID_STRING_BUFLEN];
char vmuuidstr[VIR_UUID_STRING_BUFLEN];
char *attachedmac_ex_id = NULL;
char *ifaceid_ex_id = NULL;
char *profile_ex_id = NULL;
char *vmid_ex_id = NULL;
VIR_AUTOFREE(char *) attachedmac_ex_id = NULL;
VIR_AUTOFREE(char *) ifaceid_ex_id = NULL;
VIR_AUTOFREE(char *) profile_ex_id = NULL;
VIR_AUTOFREE(char *) vmid_ex_id = NULL;
virMacAddrFormat(macaddr, macaddrstr);
virUUIDFormat(ovsport->interfaceID, ifuuidstr);
......@@ -209,10 +209,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
ret = 0;
cleanup:
VIR_FREE(attachedmac_ex_id);
VIR_FREE(ifaceid_ex_id);
VIR_FREE(vmid_ex_id);
VIR_FREE(profile_ex_id);
virCommandFree(cmd);
return ret;
}
......@@ -339,10 +335,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
virDomainInterfaceStatsPtr stats)
{
virCommandPtr cmd = NULL;
char *output;
char *tmp;
bool gotStats = false;
int ret = -1;
VIR_AUTOFREE(char *) output = NULL;
/* Just ensure the interface exists in ovs */
cmd = virCommandNew(OVSVSCTL);
......@@ -399,7 +395,6 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
ret = 0;
cleanup:
VIR_FREE(output);
virCommandFree(cmd);
return ret;
}
......@@ -478,7 +473,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
size_t ntokens = 0;
int status;
int ret = -1;
char *ovs_timeout = NULL;
VIR_AUTOFREE(char *) ovs_timeout = NULL;
/* Openvswitch vhostuser path are hardcoded to
* /<runstatedir>/openvswitch/<ifname>
......@@ -510,7 +505,6 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
cleanup:
virStringListFreeCount(tokens, ntokens);
virCommandFree(cmd);
VIR_FREE(ovs_timeout);
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册