system/core 64-bit cleanup.

This cleans up most of the size-related problems in system/core.
There are still a few changes needed for a clean 64-bit build,
but they look like they might require changes to things like the
fastboot protocol.

Change-Id: I1560425a289fa158e13e2e3173cc3e71976f92c0
diff --git a/fastbootd/commands.c b/fastbootd/commands.c
index d8a601f..063e1a6 100644
--- a/fastbootd/commands.c
+++ b/fastbootd/commands.c
@@ -29,6 +29,7 @@
  * SUCH DAMAGE.
  */
 
+#include <inttypes.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -319,7 +320,7 @@
         return;
     }
 
-    D(INFO, "writing %lld bytes to '%s'\n", sz, arg);
+    D(INFO, "writing %"PRId64" bytes to '%s'\n", sz, arg);
 
     if (flash_write(partition, phandle->download_fd, sz, header_sz)) {
         fastboot_fail(phandle, "flash write failure");
diff --git a/fastbootd/commands/flash.c b/fastbootd/commands/flash.c
index 0954217..1eb4d1b 100644
--- a/fastbootd/commands/flash.c
+++ b/fastbootd/commands/flash.c
@@ -31,6 +31,7 @@
 
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <inttypes.h>
 #include <sys/mman.h>
 
 #include "flash.h"
@@ -82,7 +83,7 @@
 {
     int64_t size;
     size = get_block_device_size(fd);
-    D(DEBUG, "erase %llu data from %d\n", size, fd);
+    D(DEBUG, "erase %"PRId64" data from %d\n", size, fd);
 
     return wipe_block_device(fd, size);
 }
@@ -97,7 +98,7 @@
         int current_size = MIN(size - written, BUFFER_SIZE);
 
         if (gpt_mmap(&input, written + skip, current_size, data_fd)) {
-            D(ERR, "Error in writing data, unable to map data file %d at %d size %d", size, skip, current_size);
+            D(ERR, "Error in writing data, unable to map data file %zd at %zd size %d", size, skip, current_size);
             return -1;
         }
         if (gpt_mmap(&output, written, current_size, partition_fd)) {
diff --git a/fastbootd/secure.c b/fastbootd/secure.c
index a657ad4..186e026 100644
--- a/fastbootd/secure.c
+++ b/fastbootd/secure.c
@@ -151,7 +151,7 @@
         char buf[256];
         unsigned long err = ERR_peek_last_error();
         D(ERR, "Verification failed with reason: %s, %s", ERR_lib_error_string(err),  ERR_error_string(err, buf));
-        D(ERR, "Data used: content %d", (int) content);
+        D(ERR, "Data used: content %p", content);
     }
 
     ERR_clear_error();
diff --git a/fastbootd/transport.c b/fastbootd/transport.c
index 19a705c..ce8f9d0 100644
--- a/fastbootd/transport.c
+++ b/fastbootd/transport.c
@@ -56,14 +56,14 @@
 
     buffer = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
     if (buffer == NULL) {
-        D(ERR, "mmap(%u) failed: %d %s", len, errno, strerror(errno));
+        D(ERR, "mmap(%zu) failed: %d %s", len, errno, strerror(errno));
         goto err;
     }
 
     while (n < len) {
         ret = thandle->transport->read(thandle, buffer + n, len - n);
         if (ret <= 0) {
-            D(WARN, "transport read failed, ret=%d %s", ret, strerror(-ret));
+            D(WARN, "transport read failed, ret=%zd %s", ret, strerror(-ret));
             break;
         }
         n += ret;
diff --git a/fastbootd/transport_socket.c b/fastbootd/transport_socket.c
index ff0f3bd..664d473 100644
--- a/fastbootd/transport_socket.c
+++ b/fastbootd/transport_socket.c
@@ -88,7 +88,7 @@
     ssize_t ret;
     struct socket_handle *handle = container_of(thandle, struct socket_handle, handle);
 
-    D(DEBUG, "about to write (fd=%d, len=%d)", handle->fd, len);
+    D(DEBUG, "about to write (fd=%d, len=%zu)", handle->fd, len);
     ret = bulk_write(handle->fd, data, len);
     if (ret < 0) {
         D(ERR, "ERROR: fd = %d, ret = %zd", handle->fd, ret);
@@ -103,7 +103,7 @@
     ssize_t ret;
     struct socket_handle *handle = container_of(thandle, struct socket_handle, handle);
 
-    D(DEBUG, "about to read (fd=%d, len=%d)", handle->fd, len);
+    D(DEBUG, "about to read (fd=%d, len=%zu)", handle->fd, len);
     ret = bulk_read(handle->fd, data, len);
     if (ret < 0) {
         D(ERR, "ERROR: fd = %d, ret = %zd", handle->fd, ret);
diff --git a/fastbootd/usb_linux_client.c b/fastbootd/usb_linux_client.c
index 7a8e46f..64420e9 100644
--- a/fastbootd/usb_linux_client.c
+++ b/fastbootd/usb_linux_client.c
@@ -217,7 +217,7 @@
     struct transport *t = thandle->transport;
     struct usb_transport *usb_transport = container_of(t, struct usb_transport, transport);
 
-    D(DEBUG, "about to write (fd=%d, len=%d)", usb_transport->bulk_in, len);
+    D(DEBUG, "about to write (fd=%d, len=%zu)", usb_transport->bulk_in, len);
     ret = bulk_write(usb_transport->bulk_in, data, len);
     if (ret < 0) {
         D(ERR, "ERROR: fd = %d, ret = %zd", usb_transport->bulk_in, ret);
@@ -233,7 +233,7 @@
     struct transport *t = thandle->transport;
     struct usb_transport *usb_transport = container_of(t, struct usb_transport, transport);
 
-    D(DEBUG, "about to read (fd=%d, len=%d)", usb_transport->bulk_out, len);
+    D(DEBUG, "about to read (fd=%d, len=%zu)", usb_transport->bulk_out, len);
     ret = bulk_read(usb_transport->bulk_out, data, len);
     if (ret < 0) {
         D(ERR, "ERROR: fd = %d, ret = %zd", usb_transport->bulk_out, ret);