Use uintptr_t for cast pointer to integer.
On 64bit host, sizeof pointer is not equal to sizeof int/u4.
Need for host tools.
Change-Id: Id8d9418787e79523226b9c9e3f67277f9ac7c6aa
diff --git a/dexdump/DexDump.cpp b/dexdump/DexDump.cpp
index bd2f17c..31fd1f8 100644
--- a/dexdump/DexDump.cpp
+++ b/dexdump/DexDump.cpp
@@ -1518,7 +1518,7 @@
*/
static inline const u1* align32(const u1* ptr)
{
- return (u1*) (((int) ptr + 3) & ~0x03);
+ return (u1*) (((uintptr_t) ptr + 3) & ~0x03);
}
diff --git a/libdex/DexFile.h b/libdex/DexFile.h
index 38e6eca..7a04f2a 100644
--- a/libdex/DexFile.h
+++ b/libdex/DexFile.h
@@ -756,7 +756,7 @@
const u2* insnsEnd = &pCode->insns[pCode->insnsSize];
// Round to four bytes.
- if ((((u4) insnsEnd) & 3) != 0) {
+ if ((((uintptr_t) insnsEnd) & 3) != 0) {
insnsEnd++;
}
diff --git a/libdex/DexOptData.cpp b/libdex/DexOptData.cpp
index b859d63..dd41751 100644
--- a/libdex/DexOptData.cpp
+++ b/libdex/DexOptData.cpp
@@ -30,7 +30,7 @@
*/
static bool isValidPointer(const void* ptr, const void* start, const void* end)
{
- return (ptr >= start) && (ptr < end) && (((u4) ptr & 7) == 0);
+ return (ptr >= start) && (ptr < end) && (((uintptr_t) ptr & 7) == 0);
}
/* (documented in header file) */
diff --git a/libdex/DexSwapVerify.cpp b/libdex/DexSwapVerify.cpp
index 1835e9b..24a86f9 100644
--- a/libdex/DexSwapVerify.cpp
+++ b/libdex/DexSwapVerify.cpp
@@ -1842,7 +1842,7 @@
if (item->triesSize == 0) {
ptr = insns;
} else {
- if ((((u4) insns) & 3) != 0) {
+ if ((((uintptr_t) insns) & 3) != 0) {
// Four-byte alignment for the tries. Verify the spacer is a 0.
if (*insns != 0) {
ALOGE("Non-zero padding: %#x", (u4) *insns);
diff --git a/libdex/SysUtil.cpp b/libdex/SysUtil.cpp
index a412a12..456d26e 100644
--- a/libdex/SysUtil.cpp
+++ b/libdex/SysUtil.cpp
@@ -331,7 +331,7 @@
* (The address must be page-aligned, the length doesn't need to be,
* but we do need to ensure we cover the same range.)
*/
- u1* alignAddr = (u1*) ((int) addr & ~(SYSTEM_PAGE_SIZE-1));
+ u1* alignAddr = (u1*) ((uintptr_t) addr & ~(SYSTEM_PAGE_SIZE-1));
size_t alignLength = length + ((u1*) addr - alignAddr);
//ALOGI("%p/%zd --> %p/%zd", addr, length, alignAddr, alignLength);