struct usb_bus *bus;
        struct usb_device *dev;
        usb_dev_handle *h;
+       #ifdef LIBUSB_HAS_GET_DRIVER_NP
        char buf[128];
+       #endif
        int r;
 
        usb_init();
                if (r != WAIT_OBJECT_0) return 0;
        }
        if (!GetOverlappedResult(h, &ov, &n, FALSE)) return 0;
-       if (n <= 0) return 0;
        return 1;
 }
 
 {
        teensy_close();
        uhid_teensy_fd = open_usb_device(0x16C0, 0x0478);
-       
+
        if (uhid_teensy_fd < 0)
                uhid_teensy_fd = open_usb_device(0x03eb, 0x2067);
-       
+
        if (uhid_teensy_fd < 0) return 0;
        return 1;
 }
                if (*buf) {
                        if (parse_hex_line(buf) == 0) {
                                //printf("Warning, parse error line %d\n", lineno);
+                               fclose(fp);
                                return -2;
                        }
                }
        int addr, code, num;
         int sum, len, cksum, i;
         char *ptr;
-        
+
         num = 0;
         if (line[0] != ':') return 0;
         if (strlen(line) < 11) return 0;