[PATCH v2 07/14] nodedev: Alter param to nodeDeviceUpdateDriverName

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

 



Rather than taking an virNodeDeviceObjPtr and dereffing the obj->def,
just pass the def.

Also check for an error in the function to have the calling function goto
cleanup on error.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/node_device/node_device_driver.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 2a461fb..87953f3 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -106,16 +106,16 @@ nodeDeviceUpdateCaps(virNodeDeviceObjPtr dev)
  * udev *and* HAL backends.
  */
 static int
-nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
+nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def)
 {
     char *driver_link = NULL;
     char *devpath = NULL;
     char *p;
     int ret = -1;
 
-    VIR_FREE(dev->def->driver);
+    VIR_FREE(def->driver);
 
-    if (virAsprintf(&driver_link, "%s/driver", dev->def->sysfs_path) < 0)
+    if (virAsprintf(&driver_link, "%s/driver", def->sysfs_path) < 0)
         goto cleanup;
 
     /* Some devices don't have an explicit driver, so just return
@@ -132,7 +132,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
     }
 
     p = strrchr(devpath, '/');
-    if (p && VIR_STRDUP(dev->def->driver, p + 1) < 0)
+    if (p && VIR_STRDUP(def->driver, p + 1) < 0)
         goto cleanup;
     ret = 0;
 
@@ -144,7 +144,7 @@ nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev)
 #else
 /* XXX: Implement me for non-linux */
 static int
-nodeDeviceUpdateDriverName(virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
+nodeDeviceUpdateDriverName(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED)
 {
     return 0;
 }
@@ -338,7 +338,9 @@ nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
     if (virNodeDeviceGetXMLDescEnsureACL(dev->conn, obj->def) < 0)
         goto cleanup;
 
-    nodeDeviceUpdateDriverName(obj);
+    if (nodeDeviceUpdateDriverName(obj->def) < 0)
+        goto cleanup;
+
     if (nodeDeviceUpdateCaps(obj) < 0)
         goto cleanup;
 
-- 
2.9.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]
  Powered by Linux