From d85e29dd8207d6972b03a55af8c024c319d081cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Fri, 3 Jun 2016 12:38:40 +0200 Subject: [PATCH] Reformat nodeStateCleanup Remove the ret variable and return early if there is no driver. --- src/node_device/node_device_udev.c | 46 ++++++++++++++---------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index ef8d7af7b3..1e11afe128 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); - - virNodeDeviceObjListFree(&driver->devs); - nodeDeviceUnlock(); - virMutexDestroy(&driver->lock); - VIR_FREE(driver); - VIR_FREE(priv); - - udevPCITranslateDeinit(); - } else { - ret = -1; + if (udev_monitor != NULL) { + udev = udev_monitor_get_udev(udev_monitor); + udev_monitor_unref(udev_monitor); } - return ret; + if (udev != NULL) + udev_unref(udev); + + virNodeDeviceObjListFree(&driver->devs); + nodeDeviceUnlock(); + virMutexDestroy(&driver->lock); + VIR_FREE(driver); + VIR_FREE(priv); + + udevPCITranslateDeinit(); + return 0; }