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@xxxxxxxxx> --- src/util/virnetdevmacvlan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index 91c6244..a2ed65c 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -308,7 +308,7 @@ virNetDevMacVLanCreate(const char *ifname, int *retry) { int rc = -1; - struct nlmsghdr *resp = NULL; + VIR_AUTOFREE(struct nlmsghdr *) resp = NULL; struct nlmsgerr *err; struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC }; int ifindex; @@ -403,7 +403,6 @@ virNetDevMacVLanCreate(const char *ifname, rc = 0; cleanup: nlmsg_free(nl_msg); - VIR_FREE(resp); return rc; malformed_resp: @@ -452,7 +451,7 @@ virNetDevMacVLanTapOpen(const char *ifname, { int ret = -1; int ifindex; - char *tapname = NULL; + VIR_AUTOFREE(char *) tapname = NULL; size_t i = 0; if (virNetDevGetIndex(ifname, &ifindex) < 0) @@ -487,7 +486,6 @@ virNetDevMacVLanTapOpen(const char *ifname, while (i--) VIR_FORCE_CLOSE(tapfd[i]); } - VIR_FREE(tapname); return ret; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list