mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
virarptable: fix some leaks and format issue
fix some leaks and format issue Also support virArpTableFree to get NULL. Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
This commit is contained in:
parent
60b3fcd90c
commit
70c67d4a15
@ -47,6 +47,7 @@ VIR_LOG_INIT("util.arptable");
|
|||||||
# define NDA_RTA(r) \
|
# define NDA_RTA(r) \
|
||||||
((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
|
((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
|
parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
|
||||||
{
|
{
|
||||||
@ -64,7 +65,9 @@ parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virArpTablePtr virArpTableGet(void)
|
|
||||||
|
virArpTablePtr
|
||||||
|
virArpTableGet(void)
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
int msglen;
|
int msglen;
|
||||||
@ -156,6 +159,7 @@ virArpTablePtr virArpTableGet(void)
|
|||||||
return table;
|
return table;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virArpTableFree(table);
|
||||||
VIR_FREE(ipstr);
|
VIR_FREE(ipstr);
|
||||||
VIR_FREE(nlData);
|
VIR_FREE(nlData);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -163,7 +167,8 @@ virArpTablePtr virArpTableGet(void)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
virArpTablePtr virArpTableGet(void)
|
virArpTablePtr
|
||||||
|
virArpTableGet(void)
|
||||||
{
|
{
|
||||||
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("get arp table not implemented on this platform"));
|
_("get arp table not implemented on this platform"));
|
||||||
@ -176,6 +181,10 @@ void
|
|||||||
virArpTableFree(virArpTablePtr table)
|
virArpTableFree(virArpTablePtr table)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
if (!table)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < table->n; i++) {
|
for (i = 0; i < table->n; i++) {
|
||||||
VIR_FREE(table->t[i].ipaddr);
|
VIR_FREE(table->t[i].ipaddr);
|
||||||
VIR_FREE(table->t[i].mac);
|
VIR_FREE(table->t[i].mac);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user