Remove the ret variable and return early if there is no driver. --- src/node_device/node_device_udev.c | 44 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 24 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index ef8d7af..1e11afe 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1488,42 +1488,38 @@ static void udevPCITranslateDeinit(void) static int nodeStateCleanup(void) { - int ret = 0; - udevPrivate *priv = NULL; struct udev_monitor *udev_monitor = NULL; struct udev *udev = NULL; - if (driver) { - nodeDeviceLock(); + if (!driver) + return -1; - priv = driver->privateData; + nodeDeviceLock(); - if (priv->watch != -1) - virEventRemoveHandle(priv->watch); + priv = driver->privateData; - udev_monitor = DRV_STATE_UDEV_MONITOR(driver); + if (priv->watch != -1) + virEventRemoveHandle(priv->watch); - if (udev_monitor != NULL) { - udev = udev_monitor_get_udev(udev_monitor); - udev_monitor_unref(udev_monitor); - } + udev_monitor = DRV_STATE_UDEV_MONITOR(driver); - if (udev != NULL) - udev_unref(udev); + if (udev_monitor != NULL) { + udev = udev_monitor_get_udev(udev_monitor); + udev_monitor_unref(udev_monitor); + } - virNodeDeviceObjListFree(&driver->devs); - nodeDeviceUnlock(); - virMutexDestroy(&driver->lock); - VIR_FREE(driver); - VIR_FREE(priv); + if (udev != NULL) + udev_unref(udev); - udevPCITranslateDeinit(); - } else { - ret = -1; - } + virNodeDeviceObjListFree(&driver->devs); + nodeDeviceUnlock(); + virMutexDestroy(&driver->lock); + VIR_FREE(driver); + VIR_FREE(priv); - return ret; + udevPCITranslateDeinit(); + return 0; } -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list