]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: netdevmacvlan: use VIR_AUTOPTR for aggregate types
authorSukrit Bhatnagar <skrtbhtngr@gmail.com>
Sat, 28 Jul 2018 18:01:31 +0000 (23:31 +0530)
committerErik Skultety <eskultet@redhat.com>
Tue, 7 Aug 2018 14:29:55 +0000 (16:29 +0200)
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@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virnetdevmacvlan.c

index 32062cbc2cc67de1c0b4922b484548a2061ba998..2035b1f0215ec1c7d7d6e10d047b2b1a565a07ad 100644 (file)
@@ -1181,9 +1181,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) &&
@@ -1191,9 +1191,6 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
 
             ignore_value(virNetDevSetNetConfig(linkdev, -1,
                                                adminMAC, vlan, MAC, !!vlan));
-            VIR_FREE(MAC);
-            VIR_FREE(adminMAC);
-            virNetDevVlanFree(vlan);
         }
     }