kinect_upload_fw: fix -Wsign-compare and -Wpointer-sign
[kinect-audio-setup.git] / kinect_upload_fw / kinect_upload_fw.c
index 1466ccd..3a22d5c 100644 (file)
@@ -36,7 +36,7 @@
 #include <libusb.h>
 
 static libusb_device_handle *dev;
 #include <libusb.h>
 
 static libusb_device_handle *dev;
-int seq;
+unsigned int seq;
 
 typedef struct {
        uint32_t magic;
 
 typedef struct {
        uint32_t magic;
@@ -57,14 +57,14 @@ typedef struct {
 #define fn_le32(x) (x)
 // TODO: support architectures that aren't little-endian
 
 #define fn_le32(x) (x)
 // TODO: support architectures that aren't little-endian
 
-void dump_bl_cmd(bootloader_command cmd) {
+static void dump_bl_cmd(bootloader_command cmd) {
        int i;
        for(i = 0; i < 24; i++)
                LOG("%02X ", ((unsigned char*)(&cmd))[i]);
        LOG("\n");
 }
 
        int i;
        for(i = 0; i < 24; i++)
                LOG("%02X ", ((unsigned char*)(&cmd))[i]);
        LOG("\n");
 }
 
-int get_first_reply() {
+static int get_first_reply(void) {
        unsigned char buffer[512];
        int res;
        int transferred;
        unsigned char buffer[512];
        int res;
        int transferred;
@@ -82,15 +82,14 @@ int get_first_reply() {
        return res;
 }
 
        return res;
 }
 
-
-int get_reply() {
+static int get_reply(void) {
        unsigned char dump[512];
        status_code buffer = ((status_code*)dump)[0];
        int res;
        int transferred;
        res = libusb_bulk_transfer(dev, 0x81, (unsigned char*)&buffer, 512, &transferred, 0);
        if(res != 0 || transferred != sizeof(status_code)) {
        unsigned char dump[512];
        status_code buffer = ((status_code*)dump)[0];
        int res;
        int transferred;
        res = libusb_bulk_transfer(dev, 0x81, (unsigned char*)&buffer, 512, &transferred, 0);
        if(res != 0 || transferred != sizeof(status_code)) {
-               LOG("Error reading reply: %d\ttransferred: %d (expected %d)\n", res, transferred, sizeof(status_code));
+               LOG("Error reading reply: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(status_code));
                return res;
        }
        if(fn_le32(buffer.magic) != 0x0a6fe000) {
                return res;
        }
        if(fn_le32(buffer.magic) != 0x0a6fe000) {
@@ -104,14 +103,14 @@ int get_reply() {
        if(fn_le32(buffer.status) != 0) {
                LOG("Notice reading reply: last uint32_t was nonzero: %d\n", buffer.status);
        }
        if(fn_le32(buffer.status) != 0) {
                LOG("Notice reading reply: last uint32_t was nonzero: %d\n", buffer.status);
        }
-       
+
        LOG("Reading reply: ");
        int i;
        for(i = 0; i < transferred; ++i) {
                LOG("%02X ", ((unsigned char*)(&buffer))[i]);
        }
        LOG("\n");
        LOG("Reading reply: ");
        int i;
        for(i = 0; i < transferred; ++i) {
                LOG("%02X ", ((unsigned char*)(&buffer))[i]);
        }
        LOG("\n");
-       
+
        return res;
 }
 
        return res;
 }
 
@@ -155,7 +154,7 @@ int main(int argc, char** argv) {
 
        res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
        if(res != 0 || transferred != sizeof(cmd)) {
 
        res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
        if(res != 0 || transferred != sizeof(cmd)) {
-               LOG("Error: res: %d\ttransferred: %d (expected %d)\n",res, transferred, sizeof(cmd));
+               LOG("Error: res: %d\ttransferred: %d (expected %lu)\n",res, transferred, sizeof(cmd));
                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.
@@ -163,7 +162,7 @@ int main(int argc, char** argv) {
        seq++;
 
        uint32_t addr = 0x00080000;
        seq++;
 
        uint32_t addr = 0x00080000;
-       char page[0x4000];
+       unsigned char page[0x4000];
        int read;
        do {
                read = fread(page, 1, 0x4000, fw);
        int read;
        do {
                read = fread(page, 1, 0x4000, fw);
@@ -180,7 +179,7 @@ int main(int argc, char** argv) {
                // Send it off!
                res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
                if(res != 0 || transferred != sizeof(cmd)) {
                // Send it off!
                res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
                if(res != 0 || transferred != sizeof(cmd)) {
-                       LOG("Error: res: %d\ttransferred: %d (expected %d)\n",res, transferred, sizeof(cmd));
+                       LOG("Error: res: %d\ttransferred: %d (expected %lu)\n",res, transferred, sizeof(cmd));
                        goto cleanup;
                }
                int bytes_sent = 0;
                        goto cleanup;
                }
                int bytes_sent = 0;
@@ -206,16 +205,15 @@ int main(int argc, char** argv) {
        dump_bl_cmd(cmd);
        res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
        if(res != 0 || transferred != sizeof(cmd)) {
        dump_bl_cmd(cmd);
        res = libusb_bulk_transfer(dev, 1, (unsigned char*)&cmd, sizeof(cmd), &transferred, 0);
        if(res != 0 || transferred != sizeof(cmd)) {
-               LOG("Error: res: %d\ttransferred: %d (expected %d)\n", res, transferred, sizeof(cmd));
+               LOG("Error: res: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(cmd));
                goto cleanup;
        }
        res = get_reply();
        seq++;
        // Now the device reenumerates.
                goto cleanup;
        }
        res = get_reply();
        seq++;
        // Now the device reenumerates.
-       
+
 cleanup:
        libusb_close(dev);
        libusb_exit(NULL);
        return 0;
 }
 cleanup:
        libusb_close(dev);
        libusb_exit(NULL);
        return 0;
 }
-