Remove unnecessary curly brackets in src/node_device/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-11-13 15:24:17 +01:00
parent f9674bf277
commit df6c14e6a8
3 changed files with 38 additions and 76 deletions

View File

@ -48,9 +48,8 @@ static int update_caps(virNodeDeviceObjPtr dev)
virNodeDevCapsDefPtr cap = dev->def->caps; virNodeDevCapsDefPtr cap = dev->def->caps;
while (cap) { 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); detect_scsi_host_caps(&dev->def->caps->data);
}
if (cap->type == VIR_NODE_DEV_CAP_NET && if (cap->type == VIR_NODE_DEV_CAP_NET &&
virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0) virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0)
return -1; return -1;
@ -494,15 +493,13 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0);
if (dev != NULL) { if (dev != NULL)
break; break;
}
sleep(5); sleep(5);
if (get_time(&now) == -1) { if (get_time(&now) == -1)
break; break;
} }
}
nodeDeviceLock(driver); nodeDeviceLock(driver);
@ -527,16 +524,14 @@ nodeDeviceCreateXML(virConnectPtr conn,
nodeDeviceLock(driver); nodeDeviceLock(driver);
def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type); def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type);
if (def == NULL) { if (def == NULL)
goto cleanup; goto cleanup;
}
if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0) if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0)
goto cleanup; goto cleanup;
if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) { if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1)
goto cleanup; goto cleanup;
}
if (virNodeDeviceGetParentHost(&driver->devs, if (virNodeDeviceGetParentHost(&driver->devs,
def->name, def->name,
@ -556,9 +551,8 @@ nodeDeviceCreateXML(virConnectPtr conn,
/* We don't check the return value, because one way or another, /* We don't check the return value, because one way or another,
* we're returning what we get... */ * we're returning what we get... */
if (dev == NULL) { if (dev == NULL)
virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); virReportError(VIR_ERR_NO_NODE_DEVICE, NULL);
}
cleanup: cleanup:
nodeDeviceUnlock(driver); nodeDeviceUnlock(driver);
@ -590,9 +584,8 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0) if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0)
goto out; goto out;
if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) { if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1)
goto out; goto out;
}
/* virNodeDeviceGetParentHost will cause the device object's lock to be /* virNodeDeviceGetParentHost will cause the device object's lock to be

View File

@ -255,9 +255,8 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi,
retval = detect_scsi_host_caps(d); retval = detect_scsi_host_caps(d);
if (retval == -1) { if (retval == -1)
goto out; goto out;
}
out: out:
return retval; return retval;
@ -551,9 +550,8 @@ dev_refresh(const char *udi)
} }
nodeDeviceUnlock(driverState); nodeDeviceUnlock(driverState);
if (dev) { if (dev)
dev_create(udi); dev_create(udi);
}
} }
static void static void

View File

@ -166,10 +166,9 @@ static int udevGetIntProperty(struct udev_device *udev_device,
ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); ret = udevGetDeviceProperty(udev_device, property_key, &udev_value);
if (ret == PROPERTY_FOUND) { 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; ret = PROPERTY_ERROR;
} }
}
VIR_FREE(udev_value); VIR_FREE(udev_value);
return ret; return ret;
@ -187,10 +186,9 @@ static int udevGetUintProperty(struct udev_device *udev_device,
ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); ret = udevGetDeviceProperty(udev_device, property_key, &udev_value);
if (ret == PROPERTY_FOUND) { 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; ret = PROPERTY_ERROR;
} }
}
VIR_FREE(udev_value); VIR_FREE(udev_value);
return ret; return ret;
@ -266,10 +264,9 @@ static int udevGetIntSysfsAttr(struct udev_device *udev_device,
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) { 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; ret = PROPERTY_ERROR;
} }
}
VIR_FREE(udev_value); VIR_FREE(udev_value);
return ret; return ret;
@ -287,10 +284,9 @@ static int udevGetUintSysfsAttr(struct udev_device *udev_device,
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) { 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; ret = PROPERTY_ERROR;
} }
}
VIR_FREE(udev_value); VIR_FREE(udev_value);
return ret; return ret;
@ -307,10 +303,9 @@ static int udevGetUint64SysfsAttr(struct udev_device *udev_device,
ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value);
if (ret == PROPERTY_FOUND) { 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; ret = PROPERTY_ERROR;
} }
}
VIR_FREE(udev_value); VIR_FREE(udev_value);
return ret; return ret;
@ -329,9 +324,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
udev_device_get_subsystem(device), udev_device_get_subsystem(device),
udev_device_get_sysname(device)); udev_device_get_sysname(device));
if (s != NULL) { if (s != NULL)
virBufferAsprintf(&buf, "_%s", s); virBufferAsprintf(&buf, "_%s", s);
}
if (virBufferCheckError(&buf) < 0) if (virBufferCheckError(&buf) < 0)
return -1; return -1;
@ -339,10 +333,9 @@ static int udevGenerateDeviceName(struct udev_device *device,
def->name = virBufferContentAndReset(&buf); def->name = virBufferContentAndReset(&buf);
for (i = 0; i < strlen(def->name); i++) { for (i = 0; i < strlen(def->name); i++) {
if (!(c_isalnum(*(def->name + i)))) { if (!(c_isalnum(*(def->name + i))))
*(def->name + i) = '_'; *(def->name + i) = '_';
} }
}
return ret; return ret;
} }
@ -490,9 +483,8 @@ static int udevProcessPCI(struct udev_device *device,
goto out; goto out;
} }
if (udevGenerateDeviceName(device, def, NULL) != 0) { if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out; goto out;
}
rc = udevGetIntSysfsAttr(device, rc = udevGetIntSysfsAttr(device,
"numa_node", "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; goto out;
}
ret = 0; ret = 0;
@ -681,9 +672,8 @@ static int udevProcessUSBInterface(struct udev_device *device,
goto out; goto out;
} }
if (udevGenerateDeviceName(device, def, NULL) != 0) { if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out; goto out;
}
ret = 0; ret = 0;
@ -724,9 +714,8 @@ static int udevProcessNetworkInterface(struct udev_device *device,
goto out; goto out;
} }
if (udevGenerateDeviceName(device, def, data->net.address) != 0) { if (udevGenerateDeviceName(device, def, data->net.address) != 0)
goto out; goto out;
}
if (virNetDevGetLinkInfo(data->net.ifname, &data->net.lnk) < 0) if (virNetDevGetLinkInfo(data->net.ifname, &data->net.lnk) < 0)
goto out; goto out;
@ -762,9 +751,8 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
detect_scsi_host_caps(&def->caps->data); detect_scsi_host_caps(&def->caps->data);
if (udevGenerateDeviceName(device, def, NULL) != 0) { if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out; goto out;
}
ret = 0; ret = 0;
@ -785,9 +773,8 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED,
if (VIR_STRDUP(data->scsi_target.name, sysname) < 0) if (VIR_STRDUP(data->scsi_target.name, sysname) < 0)
goto out; goto out;
if (udevGenerateDeviceName(device, def, NULL) != 0) { if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out; goto out;
}
ret = 0; ret = 0;
@ -864,9 +851,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
filename = last_component(def->sysfs_path); 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; goto out;
}
if ((p == NULL) || (udevStrToLong_ui(p+1, if ((p == NULL) || (udevStrToLong_ui(p+1,
&p, &p,
@ -891,9 +877,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
switch (udevGetUintSysfsAttr(device, "type", &tmp, 0)) { switch (udevGetUintSysfsAttr(device, "type", &tmp, 0)) {
case PROPERTY_FOUND: case PROPERTY_FOUND:
if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) { if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1)
goto out; goto out;
}
break; break;
case PROPERTY_MISSING: case PROPERTY_MISSING:
break; /* No type is not an error */ break; /* No type is not an error */
@ -903,9 +888,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
break; break;
} }
if (udevGenerateDeviceName(device, def, NULL) != 0) { if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out; goto out;
}
ret = 0; ret = 0;
@ -1099,9 +1083,8 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def)
static void udevStripSpaces(char *s) static void udevStripSpaces(char *s)
{ {
if (s == NULL) { if (s == NULL)
return; return;
}
while (virFileStripSuffix(s, " ")) { while (virFileStripSuffix(s, " ")) {
/* do nothing */ /* do nothing */
@ -1184,11 +1167,10 @@ static int udevProcessStorage(struct udev_device *device,
} else { } else {
/* If udev doesn't have it, perhaps we can guess it. */ /* If udev doesn't have it, perhaps we can guess it. */
if (udevKludgeStorageType(def) != 0) { if (udevKludgeStorageType(def) != 0)
goto out; goto out;
} }
} }
}
if (STREQ(def->caps->data.storage.drive_type, "cd")) { if (STREQ(def->caps->data.storage.drive_type, "cd")) {
ret = udevProcessCDROM(device, def); ret = udevProcessCDROM(device, def);
@ -1204,9 +1186,8 @@ static int udevProcessStorage(struct udev_device *device,
goto out; goto out;
} }
if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) { if (udevGenerateDeviceName(device, def, data->storage.serial) != 0)
goto out; goto out;
}
out: out:
VIR_DEBUG("Storage ret=%d", ret); VIR_DEBUG("Storage ret=%d", ret);
@ -1376,9 +1357,8 @@ static int udevSetParent(struct udev_device *device,
do { do {
parent_device = udev_device_get_parent(parent_device); parent_device = udev_device_get_parent(parent_device);
if (parent_device == NULL) { if (parent_device == NULL)
break; break;
}
parent_sysfs_path = udev_device_get_syspath(parent_device); parent_sysfs_path = udev_device_get_syspath(parent_device);
if (parent_sysfs_path == NULL) { if (parent_sysfs_path == NULL) {
@ -1434,17 +1414,14 @@ static int udevAddOneDevice(struct udev_device *device)
if (VIR_ALLOC(def->caps) != 0) if (VIR_ALLOC(def->caps) != 0)
goto out; goto out;
if (udevGetDeviceType(device, &def->caps->type) != 0) { if (udevGetDeviceType(device, &def->caps->type) != 0)
goto out; goto out;
}
if (udevGetDeviceDetails(device, def) != 0) { if (udevGetDeviceDetails(device, def) != 0)
goto out; goto out;
}
if (udevSetParent(device, def) != 0) { if (udevSetParent(device, def) != 0)
goto out; goto out;
}
/* If this is a device change, the old definition will be freed /* If this is a device change, the old definition will be freed
* and the current definition will take its place. */ * and the current definition will take its place. */
@ -1544,9 +1521,8 @@ static int nodeStateCleanup(void)
udev_monitor_unref(udev_monitor); udev_monitor_unref(udev_monitor);
} }
if (udev != NULL) { if (udev != NULL)
udev_unref(udev); udev_unref(udev);
}
virNodeDeviceObjListFree(&driverState->devs); virNodeDeviceObjListFree(&driverState->devs);
nodeDeviceUnlock(driverState); nodeDeviceUnlock(driverState);
@ -1681,9 +1657,8 @@ udevGetDMIData(union _virNodeDevCapData *data)
out: out:
VIR_FREE(tmp); VIR_FREE(tmp);
if (device != NULL) { if (device != NULL)
udev_device_unref(device); udev_device_unref(device);
}
return; return;
} }
#endif #endif
@ -1719,9 +1694,8 @@ static int udevSetupSystemDev(void)
ret = 0; ret = 0;
out: out:
if (ret == -1) { if (ret == -1)
virNodeDeviceDefFree(def); virNodeDeviceDefFree(def);
}
return ret; return ret;
} }
@ -1834,9 +1808,8 @@ static int nodeStateInitialize(bool privileged,
nodeDeviceUnlock(driverState); nodeDeviceUnlock(driverState);
out: out:
if (ret == -1) { if (ret == -1)
nodeStateCleanup(); nodeStateCleanup();
}
return ret; return ret;
} }
@ -1853,9 +1826,8 @@ static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn,
{ {
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
if (driverState == NULL) { if (driverState == NULL)
return VIR_DRV_OPEN_DECLINED; return VIR_DRV_OPEN_DECLINED;
}
conn->nodeDevicePrivateData = driverState; conn->nodeDevicePrivateData = driverState;
@ -1896,9 +1868,8 @@ int udevNodeRegister(void)
{ {
VIR_DEBUG("Registering udev node device backend"); VIR_DEBUG("Registering udev node device backend");
if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) { if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0)
return -1; return -1;
}
return virRegisterStateDriver(&udevStateDriver); return virRegisterStateDriver(&udevStateDriver);
} }