mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
nodedev: Alter param to nodeDeviceUpdateDriverName
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@redhat.com>
This commit is contained in:
parent
18c551f378
commit
381bbfbbb6
@ -110,16 +110,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
|
||||
@ -136,7 +136,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;
|
||||
|
||||
@ -148,7 +148,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;
|
||||
}
|
||||
@ -352,7 +352,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user