[PATCH 11/11] Delete udevFreeIfaceDef function in udev interface driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The udevFreeIfaceDef function in the udev interface driver
just duplicates code from virInterfaceDefFree. Delete it
and call the standard API instead.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/interface/interface_backend_udev.c | 45 ++--------------------------------
 1 file changed, 2 insertions(+), 43 deletions(-)

diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 79c57ee..0384ef5 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -542,44 +542,6 @@ udevBridgeScanDirFilter(const struct dirent *entry)
     return 1;
 }
 
-/**
- * Frees any memory allocated by udevGetIfaceDef()
- *
- * @param ifacedef - interface to free and cleanup
- */
-static void
-udevFreeIfaceDef(virInterfaceDef *ifacedef)
-{
-    int i;
-
-    if (!ifacedef)
-        return;
-
-    if (ifacedef->type == VIR_INTERFACE_TYPE_BOND) {
-        VIR_FREE(ifacedef->data.bond.target);
-        for (i = 0; i < ifacedef->data.bond.nbItf; i++) {
-            udevFreeIfaceDef(ifacedef->data.bond.itf[i]);
-        }
-        VIR_FREE(ifacedef->data.bond.itf);
-    }
-
-    if (ifacedef->type == VIR_INTERFACE_TYPE_BRIDGE) {
-        VIR_FREE(ifacedef->data.bridge.delay);
-        for (i = 0; i < ifacedef->data.bridge.nbItf; i++) {
-            udevFreeIfaceDef(ifacedef->data.bridge.itf[i]);
-        }
-        VIR_FREE(ifacedef->data.bridge.itf);
-    }
-
-    if (ifacedef->type == VIR_INTERFACE_TYPE_VLAN) {
-        VIR_FREE(ifacedef->data.vlan.devname);
-    }
-
-    VIR_FREE(ifacedef->mac);
-    VIR_FREE(ifacedef->name);
-
-    VIR_FREE(ifacedef);
-}
 
 static int
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
@@ -1080,7 +1042,7 @@ udevGetIfaceDef(struct udev *udev, const char *name)
 cleanup:
     udev_device_unref(dev);
 
-    udevFreeIfaceDef(ifacedef);
+    virInterfaceDefFree(ifacedef);
 
     return NULL;
 }
@@ -1101,15 +1063,12 @@ udevInterfaceGetXMLDesc(virInterfacePtr ifinfo,
      */
     ifacedef = udevGetIfaceDef(udev, ifinfo->name);
 
-    /* We've already printed by it happened */
     if (!ifacedef)
         goto err;
 
-    /* Convert our interface to XML */
     xmlstr = virInterfaceDefFormat(ifacedef);
 
-    /* Recursively free our interface structures and free the children too */
-    udevFreeIfaceDef(ifacedef);
+    virInterfaceDefFree(ifacedef);
 
 err:
     /* decrement our udev ptr */
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]