Skip to content

Commit

Permalink
Update htool_usb.c to print the actual error code
Browse files Browse the repository at this point in the history
  • Loading branch information
paipeng-g authored May 13, 2024
1 parent cfa8c3a commit d01aca4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/htool_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ static void print_device(void* cb_param, libusb_device* dev,
goto cleanup;
}
char product_name[512];
int len = libusb_get_string_descriptor_ascii(dev_handle, descriptor->iProduct,
int rv_or_len = libusb_get_string_descriptor_ascii(dev_handle, descriptor->iProduct,
(unsigned char*)product_name,
sizeof(product_name));
if (len < 0) {
fprintf(stderr, " (unable to get product string: %s)", libusb_strerror(rv));
if (rv_or_len < 0) {
fprintf(stderr, " (unable to get product string: %s)", libusb_strerror(rv_or_len));
goto cleanup2;
}
fprintf(stderr, " - %.*s", len, product_name);
// valid product_name is returned
fprintf(stderr, " - %.*s", rv_or_len, product_name);

cleanup2:
libusb_close(dev_handle);
Expand Down

0 comments on commit d01aca4

Please sign in to comment.