Fix a "possibly lost" issue due to a missing call to libusb_exit() when
exiting after libusb_open_device_with_vid_pid() fails.
Fix a "still reachable" issue due to a missing fclose().
int main(int argc, char** argv) {
char default_filename[] = "firmware.bin";
char* filename = default_filename;
+ int res = 0;
if (argc == 2) {
filename = argv[1];
dev = libusb_open_device_with_vid_pid(NULL, 0x045e, 0x02ad);
if (dev == NULL) {
fprintf(stderr, "Couldn't open device.\n");
- return 1;
+ res = -ENODEV;
+ goto fail_libusb_open;
}
libusb_set_configuration(dev, 1);
LOG("About to send: ");
dump_bl_cmd(cmd);
- int res;
int transferred;
res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
cleanup:
libusb_close(dev);
+fail_libusb_open:
libusb_exit(NULL);
- return 0;
+ fclose(fw);
+ return res;
}