diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/atomic.cc | 4 | ||||
-rw-r--r-- | src/card_table.cc | 3 | ||||
-rw-r--r-- | src/card_table.h | 2 | ||||
-rw-r--r-- | src/compiler.cc | 2 | ||||
-rw-r--r-- | src/dex_verifier.cc | 27 | ||||
-rw-r--r-- | src/logging.cc | 21 | ||||
-rw-r--r-- | src/macros.h | 8 | ||||
-rw-r--r-- | src/mark_sweep.cc | 11 | ||||
-rw-r--r-- | src/monitor.cc | 14 | ||||
-rw-r--r-- | src/monitor_android.cc | 4 | ||||
-rw-r--r-- | src/object.cc | 2 | ||||
-rw-r--r-- | src/runtime.cc | 6 | ||||
-rw-r--r-- | src/stringprintf.cc | 2 | ||||
-rw-r--r-- | src/thread.cc | 2 | ||||
-rw-r--r-- | src/thread_list.cc | 2 | ||||
-rw-r--r-- | src/thread_list.h | 2 | ||||
-rw-r--r-- | src/utils.cc | 2 |
17 files changed, 59 insertions, 55 deletions
diff --git a/src/atomic.cc b/src/atomic.cc index e5c10e4..0f4ff91 100644 --- a/src/atomic.cc +++ b/src/atomic.cc @@ -148,10 +148,10 @@ int64_t QuasiAtomicRead64(volatile const int64_t* addr) { #include <pthread.h> -#define SWAP_LOCK_COUNT 32U +#define SWAP_LOCK_COUNT 32U static pthread_mutex_t _swap_locks[SWAP_LOCK_COUNT]; -#define SWAP_LOCK(addr) &_swap_locks[((unsigned)(void*)(addr) >> 3U) % SWAP_LOCK_COUNT] +#define SWAP_LOCK(addr) &_swap_locks[(reinterpret_cast<unsigned>(reinterpret_cast<void*>(addr)) >> 3U) % SWAP_LOCK_COUNT] int64_t QuasiAtomicSwap64(int64_t value, volatile int64_t* addr) { pthread_mutex_t* lock = SWAP_LOCK(addr); diff --git a/src/card_table.cc b/src/card_table.cc index dc61c0a..d442306 100644 --- a/src/card_table.cc +++ b/src/card_table.cc @@ -68,7 +68,8 @@ CardTable* CardTable::Create(const byte* heap_begin, size_t heap_capacity) { // We allocated up to a bytes worth of extra space to allow biased_begin's byte value to equal // GC_CARD_DIRTY, compute a offset value to make this the case size_t offset = 0; - byte* biased_begin = (byte *)((uintptr_t)cardtable_begin -((uintptr_t)heap_begin >> GC_CARD_SHIFT)); + byte* biased_begin = reinterpret_cast<byte*>(reinterpret_cast<uintptr_t>(cardtable_begin) - + (reinterpret_cast<uintptr_t>(heap_begin) >> GC_CARD_SHIFT)); if (((uintptr_t)biased_begin & 0xff) != GC_CARD_DIRTY) { int delta = GC_CARD_DIRTY - (reinterpret_cast<int>(biased_begin) & 0xff); offset = delta + (delta < 0 ? 0x100 : 0); diff --git a/src/card_table.h b/src/card_table.h index ea0504a..70d033e 100644 --- a/src/card_table.h +++ b/src/card_table.h @@ -85,7 +85,7 @@ class CardTable { void* AddrFromCard(const byte *cardAddr) const { DCHECK(IsValidCard(cardAddr)); uintptr_t offset = cardAddr - biased_begin_; - return (void *)(offset << GC_CARD_SHIFT); + return reinterpret_cast<void*>(offset << GC_CARD_SHIFT); } // Returns true iff the card table address is within the bounds of the card table. diff --git a/src/compiler.cc b/src/compiler.cc index 6cdb6ee..0eb4301 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -54,7 +54,7 @@ namespace x86 { } static double Percentage(size_t x, size_t y) { - return 100.0 * ((double)x) / ((double)(x + y)); + return 100.0 * (static_cast<double>(x)) / (static_cast<double>(x + y)); } static void DumpStat(size_t x, size_t y, const char* str) { diff --git a/src/dex_verifier.cc b/src/dex_verifier.cc index 448f3b7..987777c 100644 --- a/src/dex_verifier.cc +++ b/src/dex_verifier.cc @@ -1469,7 +1469,7 @@ bool DexVerifier::CheckArrayData(uint32_t cur_offset) { return false; } uint32_t value_width = array_data[1]; - uint32_t value_count = *(uint32_t*) (&array_data[2]); + uint32_t value_count = *reinterpret_cast<const uint32_t*>(&array_data[2]); uint32_t table_size = 4 + (value_width * value_count + 1) / 2; /* make sure the end of the switch is in range */ if (cur_offset + array_data_offset + table_size > insn_count) { @@ -1489,20 +1489,21 @@ bool DexVerifier::CheckBranchTarget(uint32_t cur_offset) { return false; } if (!selfOkay && offset == 0) { - Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "branch offset of zero not allowed at" << (void*) cur_offset; + Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "branch offset of zero not allowed at" << reinterpret_cast<void*>(cur_offset); return false; } // Check for 32-bit overflow. This isn't strictly necessary if we can depend on the runtime // to have identical "wrap-around" behavior, but it's unwise to depend on that. if (((int64_t) cur_offset + (int64_t) offset) != (int64_t) (cur_offset + offset)) { - Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "branch target overflow " << (void*) cur_offset << " +" << offset; + Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "branch target overflow " << reinterpret_cast<void*>(cur_offset) << " +" << offset; return false; } const uint32_t insn_count = code_item_->insns_size_in_code_units_; int32_t abs_offset = cur_offset + offset; if (abs_offset < 0 || (uint32_t) abs_offset >= insn_count || !insn_flags_[abs_offset].IsOpcode()) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "invalid branch target " << offset << " (-> " - << (void*) abs_offset << ") at " << (void*) cur_offset; + << reinterpret_cast<void*>(abs_offset) << ") at " + << reinterpret_cast<void*>(cur_offset); return false; } insn_flags_[abs_offset].SetBranchTarget(); @@ -1615,8 +1616,8 @@ bool DexVerifier::CheckSwitchTargets(uint32_t cur_offset) { int32_t abs_offset = cur_offset + offset; if (abs_offset < 0 || abs_offset >= (int32_t) insn_count || !insn_flags_[abs_offset].IsOpcode()) { Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "invalid switch target " << offset << " (-> " - << (void*) abs_offset << ") at " - << (void*) cur_offset << "[" << targ << "]"; + << reinterpret_cast<void*>(abs_offset) << ") at " + << reinterpret_cast<void*>(cur_offset) << "[" << targ << "]"; return false; } insn_flags_[abs_offset].SetBranchTarget(); @@ -1924,9 +1925,9 @@ bool DexVerifier::CodeFlowVerifyMethod() { Dump(std::cout); std::cout << info_messages_.str(); LOG(FATAL) << "work_line diverged in " << PrettyMethod(method_) - << "@" << (void*)work_insn_idx_ << std::endl - << " work_line=" << *work_line_ << std::endl - << " expected=" << *register_line; + << "@" << reinterpret_cast<void*>(work_insn_idx_) << std::endl + << " work_line=" << *work_line_ << std::endl + << " expected=" << *register_line; } } #endif @@ -1970,12 +1971,12 @@ bool DexVerifier::CodeFlowVerifyMethod() { if (dead_start < 0) dead_start = insn_idx; } else if (dead_start >= 0) { - LogVerifyInfo() << "dead code " << (void*) dead_start << "-" << (void*) (insn_idx - 1); + LogVerifyInfo() << "dead code " << reinterpret_cast<void*>(dead_start) << "-" << reinterpret_cast<void*>(insn_idx - 1); dead_start = -1; } } if (dead_start >= 0) { - LogVerifyInfo() << "dead code " << (void*) dead_start << "-" << (void*) (insn_idx - 1); + LogVerifyInfo() << "dead code " << reinterpret_cast<void*>(dead_start) << "-" << reinterpret_cast<void*>(insn_idx - 1); } } return true; @@ -3880,8 +3881,8 @@ bool DexVerifier::UpdateRegisters(uint32_t next_insn, const RegisterLine* merge_ return false; } if (gDebugVerify && changed) { - LogVerifyInfo() << "Merging at [" << (void*)work_insn_idx_ << "]" - " to [" <<(void*)next_insn << "]: " << std::endl + LogVerifyInfo() << "Merging at [" << reinterpret_cast<void*>(work_insn_idx_) << "]" + << " to [" << reinterpret_cast<void*>(next_insn) << "]: " << std::endl << *copy.get() << " MERGE" << std::endl << *merge_line << " ==" << std::endl << *target_line << std::endl; diff --git a/src/logging.cc b/src/logging.cc index 18fe99b..813fa9a 100644 --- a/src/logging.cc +++ b/src/logging.cc @@ -79,7 +79,7 @@ void HexDump(const void* address, size_t byte_count, bool show_actual_address) { unsigned int offset; /* offset to show while printing */ if (show_actual_address) { - offset = (int) addr; + offset = reinterpret_cast<int>(addr); } else { offset = 0; } @@ -87,22 +87,21 @@ void HexDump(const void* address, size_t byte_count, bool show_actual_address) { out[8] = ':'; out[sizeof(out)-1] = '\0'; - int gap = (int) offset & 0x0f; + int gap = static_cast<int>(offset & 0x0f); while (byte_count) { unsigned int lineOffset = offset & ~0x0f; - int i, count; char* hex = out; char* asc = out + 59; - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { *hex++ = gHexDigit[lineOffset >> 28]; lineOffset <<= 4; } hex++; hex++; - count = ((int)byte_count > 16-gap) ? 16-gap : (int)byte_count; /* cap length */ + int count = std::min(static_cast<int>(byte_count), 16 - gap); CHECK_NE(count, 0); CHECK_LE(count + gap, 16); @@ -112,17 +111,19 @@ void HexDump(const void* address, size_t byte_count, bool show_actual_address) { asc += gap; } + int i; for (i = gap ; i < count+gap; i++) { *hex++ = gHexDigit[*addr >> 4]; *hex++ = gHexDigit[*addr & 0x0f]; hex++; - if (*addr >= 0x20 && *addr < 0x7f /*isprint(*addr)*/) - *asc++ = *addr; - else - *asc++ = '.'; + if (*addr >= 0x20 && *addr < 0x7f /*isprint(*addr)*/) { + *asc++ = *addr; + } else { + *asc++ = '.'; + } addr++; } - for ( ; i < 16; i++) { + for (; i < 16; i++) { /* erase extra stuff; only happens on last line */ *hex++ = ' '; *hex++ = ' '; diff --git a/src/macros.h b/src/macros.h index 1800dea..8fb4599 100644 --- a/src/macros.h +++ b/src/macros.h @@ -41,7 +41,7 @@ struct CompileAssert { }; #define COMPILE_ASSERT(expr, msg) \ - typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] + typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] // NOLINT // DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions. // It goes in the private: declarations in a class. @@ -120,10 +120,10 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; #define SIZEOF_MEMBER(t, f) sizeof((reinterpret_cast<t*>(4096))->f) #define OFFSETOF_MEMBER(t, f) \ - (reinterpret_cast<char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<char*>(16)) + (reinterpret_cast<char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<char*>(16)) // NOLINT #define OFFSETOF_VOLATILE_MEMBER(t, f) \ - (reinterpret_cast<volatile char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<volatile char*>(16)) + (reinterpret_cast<volatile char*>(&reinterpret_cast<t*>(16)->f) - reinterpret_cast<volatile char*>(16)) // NOLINT #define PACKED __attribute__ ((__packed__)) @@ -133,7 +133,7 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; // bionic and glibc both have TEMP_FAILURE_RETRY, but Mac OS' libc doesn't. #ifndef TEMP_FAILURE_RETRY #define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ + typeof(exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ diff --git a/src/mark_sweep.cc b/src/mark_sweep.cc index 3740d91..381c7f0 100644 --- a/src/mark_sweep.cc +++ b/src/mark_sweep.cc @@ -300,13 +300,14 @@ inline void MarkSweep::CheckReference(const Object* obj, const Object* ref, Memb if (!is_marked) { LOG(INFO) << *alloc_space; LOG(WARNING) << (is_static ? "Static ref'" : "Instance ref'") << PrettyTypeOf(ref) - << "' (" << (void*)ref << ") in '" << PrettyTypeOf(obj) - << "' (" << (void*)obj << ") at offset " - << (void*)offset.Int32Value() << " wasn't marked"; + << "' (" << reinterpret_cast<const void*>(ref) << ") in '" << PrettyTypeOf(obj) + << "' (" << reinterpret_cast<const void*>(obj) << ") at offset " + << reinterpret_cast<void*>(offset.Int32Value()) << " wasn't marked"; bool obj_marked = heap_->GetCardTable()->IsDirty(obj); if (!obj_marked) { - LOG(WARNING) << "Object '" << PrettyTypeOf(obj) << "' (" << (void*)obj - << ") contains references to the alloc space, but wasn't card marked"; + LOG(WARNING) << "Object '" << PrettyTypeOf(obj) << "' " + << "(" << reinterpret_cast<const void*>(obj) << ") contains references to " + << "the alloc space, but wasn't card marked"; } } } diff --git a/src/monitor.cc b/src/monitor.cc index cfc7d49..6887010 100644 --- a/src/monitor.cc +++ b/src/monitor.cc @@ -86,7 +86,7 @@ namespace art { * lock. Performs no error checking. */ #define LW_MONITOR(x) \ - ((Monitor*)((x) & ~((LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT) | LW_SHAPE_MASK))) + (reinterpret_cast<Monitor*>((x) & ~((LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT) | LW_SHAPE_MASK))) /* * Lock recursion count field. Contains a count of the number of times @@ -583,9 +583,9 @@ void Monitor::Inflate(Thread* self, Object* obj) { void Monitor::MonitorEnter(Thread* self, Object* obj) { volatile int32_t* thinp = obj->GetRawLockWordAddress(); struct timespec tm; - long sleepDelayNs; - long minSleepDelayNs = 1000000; /* 1 millisecond */ - long maxSleepDelayNs = 1000000000; /* 1 second */ + uint32_t sleepDelayNs; + uint32_t minSleepDelayNs = 1000000; /* 1 millisecond */ + uint32_t maxSleepDelayNs = 1000000000; /* 1 second */ uint32_t thin, newThin; DCHECK(self != NULL); @@ -662,8 +662,7 @@ retry: } else { // The thin lock was inflated by another thread. Let the runtime know we are no longer // waiting and try again. - VLOG(monitor) << "monitor: thread " << threadId - << " found lock " << (void*) thinp << " surprise-fattened by another thread"; + VLOG(monitor) << StringPrintf("monitor: thread %d found lock %p surprise-fattened by another thread", threadId, thinp); self->monitor_enter_object_ = NULL; self->SetState(oldStatus); goto retry; @@ -680,7 +679,8 @@ retry: } else { // The lock is a fat lock. VLOG(monitor) << StringPrintf("monitor: thread %d locking fat lock %p (%p) %p on a %s", - threadId, thinp, LW_MONITOR(*thinp), (void*)*thinp, PrettyTypeOf(obj).c_str()); + threadId, thinp, LW_MONITOR(*thinp), + reinterpret_cast<void*>(*thinp), PrettyTypeOf(obj).c_str()); DCHECK(LW_MONITOR(*thinp) != NULL); LW_MONITOR(*thinp)->Lock(self); } diff --git a/src/monitor_android.cc b/src/monitor_android.cc index c1949ec..dc77b6d 100644 --- a/src/monitor_android.cc +++ b/src/monitor_android.cc @@ -37,14 +37,14 @@ static void Set4LE(uint8_t* buf, uint32_t val) { static char* EventLogWriteInt(char* dst, int value) { *dst++ = EVENT_TYPE_INT; - Set4LE((uint8_t*) dst, value); + Set4LE(reinterpret_cast<uint8_t*>(dst), value); return dst + 4; } static char* EventLogWriteString(char* dst, const char* value, size_t len) { *dst++ = EVENT_TYPE_STRING; len = len < 32 ? len : 32; - Set4LE((uint8_t*) dst, len); + Set4LE(reinterpret_cast<uint8_t*>(dst), len); dst += 4; memcpy(dst, value, len); return dst + len; diff --git a/src/object.cc b/src/object.cc index f72dc28..207a175 100644 --- a/src/object.cc +++ b/src/object.cc @@ -1470,7 +1470,7 @@ bool String::Equals(const StringPiece& modified_utf8) const { std::string String::ToModifiedUtf8() const { const uint16_t* chars = GetCharArray()->GetData() + GetOffset(); size_t byte_count(CountUtf8Bytes(chars, GetLength())); - std::string result(byte_count, char(0)); + std::string result(byte_count, static_cast<char>(0)); ConvertUtf16ToModifiedUtf8(&result[0], chars, GetLength()); return result; } diff --git a/src/runtime.cc b/src/runtime.cc index 4156bb3..f6311bb 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -199,8 +199,8 @@ size_t ParseMemoryOption(const char* s, size_t div) { // strtoul accepts a leading [+-], which we don't want, // so make sure our string starts with a decimal digit. if (isdigit(*s)) { - const char* s2; - size_t val = strtoul(s, (char**)&s2, 10); + char* s2; + size_t val = strtoul(s, &s2, 10); if (s2 != s) { // s2 should be pointing just after the number. // If this is the end of the string, the user @@ -785,7 +785,7 @@ int32_t Runtime::GetStat(int kind) { return stats->class_init_count; case KIND_CLASS_INIT_TIME: // Convert ns to us, reduce to 32 bits. - return (int) (stats->class_init_time_ns / 1000); + return static_cast<int>(stats->class_init_time_ns / 1000); case KIND_EXT_ALLOCATED_OBJECTS: case KIND_EXT_ALLOCATED_BYTES: case KIND_EXT_FREED_OBJECTS: diff --git a/src/stringprintf.cc b/src/stringprintf.cc index aed60eb..8fd9257 100644 --- a/src/stringprintf.cc +++ b/src/stringprintf.cc @@ -32,7 +32,7 @@ void StringAppendV(std::string* dst, const char* format, va_list ap) { int result = vsnprintf(space, sizeof(space), format, backup_ap); va_end(backup_ap); - if (result < int(sizeof(space))) { + if (result < static_cast<int>(sizeof(space))) { if (result >= 0) { // Normal case -- everything fit. dst->append(space, result); diff --git a/src/thread.cc b/src/thread.cc index 74165da..1b5dea0 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -513,7 +513,7 @@ void Thread::InitStackHwm() { // Sanity check. int stack_variable; - CHECK_GT(&stack_variable, (void*) stack_end_); + CHECK_GT(&stack_variable, reinterpret_cast<void*>(stack_end_)); CHECK_PTHREAD_CALL(pthread_attr_destroy, (&attributes), __FUNCTION__); #endif diff --git a/src/thread_list.cc b/src/thread_list.cc index 8927820..a64e217 100644 --- a/src/thread_list.cc +++ b/src/thread_list.cc @@ -274,7 +274,7 @@ void ThreadList::Resume(Thread* thread, bool for_debugger) { VLOG(threads) << "Resume(" << *thread << ") complete"; } -void ThreadList::RunWhileSuspended(Thread* thread, void (*callback)(void*), void* arg) { +void ThreadList::RunWhileSuspended(Thread* thread, void (*callback)(void*), void* arg) { // NOLINT DCHECK(thread != NULL); Thread* self = Thread::Current(); if (thread != self) { diff --git a/src/thread_list.h b/src/thread_list.h index 07c9514..fbcd9bc 100644 --- a/src/thread_list.h +++ b/src/thread_list.h @@ -39,7 +39,7 @@ class ThreadList { void FullSuspendCheck(Thread* thread); void ResumeAll(bool for_debugger = false); void Resume(Thread* thread, bool for_debugger = false); - void RunWhileSuspended(Thread* thread, void (*callback)(void*), void* arg); + void RunWhileSuspended(Thread* thread, void (*callback)(void*), void* arg); // NOLINT void SuspendAll(bool for_debugger = false); void SuspendSelfForDebugger(); void Suspend(Thread* thread, bool for_debugger = false); diff --git a/src/utils.cc b/src/utils.cc index 67c88cf..bdc5925 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -772,7 +772,7 @@ void SetThreadName(const char* threadName) { #elif defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 pthread_setname_np(threadName); #elif defined(HAVE_PRCTL) - prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0); + prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0); // NOLINT (unsigned long) #else UNIMPLEMENTED(WARNING) << threadName; #endif |