And fix old style casts.
Change-Id: I37e7a3e3fd852528ea76f02d967c7bd8cd5b06c9
LOCAL_CPPFLAGS += \
-std=gnu++11 \
+ -Wold-style-cast \
ifeq ($(TARGET_IS_64_BIT),true)
LOCAL_CPPFLAGS += -DTARGET_IS_64_BIT
}
char thread_name[MAX_TASK_NAME_LEN + 1]; // one more for termination
- if (prctl(PR_GET_NAME, (unsigned long)thread_name, 0, 0, 0) != 0) {
+ if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(thread_name), 0, 0, 0) != 0) {
strcpy(thread_name, "<name unknown>");
} else {
// short names are null terminated by prctl, but the man page
* and NOEXEC
*/
+// Override macros to use C++ style casts
+#undef ELF_ST_TYPE
+#define ELF_ST_TYPE(x) (static_cast<uint32_t>(x) & 0xf)
+
#if defined(__LP64__)
#define SEARCH_NAME(x) x
#else
//
// This function is exposed via dlfcn.cpp and libdl.so.
_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) {
- unsigned addr = (unsigned)pc;
+ uintptr_t addr = reinterpret_cast<uintptr_t>(pc);
for (soinfo* si = solist; si != 0; si = si->next) {
if ((addr >= si->base) && (addr < (si->base + si->size))) {
*pcount = si->ARM_exidx_count;
- return (_Unwind_Ptr)si->ARM_exidx;
+ return reinterpret_cast<_Unwind_Ptr>(si->ARM_exidx);
}
}
*pcount = 0;
break;
case DT_INIT_ARRAYSZ:
- init_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
+ init_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break;
case DT_FINI_ARRAY:
break;
case DT_FINI_ARRAYSZ:
- fini_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
+ fini_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break;
case DT_PREINIT_ARRAY:
break;
case DT_PREINIT_ARRAYSZ:
- preinit_array_count_ = ((unsigned)d->d_un.d_val) / sizeof(ElfW(Addr));
+ preinit_array_count_ = static_cast<uint32_t>(d->d_un.d_val) / sizeof(ElfW(Addr));
break;
case DT_TEXTREL:
*/
int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias,
- ElfW(Addr)** arm_exidx, unsigned* arm_exidx_count) {
+ ElfW(Addr)** arm_exidx, size_t* arm_exidx_count) {
const ElfW(Phdr)* phdr = phdr_table;
const ElfW(Phdr)* phdr_limit = phdr + phdr_count;
}
*arm_exidx = reinterpret_cast<ElfW(Addr)*>(load_bias + phdr->p_vaddr);
- *arm_exidx_count = (unsigned)(phdr->p_memsz / 8);
+ *arm_exidx_count = phdr->p_memsz / 8;
return 0;
}
*arm_exidx = nullptr;
ElfW(Addr) elf_addr = load_bias_ + phdr->p_vaddr;
const ElfW(Ehdr)* ehdr = reinterpret_cast<const ElfW(Ehdr)*>(elf_addr);
ElfW(Addr) offset = ehdr->e_phoff;
- return CheckPhdr((ElfW(Addr))ehdr + offset);
+ return CheckPhdr(reinterpret_cast<ElfW(Addr)>(ehdr) + offset);
}
break;
}
#if defined(__arm__)
int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, ElfW(Addr) load_bias,
- ElfW(Addr)** arm_exidx, unsigned* arm_exidix_count);
+ ElfW(Addr)** arm_exidx, size_t* arm_exidix_count);
#endif
void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count,