port->usb_pid = connection_info_ex->DeviceDescriptor.idProduct;
if (connection_info_ex->DeviceDescriptor.iManufacturer)
- port->usb_manufacturer = get_string_descriptor(hub_device,index,
+ port->usb_manufacturer = get_string_descriptor(hub_device, index,
connection_info_ex->DeviceDescriptor.iManufacturer);
if (connection_info_ex->DeviceDescriptor.iProduct)
port->usb_product = get_string_descriptor(hub_device, index,
continue;
}
RegCloseKey(device_key);
- value[sizeof(value)-1] = 0;
+ value[sizeof(value) - 1] = 0;
if (strcmp(value, port->name))
continue;
DWORD max_value_len, max_data_size, max_data_len;
DWORD value_len, data_size, data_len;
DWORD type, index = 0;
+ LSTATUS result;
char *name;
int name_len;
int ret = SP_OK;
DEBUG("Opening registry key");
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
- 0, KEY_QUERY_VALUE, &key) != ERROR_SUCCESS) {
- SET_FAIL(ret, "RegOpenKeyEx() failed");
+ if ((result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("HARDWARE\\DEVICEMAP\\SERIALCOMM"),
+ 0, KEY_QUERY_VALUE, &key)) != ERROR_SUCCESS) {
+ /* It's possible for this key to not exist if there are no serial ports
+ * at all. In that case we're done. Return a failure for any other error. */
+ if (result != ERROR_FILE_NOT_FOUND) {
+ SetLastError(result);
+ SET_FAIL(ret, "RegOpenKeyEx() failed");
+ }
goto out_done;
}
DEBUG("Querying registry key value and data sizes");
- if (RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- &max_value_len, &max_data_size, NULL, NULL) != ERROR_SUCCESS) {
+ if ((result = RegQueryInfoKey(key, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &max_value_len, &max_data_size, NULL, NULL)) != ERROR_SUCCESS) {
+ SetLastError(result);
SET_FAIL(ret, "RegQueryInfoKey() failed");
goto out_close;
}