/* iterate through all configurations, returning the index of the configuration
* matching a specific bConfigurationValue in the idx output parameter, or -1
* if the config was not found.
- * returns 0 or a LIBUSB_ERROR code
+ * returns 0 on success or a LIBUSB_ERROR code
*/
int usbi_get_config_index_by_value(struct libusb_device *dev,
uint8_t bConfigurationValue, int *idx)
int host_endian;
int r = usbi_backend->get_config_descriptor(dev, i, tmp, sizeof(tmp),
&host_endian);
- if (r < 0)
+ if (r < 0) {
+ *idx = -1;
return r;
+ }
if (tmp[5] == bConfigurationValue) {
*idx = i;
return 0;