Handle libusb_get_device_descriptor() error
The function libusb_get_device_descriptor() might return an error. Handle it.
This commit is contained in:
parent
308a1f8192
commit
d41a46dc95
1 changed files with 3 additions and 4 deletions
|
@ -56,14 +56,13 @@ accept_device(libusb_device *device, const char *serial) {
|
||||||
// devices available on the computer have permission restrictions
|
// devices available on the computer have permission restrictions
|
||||||
|
|
||||||
struct libusb_device_descriptor desc;
|
struct libusb_device_descriptor desc;
|
||||||
libusb_get_device_descriptor(device, &desc);
|
int result = libusb_get_device_descriptor(device, &desc);
|
||||||
|
if (result < 0 || !desc.iSerialNumber) {
|
||||||
if (!desc.iSerialNumber) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
libusb_device_handle *handle;
|
libusb_device_handle *handle;
|
||||||
int result = libusb_open(device, &handle);
|
result = libusb_open(device, &handle);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue