Fix malloc debugging for LP64.

Change-Id: Idd0b239f5c66d45de315d556271a5d13b8eb907c
diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp
index 11a6ec1..a5d49cb 100644
--- a/libc/bionic/malloc_debug_check.cpp
+++ b/libc/bionic/malloc_debug_check.cpp
@@ -85,11 +85,11 @@
     uintptr_t freed_bt[MAX_BACKTRACE_DEPTH];
     int freed_bt_depth;
     size_t size;
-    char front_guard[FRONT_GUARD_LEN];
+    uint8_t front_guard[FRONT_GUARD_LEN];
 } __attribute__((packed, aligned(MALLOC_ALIGNMENT)));
 
 struct ftr_t {
-    char rear_guard[REAR_GUARD_LEN];
+    uint8_t rear_guard[REAR_GUARD_LEN];
 } __attribute__((packed));
 
 static inline ftr_t* to_ftr(hdr_t* hdr) {
@@ -126,10 +126,10 @@
 static inline bool is_front_guard_valid(hdr_t* hdr) {
     for (size_t i = 0; i < FRONT_GUARD_LEN; i++) {
         if (hdr->front_guard[i] != FRONT_GUARD) {
-            return 0;
+            return false;
         }
     }
-    return 1;
+    return true;
 }
 
 static inline void init_rear_guard(hdr_t* hdr) {
@@ -207,13 +207,14 @@
     memset(user(hdr), FREE_POISON, hdr->size);
 }
 
-static int was_used_after_free(hdr_t* hdr) {
-    unsigned i;
-    const char* data = reinterpret_cast<const char *>(user(hdr));
-    for (i = 0; i < hdr->size; i++)
-        if (data[i] != FREE_POISON)
-            return 1;
-    return 0;
+static bool was_used_after_free(hdr_t* hdr) {
+    const uint8_t* data = reinterpret_cast<const uint8_t*>(user(hdr));
+    for (size_t i = 0; i < hdr->size; i++) {
+        if (data[i] != FREE_POISON) {
+            return true;
+        }
+    }
+    return false;
 }
 
 /* returns 1 if valid, *safe == 1 if safe to dump stack */
diff --git a/libc/bionic/malloc_debug_qemu.cpp b/libc/bionic/malloc_debug_qemu.cpp
index 1f64aa8..4d00066 100644
--- a/libc/bionic/malloc_debug_qemu.cpp
+++ b/libc/bionic/malloc_debug_qemu.cpp
@@ -394,9 +394,9 @@
  *  code - Event code (one of the TRACE_DEV_XXX).
  *  val  - Event's value parameter.
  */
-static inline void notify_qemu(uint32_t code, uint32_t val) {
+static inline void notify_qemu(uint32_t code, uintptr_t val) {
     if (NULL != qtrace) {
-        *(volatile uint32_t*)((uint32_t)qtrace + ((code - 1024) << 2)) = val;
+        *(volatile uintptr_t*)((uintptr_t)qtrace + ((code - 1024) << 2)) = val;
     }
 }
 
@@ -407,7 +407,7 @@
  */
 static void notify_qemu_string(const char* str) {
     if (str != NULL) {
-        notify_qemu(TRACE_DEV_REG_PRINT_USER_STR, (uint32_t)str);
+        notify_qemu(TRACE_DEV_REG_PRINT_USER_STR, reinterpret_cast<uintptr_t>(str));
     }
 }
 
@@ -432,7 +432,7 @@
     desc->libc_pid = malloc_pid;
     desc->allocator_pid = getpid();
     desc->av_count = 0;
-    notify_qemu(TRACE_DEV_REG_MALLOC, (uint32_t)desc);
+    notify_qemu(TRACE_DEV_REG_MALLOC, reinterpret_cast<uintptr_t>(desc));
 
     /* Emulator reports failure by zeroing libc_pid field of the
      * descriptor. */
@@ -451,7 +451,7 @@
     free_desc.ptr = ptr_to_free;
     free_desc.libc_pid = malloc_pid;
     free_desc.free_pid = getpid();
-    notify_qemu(TRACE_DEV_REG_FREE_PTR, (uint32_t)&free_desc);
+    notify_qemu(TRACE_DEV_REG_FREE_PTR, reinterpret_cast<uintptr_t>(&free_desc));
 
     /* Emulator reports failure by zeroing libc_pid field of the
      * descriptor. */
@@ -477,7 +477,7 @@
     query.query_pid = getpid();
     query.routine = routine;
     query.desc = desc;
-    notify_qemu(TRACE_DEV_REG_QUERY_MALLOC, (uint32_t)&query);
+    notify_qemu(TRACE_DEV_REG_QUERY_MALLOC, reinterpret_cast<uintptr_t>(&query));
 
     /* Emulator reports failure by zeroing libc_pid field of the
      * descriptor. */
@@ -534,11 +534,11 @@
 static void dump_malloc_descriptor(char* str, size_t str_buf_size, const MallocDesc* desc) {
     if (str_buf_size) {
         snprintf(str, str_buf_size,
-            "MDesc: %p: %X <-> %X [%u + %u + %u] by pid=%03u in libc_pid=%03u",
-            mallocdesc_user_ptr(desc), (uint32_t)desc->ptr,
-            (uint32_t)mallocdesc_alloc_end(desc), desc->prefix_size,
-            desc->requested_bytes, desc->suffix_size, desc->allocator_pid,
-            desc->libc_pid);
+                 "MDesc: %p: %p <-> %p [%u + %u + %u] by pid=%03u in libc_pid=%03u",
+                 mallocdesc_user_ptr(desc), desc->ptr,
+                 mallocdesc_alloc_end(desc), desc->prefix_size,
+                 desc->requested_bytes, desc->suffix_size, desc->allocator_pid,
+                 desc->libc_pid);
         str[str_buf_size - 1] = '\0';
     }
 }