kinect_upload_fw: fix some warnings from clang -Weverything
[kinect-audio-setup.git] / kinect_upload_fw / kinect_upload_fw.c
index 54f463a..8092422 100644 (file)
@@ -197,7 +197,16 @@ int main(int argc, char** argv) {
                goto cleanup;
        }
        res = get_first_reply(); // This first one doesn't have the usual magic bytes at the beginning, and is 96 bytes long - much longer than the usual 12-byte replies.
                goto cleanup;
        }
        res = get_first_reply(); // This first one doesn't have the usual magic bytes at the beginning, and is 96 bytes long - much longer than the usual 12-byte replies.
+       if (res < 0) {
+               LOG("get_first_reply() failed");
+               goto cleanup;
+       }
+
        res = get_reply(); // I'm not sure why we do this twice here, but maybe it'll make sense later.
        res = get_reply(); // I'm not sure why we do this twice here, but maybe it'll make sense later.
+       if (res < 0) {
+               LOG("First get_reply() failed");
+               goto cleanup;
+       }
        seq++;
 
        // Split addr declaration and assignment in order to compile as C++,
        seq++;
 
        // Split addr declaration and assignment in order to compile as C++,
@@ -208,13 +217,13 @@ int main(int argc, char** argv) {
        unsigned char page[0x4000];
        int read;
        do {
        unsigned char page[0x4000];
        int read;
        do {
-               read = fread(page, 1, 0x4000, fw);
+               read = (int)fread(page, 1, 0x4000, fw);
                if (read <= 0) {
                        break;
                }
                //LOG("");
                cmd.seq = fn_le32(seq);
                if (read <= 0) {
                        break;
                }
                //LOG("");
                cmd.seq = fn_le32(seq);
-               cmd.bytes = fn_le32(read);
+               cmd.bytes = fn_le32((unsigned int)read);
                cmd.cmd = fn_le32(0x03);
                cmd.write_addr = fn_le32(addr);
                LOG("About to send: ");
                cmd.cmd = fn_le32(0x03);
                cmd.write_addr = fn_le32(addr);
                LOG("About to send: ");
@@ -238,6 +247,10 @@ int main(int argc, char** argv) {
                        bytes_sent += to_send;
                }
                res = get_reply();
                        bytes_sent += to_send;
                }
                res = get_reply();
+               if (res < 0) {
+                       LOG("get_reply failed");
+                       goto cleanup;
+               }
 
                addr += (uint32_t)read;
                seq++;
 
                addr += (uint32_t)read;
                seq++;
@@ -259,6 +272,7 @@ int main(int argc, char** argv) {
        // Now the device reenumerates.
 
 cleanup:
        // Now the device reenumerates.
 
 cleanup:
+       libusb_release_interface(dev, KINECT_AUDIO_INTERFACE);
        libusb_close(dev);
 fail_libusb_open:
        libusb_exit(NULL);
        libusb_close(dev);
 fail_libusb_open:
        libusb_exit(NULL);