By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr(a)gmail.com>
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>
---
src/util/virnetdevmacvlan.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index a2ed65c..100507f 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -1184,9 +1184,9 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
}
if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
- virMacAddrPtr MAC = NULL;
- virMacAddrPtr adminMAC = NULL;
- virNetDevVlanPtr vlan = NULL;
+ VIR_AUTOPTR(virMacAddr) MAC = NULL;
+ VIR_AUTOPTR(virMacAddr) adminMAC = NULL;
+ VIR_AUTOPTR(virNetDevVlan) vlan = NULL;
if ((virNetDevReadNetConfig(linkdev, -1, stateDir,
&adminMAC, &vlan, &MAC) == 0) &&
@@ -1194,9 +1194,6 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
ignore_value(virNetDevSetNetConfig(linkdev, -1,
adminMAC, vlan, MAC, !!vlan));
- VIR_FREE(MAC);
- VIR_FREE(adminMAC);
- virNetDevVlanFree(vlan);
}
}
--
1.8.3.1