diff options
author | Pete Batard <pbatard@gmail.com> | 2010-10-27 19:31:27 +0100 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2010-10-27 19:31:27 +0100 |
commit | 844d7db566dc6fb75143554ddc8dcc308cc9da35 (patch) | |
tree | 7b4af3e202a640ef5ce3cb0e3da3cab432e0340c /libusb/os/windows_usb.c | |
parent | 53fec87339c29b44f2582f175aba383e9d78543e (diff) | |
download | libusb-844d7db566dc6fb75143554ddc8dcc308cc9da35.tar.gz |
minor enumeration bugfixes and improvementspbr318
* dev_interface_details is not available on GEN pass but
some warning messages attempt to reference that pointer
* skip device if interface path cannot be sanitized
* check the return value of init_device() and bail out on error
Diffstat (limited to 'libusb/os/windows_usb.c')
-rw-r--r-- | libusb/os/windows_usb.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libusb/os/windows_usb.c b/libusb/os/windows_usb.c index e9ad2a6..d75bc95 100644 --- a/libusb/os/windows_usb.c +++ b/libusb/os/windows_usb.c @@ -1342,13 +1342,15 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered // Read the Device ID path. This is what we'll use as UID // Note that if the device is plugged in a different port or hub, the Device ID changes if (CM_Get_Device_IDA(dev_info_data.DevInst, path, sizeof(path), 0) != CR_SUCCESS) { - usbi_warn(ctx, "could not read the device id path for device '%s', skipping", - dev_interface_details->DevicePath); + usbi_warn(ctx, "could not read the device id path for devinst %X, skipping", + dev_info_data.DevInst); continue; } dev_id_path = sanitize_path(path); if (dev_id_path == NULL) { - usbi_warn(ctx, "could not sanitize device id path for '%s'", dev_interface_details->DevicePath); + usbi_warn(ctx, "could not sanitize device id path for devinst %X, skipping", + dev_info_data.DevInst); + continue; } // The SPDRP_ADDRESS for USB devices is the device port number on the hub @@ -1357,8 +1359,8 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered if ( (!pSetupDiGetDeviceRegistryPropertyA(dev_info, &dev_info_data, SPDRP_ADDRESS, ®_type, (BYTE*)&port_nr, 4, &size)) || (size != 4) ) { - usbi_warn(ctx, "could not retrieve port number for device %s, skipping: %s", - dev_interface_details->DevicePath, windows_error_str(0)); + usbi_warn(ctx, "could not retrieve port number for device '%s', skipping: %s", + dev_id_path, windows_error_str(0)); continue; } } @@ -1548,7 +1550,7 @@ static int windows_get_device_list(struct libusb_context *ctx, struct discovered break; // fall through, as we must initialize hubs before generic devices case GEN_PASS: - init_device(dev, parent_dev, (uint8_t)port_nr, dev_id_path); + r = init_device(dev, parent_dev, (uint8_t)port_nr, dev_id_path); break; default: // HID_PASS and later if (parent_priv->apib == &usb_api_backend[USB_API_HID]) { |