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
|
||||
|
||||
struct libusb_device_descriptor desc;
|
||||
libusb_get_device_descriptor(device, &desc);
|
||||
|
||||
if (!desc.iSerialNumber) {
|
||||
int result = libusb_get_device_descriptor(device, &desc);
|
||||
if (result < 0 || !desc.iSerialNumber) {
|
||||
return false;
|
||||
}
|
||||
|
||||
libusb_device_handle *handle;
|
||||
int result = libusb_open(device, &handle);
|
||||
result = libusb_open(device, &handle);
|
||||
if (result < 0) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue