From 833744083efbcdfdf3bad938f76e5ca9388d9cac Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 30 Sep 2011 23:00:42 +0200 Subject: [PATCH] kinect_upload_fw: really fix -Wformat warnings about sizeof() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Use "%zu" when printing the result of a sizeof(), this way the integer conversion is done correctly taking into account the particular architecture. On a PPC64 (PlayStation 3) we were getting: kinect_upload_fw.c: In function ‘get_reply’: kinect_upload_fw.c:99:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat] kinect_upload_fw.c: In function ‘main’: kinect_upload_fw.c:169:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat] kinect_upload_fw.c:194:4: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat] kinect_upload_fw.c:220:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat] --- kinect_upload_fw/kinect_upload_fw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kinect_upload_fw/kinect_upload_fw.c b/kinect_upload_fw/kinect_upload_fw.c index 5cf1abb..f9a1952 100644 --- a/kinect_upload_fw/kinect_upload_fw.c +++ b/kinect_upload_fw/kinect_upload_fw.c @@ -96,7 +96,7 @@ static int get_reply(void) { res = libusb_bulk_transfer(dev, 0x81, reply.dump, 512, &transferred, 0); if (res != 0 || transferred != sizeof(status_code)) { - LOG("Error reading reply: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(status_code)); + LOG("Error reading reply: %d\ttransferred: %d (expected %zu)\n", res, transferred, sizeof(status_code)); return res; } if (fn_le32(reply.buffer.magic) != 0x0a6fe000) { @@ -166,7 +166,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)) { - LOG("Error: res: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(cmd)); + LOG("Error: res: %d\ttransferred: %d (expected %zu)\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. @@ -191,7 +191,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)) { - LOG("Error: res: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(cmd)); + LOG("Error: res: %d\ttransferred: %d (expected %zu)\n", res, transferred, sizeof(cmd)); goto cleanup; } int bytes_sent = 0; @@ -217,7 +217,7 @@ 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)) { - LOG("Error: res: %d\ttransferred: %d (expected %lu)\n", res, transferred, sizeof(cmd)); + LOG("Error: res: %d\ttransferred: %d (expected %zu)\n", res, transferred, sizeof(cmd)); goto cleanup; } res = get_reply(); -- 2.1.4