From df6c14e6a86d96a19540848ff9e4af47da311c45 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Thu, 13 Nov 2014 15:24:17 +0100 Subject: [PATCH] Remove unnecessary curly brackets in src/node_device/ Signed-off-by: Martin Kletzander --- src/node_device/node_device_driver.c | 21 +++---- src/node_device/node_device_hal.c | 6 +- src/node_device/node_device_udev.c | 87 ++++++++++------------------ 3 files changed, 38 insertions(+), 76 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 5d58ca7e46..5d0efb46b5 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -48,9 +48,8 @@ static int update_caps(virNodeDeviceObjPtr dev) virNodeDevCapsDefPtr cap = dev->def->caps; while (cap) { - if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { + if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) detect_scsi_host_caps(&dev->def->caps->data); - } if (cap->type == VIR_NODE_DEV_CAP_NET && virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0) return -1; @@ -494,14 +493,12 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn) dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); - if (dev != NULL) { + if (dev != NULL) break; - } sleep(5); - if (get_time(&now) == -1) { + if (get_time(&now) == -1) break; - } } nodeDeviceLock(driver); @@ -527,16 +524,14 @@ nodeDeviceCreateXML(virConnectPtr conn, nodeDeviceLock(driver); def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type); - if (def == NULL) { + if (def == NULL) goto cleanup; - } if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0) goto cleanup; - if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) goto cleanup; - } if (virNodeDeviceGetParentHost(&driver->devs, def->name, @@ -556,9 +551,8 @@ nodeDeviceCreateXML(virConnectPtr conn, /* We don't check the return value, because one way or another, * we're returning what we get... */ - if (dev == NULL) { + if (dev == NULL) virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); - } cleanup: nodeDeviceUnlock(driver); @@ -590,9 +584,8 @@ nodeDeviceDestroy(virNodeDevicePtr dev) if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0) goto out; - if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) goto out; - } /* virNodeDeviceGetParentHost will cause the device object's lock to be diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index ec37223caa..c32b1fe1cf 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -255,9 +255,8 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi, retval = detect_scsi_host_caps(d); - if (retval == -1) { + if (retval == -1) goto out; - } out: return retval; @@ -551,9 +550,8 @@ dev_refresh(const char *udi) } nodeDeviceUnlock(driverState); - if (dev) { + if (dev) dev_create(udi); - } } static void diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index f580a9b6b4..343ef85897 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -166,9 +166,8 @@ static int udevGetIntProperty(struct udev_device *udev_device, ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_i(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_i(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -187,9 +186,8 @@ static int udevGetUintProperty(struct udev_device *udev_device, ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -266,9 +264,8 @@ static int udevGetIntSysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_i(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_i(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -287,9 +284,8 @@ static int udevGetUintSysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -307,9 +303,8 @@ static int udevGetUint64SysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0) { + if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -329,9 +324,8 @@ static int udevGenerateDeviceName(struct udev_device *device, udev_device_get_subsystem(device), udev_device_get_sysname(device)); - if (s != NULL) { + if (s != NULL) virBufferAsprintf(&buf, "_%s", s); - } if (virBufferCheckError(&buf) < 0) return -1; @@ -339,9 +333,8 @@ static int udevGenerateDeviceName(struct udev_device *device, def->name = virBufferContentAndReset(&buf); for (i = 0; i < strlen(def->name); i++) { - if (!(c_isalnum(*(def->name + i)))) { + if (!(c_isalnum(*(def->name + i)))) *(def->name + i) = '_'; - } } return ret; @@ -490,9 +483,8 @@ static int udevProcessPCI(struct udev_device *device, goto out; } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } rc = udevGetIntSysfsAttr(device, "numa_node", @@ -636,9 +628,8 @@ static int udevProcessUSBDevice(struct udev_device *device, } } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -681,9 +672,8 @@ static int udevProcessUSBInterface(struct udev_device *device, goto out; } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -724,9 +714,8 @@ static int udevProcessNetworkInterface(struct udev_device *device, goto out; } - if (udevGenerateDeviceName(device, def, data->net.address) != 0) { + if (udevGenerateDeviceName(device, def, data->net.address) != 0) goto out; - } if (virNetDevGetLinkInfo(data->net.ifname, &data->net.lnk) < 0) goto out; @@ -762,9 +751,8 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED, detect_scsi_host_caps(&def->caps->data); - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -785,9 +773,8 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED, if (VIR_STRDUP(data->scsi_target.name, sysname) < 0) goto out; - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -864,9 +851,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, filename = last_component(def->sysfs_path); - if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) { + if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, @@ -891,9 +877,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, switch (udevGetUintSysfsAttr(device, "type", &tmp, 0)) { case PROPERTY_FOUND: - if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) { + if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) goto out; - } break; case PROPERTY_MISSING: break; /* No type is not an error */ @@ -903,9 +888,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, break; } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -1099,9 +1083,8 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def) static void udevStripSpaces(char *s) { - if (s == NULL) { + if (s == NULL) return; - } while (virFileStripSuffix(s, " ")) { /* do nothing */ @@ -1184,9 +1167,8 @@ static int udevProcessStorage(struct udev_device *device, } else { /* If udev doesn't have it, perhaps we can guess it. */ - if (udevKludgeStorageType(def) != 0) { + if (udevKludgeStorageType(def) != 0) goto out; - } } } @@ -1204,9 +1186,8 @@ static int udevProcessStorage(struct udev_device *device, goto out; } - if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) { + if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) goto out; - } out: VIR_DEBUG("Storage ret=%d", ret); @@ -1376,9 +1357,8 @@ static int udevSetParent(struct udev_device *device, do { parent_device = udev_device_get_parent(parent_device); - if (parent_device == NULL) { + if (parent_device == NULL) break; - } parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { @@ -1434,17 +1414,14 @@ static int udevAddOneDevice(struct udev_device *device) if (VIR_ALLOC(def->caps) != 0) goto out; - if (udevGetDeviceType(device, &def->caps->type) != 0) { + if (udevGetDeviceType(device, &def->caps->type) != 0) goto out; - } - if (udevGetDeviceDetails(device, def) != 0) { + if (udevGetDeviceDetails(device, def) != 0) goto out; - } - if (udevSetParent(device, def) != 0) { + if (udevSetParent(device, def) != 0) goto out; - } /* If this is a device change, the old definition will be freed * and the current definition will take its place. */ @@ -1544,9 +1521,8 @@ static int nodeStateCleanup(void) udev_monitor_unref(udev_monitor); } - if (udev != NULL) { + if (udev != NULL) udev_unref(udev); - } virNodeDeviceObjListFree(&driverState->devs); nodeDeviceUnlock(driverState); @@ -1681,9 +1657,8 @@ udevGetDMIData(union _virNodeDevCapData *data) out: VIR_FREE(tmp); - if (device != NULL) { + if (device != NULL) udev_device_unref(device); - } return; } #endif @@ -1719,9 +1694,8 @@ static int udevSetupSystemDev(void) ret = 0; out: - if (ret == -1) { + if (ret == -1) virNodeDeviceDefFree(def); - } return ret; } @@ -1834,9 +1808,8 @@ static int nodeStateInitialize(bool privileged, nodeDeviceUnlock(driverState); out: - if (ret == -1) { + if (ret == -1) nodeStateCleanup(); - } return ret; } @@ -1853,9 +1826,8 @@ static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (driverState == NULL) { + if (driverState == NULL) return VIR_DRV_OPEN_DECLINED; - } conn->nodeDevicePrivateData = driverState; @@ -1896,9 +1868,8 @@ int udevNodeRegister(void) { VIR_DEBUG("Registering udev node device backend"); - if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) { + if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) return -1; - } return virRegisterStateDriver(&udevStateDriver); } -- GitLab