summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
19bf8b8)
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 main(int argc, char** argv) {
char default_filename[] = "firmware.bin";
char* filename = default_filename;
if (argc == 2) {
filename = argv[1];
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");
dev = libusb_open_device_with_vid_pid(NULL, 0x045e, 0x02ad);
if (dev == NULL) {
fprintf(stderr, "Couldn't open device.\n");
+ res = -ENODEV;
+ goto fail_libusb_open;
}
libusb_set_configuration(dev, 1);
}
libusb_set_configuration(dev, 1);
LOG("About to send: ");
dump_bl_cmd(cmd);
LOG("About to send: ");
dump_bl_cmd(cmd);
int transferred;
res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
int transferred;
res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
cleanup:
libusb_close(dev);
cleanup:
libusb_close(dev);
+ fclose(fw);
+ return res;