Fixing cpplint readability/casting issues

Change-Id: I6821da0e23737995a9b884a04e9b63fac640cd05
diff --git a/runtime/atomic.cc b/runtime/atomic.cc
index f2a9982..c91db79 100644
--- a/runtime/atomic.cc
+++ b/runtime/atomic.cc
@@ -34,7 +34,7 @@
 static std::vector<Mutex*>* gSwapMutexes;
 
 static Mutex& GetSwapMutex(const volatile int64_t* addr) {
-  return *(*gSwapMutexes)[((unsigned)(void*)(addr) >> 3U) % kSwapMutexCount];
+  return *(*gSwapMutexes)[(reinterpret_cast<unsigned>(addr) >> 3U) % kSwapMutexCount];
 }
 #endif
 
diff --git a/runtime/base/histogram-inl.h b/runtime/base/histogram-inl.h
index d572cf9..1a63cf4 100644
--- a/runtime/base/histogram-inl.h
+++ b/runtime/base/histogram-inl.h
@@ -66,7 +66,7 @@
   // dividing the value by the bucket width.
   DCHECK_GE(val, min_);
   DCHECK_LE(val, max_);
-  size_t bucket_idx = static_cast<size_t>((double)(val - min_) / bucket_width_);
+  size_t bucket_idx = static_cast<size_t>(static_cast<double>(val - min_) / bucket_width_);
   DCHECK_GE(bucket_idx, 0ul);
   DCHECK_LE(bucket_idx, bucket_count_);
   return bucket_idx;
diff --git a/runtime/common_test.h b/runtime/common_test.h
index 778ca63..03a45aa 100644
--- a/runtime/common_test.h
+++ b/runtime/common_test.h
@@ -508,7 +508,8 @@
   void ReserveImageSpace() {
     // Reserve where the image will be loaded up front so that other parts of test set up don't
     // accidentally end up colliding with the fixed memory address when we need to load the image.
-    image_reservation_.reset(MemMap::MapAnonymous("image reservation", (byte*)ART_BASE_ADDRESS,
+    image_reservation_.reset(MemMap::MapAnonymous("image reservation",
+                                                  reinterpret_cast<byte*>(ART_BASE_ADDRESS),
                                                   (size_t)100 * 1024 * 1024,  // 100MB
                                                   PROT_NONE));
   }
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 4fbee51..9e9dd87 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -3281,7 +3281,7 @@
             const size_t kMaxFreeLen = 2 * kPageSize;
             void* freeStart = startOfNextMemoryChunk_;
             void* freeEnd = start;
-            size_t freeLen = (char*)freeEnd - (char*)freeStart;
+            size_t freeLen = reinterpret_cast<char*>(freeEnd) - reinterpret_cast<char*>(freeStart);
             if (!native || freeLen < kMaxFreeLen) {
                 AppendChunk(HPSG_STATE(SOLIDITY_FREE, 0), freeStart, freeLen);
                 flush = false;
@@ -3302,7 +3302,7 @@
     // allocation then the first sizeof(size_t) may belong to it.
     const size_t dlMallocOverhead = sizeof(size_t);
     AppendChunk(state, start, used_bytes + dlMallocOverhead);
-    startOfNextMemoryChunk_ = (char*)start + used_bytes + dlMallocOverhead;
+    startOfNextMemoryChunk_ = reinterpret_cast<char*>(start) + used_bytes + dlMallocOverhead;
   }
 
   void AppendChunk(uint8_t state, void* ptr, size_t length)
diff --git a/runtime/debugger.h b/runtime/debugger.h
index 28a2c60..9005fda 100644
--- a/runtime/debugger.h
+++ b/runtime/debugger.h
@@ -417,7 +417,7 @@
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
  private:
-  static void DdmBroadcast(bool) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+  static void DdmBroadcast(bool connect) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
   static void PostThreadStartOrStop(Thread*, uint32_t)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 170915d..341b62f 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -315,7 +315,7 @@
   size_t total_objects_allocated = GetObjectsAllocatedEver();
   size_t total_bytes_allocated = GetBytesAllocatedEver();
   if (total_duration != 0) {
-    const double total_seconds = double(total_duration / 1000) / 1000000.0;
+    const double total_seconds = static_cast<double>(total_duration / 1000) / 1000000.0;
     os << "Total time spent in GC: " << PrettyDuration(total_duration) << "\n";
     os << "Mean GC size throughput: "
        << PrettySize(GetBytesFreedEver() / total_seconds) << "/s\n";
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc
index d66ec79..3c8099a 100644
--- a/runtime/hprof/hprof.cc
+++ b/runtime/hprof/hprof.cc
@@ -72,7 +72,7 @@
 #define U2_TO_BUF_BE(buf, offset, value) \
     do { \
       unsigned char* buf_ = (unsigned char*)(buf); \
-      int offset_ = (int)(offset); \
+      int offset_ = static_cast<int>(offset); \
       uint16_t value_ = (uint16_t)(value); \
       buf_[offset_ + 0] = (unsigned char)(value_ >>  8); \
       buf_[offset_ + 1] = (unsigned char)(value_      ); \
@@ -81,7 +81,7 @@
 #define U4_TO_BUF_BE(buf, offset, value) \
     do { \
       unsigned char* buf_ = (unsigned char*)(buf); \
-      int offset_ = (int)(offset); \
+      int offset_ = static_cast<int>(offset); \
       uint32_t value_ = (uint32_t)(value); \
       buf_[offset_ + 0] = (unsigned char)(value_ >> 24); \
       buf_[offset_ + 1] = (unsigned char)(value_ >> 16); \
@@ -92,7 +92,7 @@
 #define U8_TO_BUF_BE(buf, offset, value) \
     do { \
       unsigned char* buf_ = (unsigned char*)(buf); \
-      int offset_ = (int)(offset); \
+      int offset_ = static_cast<int>(offset); \
       uint64_t value_ = (uint64_t)(value); \
       buf_[offset_ + 0] = (unsigned char)(value_ >> 56); \
       buf_[offset_ + 1] = (unsigned char)(value_ >> 48); \
@@ -222,7 +222,7 @@
         return UNIQUE_ERROR;
       }
       nb = fwrite(body_, 1, length_, fp_);
-      if (nb != (int)length_) {
+      if (nb != static_cast<int>(length_)) {
         return UNIQUE_ERROR;
       }
 
@@ -984,9 +984,9 @@
         if (size == 1) {
           rec->AddU1List((const uint8_t*)aobj->GetRawData(sizeof(uint8_t)), length);
         } else if (size == 2) {
-          rec->AddU2List((const uint16_t*)(void*)aobj->GetRawData(sizeof(uint16_t)), length);
+          rec->AddU2List((const uint16_t*)aobj->GetRawData(sizeof(uint16_t)), length);
         } else if (size == 4) {
-          rec->AddU4List((const uint32_t*)(void*)aobj->GetRawData(sizeof(uint32_t)), length);
+          rec->AddU4List((const uint32_t*)aobj->GetRawData(sizeof(uint32_t)), length);
         } else if (size == 8) {
           rec->AddU8List((const uint64_t*)aobj->GetRawData(sizeof(uint64_t)), length);
         }
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 8598d6d..bbd2052 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -473,7 +473,7 @@
   size_t frame_id = StackVisitor::ComputeNumFrames(self);
   std::deque<instrumentation::InstrumentationStackFrame>* stack = self->GetInstrumentationStack();
   if (kVerboseInstrumentation) {
-    LOG(INFO) << "Entering " << PrettyMethod(method) << " from PC " << (void*)lr;
+    LOG(INFO) << "Entering " << PrettyMethod(method) << " from PC " << reinterpret_cast<void*>(lr);
   }
   instrumentation::InstrumentationStackFrame instrumentation_frame(this_object, method, lr,
                                                                    frame_id, interpreter_entry);
@@ -530,7 +530,8 @@
         (static_cast<uint64_t>(*return_pc) << 32);
   } else {
     if (kVerboseInstrumentation) {
-      LOG(INFO) << "Returning from " << PrettyMethod(method) << " to PC " << (void*)(*return_pc);
+      LOG(INFO) << "Returning from " << PrettyMethod(method)
+                << " to PC " << reinterpret_cast<void*>(*return_pc);
     }
     return *return_pc;
   }
diff --git a/runtime/jdwp/jdwp_adb.cc b/runtime/jdwp/jdwp_adb.cc
index 9b9fe4c..2bfe63e 100644
--- a/runtime/jdwp/jdwp_adb.cc
+++ b/runtime/jdwp/jdwp_adb.cc
@@ -157,7 +157,7 @@
   cmsg->cmsg_len   = msg.msg_controllen;
   cmsg->cmsg_level = SOL_SOCKET;
   cmsg->cmsg_type  = SCM_RIGHTS;
-  ((int*)(void*)CMSG_DATA(cmsg))[0] = -1;
+  (reinterpret_cast<int*>(CMSG_DATA(cmsg)))[0] = -1;
 
   int rc = TEMP_FAILURE_RETRY(recvmsg(control_sock_, &msg, 0));
 
@@ -170,7 +170,7 @@
     return -1;
   }
 
-  return ((int*)(void*)CMSG_DATA(cmsg))[0];
+  return (reinterpret_cast<int*>(CMSG_DATA(cmsg)))[0];
 }
 
 /*
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index c75dffa..a0f389c 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -192,7 +192,8 @@
    * (The address must be page-aligned, the length doesn't need to be,
    * but we do need to ensure we cover the same range.)
    */
-  uint8_t* alignAddr = (uint8_t*) ((uintptr_t) addr & ~(kPageSize-1));
+  uint8_t* alignAddr = reinterpret_cast<uint8_t*>(RoundDown(reinterpret_cast<uintptr_t>(addr),
+                                                            kPageSize));
   size_t alignLength = length + (addr - alignAddr);
 
   if (mprotect(alignAddr, alignLength, prot) == 0) {
diff --git a/runtime/native/java_lang_System.cc b/runtime/native/java_lang_System.cc
index 2462f2f..30b4dc7 100644
--- a/runtime/native/java_lang_System.cc
+++ b/runtime/native/java_lang_System.cc
@@ -123,7 +123,7 @@
 
     // Check for leftovers.  Either we finished exactly, or we have one remaining 16-bit chunk.
     if ((n & 0x02) != 0) {
-      *(uint16_t*)d = *(uint16_t*)s;
+      *reinterpret_cast<uint16_t*>(d) = *reinterpret_cast<const uint16_t*>(s);
     }
   } else {
     // Copy backward, starting at the end.
diff --git a/runtime/thread_x86.cc b/runtime/thread_x86.cc
index 959f317..c398b28 100644
--- a/runtime/thread_x86.cc
+++ b/runtime/thread_x86.cc
@@ -73,7 +73,7 @@
   entry.d = seg_32bit;
   entry.g = limit_in_pages;
 
-  entry_number = i386_set_ldt(LDT_AUTO_ALLOC, (ldt_entry*)(void*)(&entry), 1);
+  entry_number = i386_set_ldt(LDT_AUTO_ALLOC, reinterpret_cast<ldt_entry*>(&entry), 1);
   if (entry_number == -1) {
     PLOG(FATAL) << "i386_set_ldt failed";
   }