From 5d9fe779c8ec2705865a23061834ad8cdbee5b82 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 5 Feb 2014 17:50:35 -0800 Subject: [PATCH] system/core LP64 cleanup. Fixes -Wint-to-pointer and -Wpointer-to-int warnings, plus various -Wformat warnings. Change-Id: I6c5eea6b4273d82d28b8e5d2925f3e5457511b17 --- debuggerd/crasher.c | 8 ++++---- fastbootd/commands.c | 6 +++--- fastbootd/commands/boot.c | 8 ++++---- fastbootd/commands/boot.h | 4 ++-- fastbootd/protocol.c | 2 +- liblog/tests/benchmark_main.cpp | 5 +++-- liblog/tests/liblog_test.cpp | 10 ++++++---- libnl_2/Android.mk | 2 ++ sdcard/sdcard.c | 10 +++++----- 9 files changed, 30 insertions(+), 25 deletions(-) diff --git a/debuggerd/crasher.c b/debuggerd/crasher.c index 0033948df..5a2bc3c73 100644 --- a/debuggerd/crasher.c +++ b/debuggerd/crasher.c @@ -57,13 +57,13 @@ static void test_call1() static void *noisy(void *x) { - char c = (unsigned) x; + char c = (uintptr_t) x; for(;;) { usleep(250*1000); write(2, &c, 1); if(c == 'C') *((unsigned*) 0) = 42; } - return 0; + return NULL; } static int ctest() @@ -81,7 +81,7 @@ static int ctest() static void* thread_callback(void* raw_arg) { - return (void*) do_action((const char*) raw_arg); + return (void*) (uintptr_t) do_action((const char*) raw_arg); } static int do_action_on_thread(const char* arg) @@ -90,7 +90,7 @@ static int do_action_on_thread(const char* arg) pthread_create(&t, NULL, thread_callback, (void*) arg); void* result = NULL; pthread_join(t, &result); - return (int) result; + return (int) (uintptr_t) result; } __attribute__((noinline)) static int crash3(int a) { diff --git a/fastbootd/commands.c b/fastbootd/commands.c index 063e1a600..98b7866a9 100644 --- a/fastbootd/commands.c +++ b/fastbootd/commands.c @@ -124,9 +124,9 @@ static void cmd_boot(struct protocol_handle *phandle, const char *arg) goto error; } - kernel_ptr = (void *)((unsigned) ptr + hdr->page_size); - ramdisk_ptr = (void *)((unsigned) kernel_ptr + kernel_actual); - second_ptr = (void *)((unsigned) ramdisk_ptr + ramdisk_actual); + kernel_ptr = (void *)((uintptr_t) ptr + hdr->page_size); + ramdisk_ptr = (void *)((uintptr_t) kernel_ptr + kernel_actual); + second_ptr = (void *)((uintptr_t) ramdisk_ptr + ramdisk_actual); D(INFO, "preparing to boot"); // Prepares boot physical address. Addresses from header are ignored diff --git a/fastbootd/commands/boot.c b/fastbootd/commands/boot.c index 8da9a2810..922914bc6 100644 --- a/fastbootd/commands/boot.c +++ b/fastbootd/commands/boot.c @@ -89,10 +89,10 @@ long kexec_load(unsigned int entry, unsigned long nr_segments, * Kernel address is not set into kernel_phys * Ramdisk is set to position relative to kernel */ -int prepare_boot_linux(unsigned kernel_phys, void *kernel_addr, int kernel_size, - unsigned ramdisk_phys, void *ramdisk_addr, int ramdisk_size, - unsigned second_phys, void *second_addr, int second_size, - unsigned atags_phys, void *atags_addr, int atags_size) { +int prepare_boot_linux(uintptr_t kernel_phys, void *kernel_addr, int kernel_size, + uintptr_t ramdisk_phys, void *ramdisk_addr, int ramdisk_size, + uintptr_t second_phys, void *second_addr, int second_size, + uintptr_t atags_phys, void *atags_addr, int atags_size) { struct kexec_segment segment[4]; int segment_count = 2; unsigned entry = START_ADDRESS + KEXEC_ARM_ZIMAGE_OFFSET; diff --git a/fastbootd/commands/boot.h b/fastbootd/commands/boot.h index 901c38a20..a5efd01a3 100644 --- a/fastbootd/commands/boot.h +++ b/fastbootd/commands/boot.h @@ -40,8 +40,8 @@ #define KEXEC_TYPE_DEFAULT 0 #define KEXEC_TYPE_CRASH 1 -int prepare_boot_linux(unsigned, void *, int, unsigned, void *, int, - unsigned, void *, int, unsigned, void *, int); +int prepare_boot_linux(uintptr_t, void *, int, uintptr_t, void *, int, + uintptr_t, void *, int, uintptr_t, void *, int); unsigned *create_atags(unsigned *, int, const struct boot_img_hdr *, int *); long kexec_load(unsigned int, unsigned long, struct kexec_segment *, unsigned long); char *read_atags(const char *, int *); diff --git a/fastbootd/protocol.c b/fastbootd/protocol.c index 0086b4a96..3908020a1 100644 --- a/fastbootd/protocol.c +++ b/fastbootd/protocol.c @@ -142,7 +142,7 @@ void fastboot_data(struct protocol_handle *phandle, size_t len) char response[64]; ssize_t ret; - snprintf(response, 64, "DATA%08x", len); + snprintf(response, 64, "DATA%08zx", len); ret = protocol_handle_write(phandle, response, strlen(response)); if (ret < 0) return; diff --git a/liblog/tests/benchmark_main.cpp b/liblog/tests/benchmark_main.cpp index 02df46005..090394ccf 100644 --- a/liblog/tests/benchmark_main.cpp +++ b/liblog/tests/benchmark_main.cpp @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -158,10 +159,10 @@ void Run(Benchmark* b) { sdev = (sqrt((double)nXvariance) / gBenchmarkNum / gBenchmarkNum) + 0.5; } if (mean > (10000 * sdev)) { - printf("%-25s %10llu %10llu%s\n", full_name, + printf("%-25s %10" PRIu64 " %10" PRIu64 "%s\n", full_name, static_cast(iterations), mean, throughput); } else { - printf("%-25s %10llu %10llu(\317\203%llu)%s\n", full_name, + printf("%-25s %10" PRIu64 " %10" PRIu64 "(\317\203%" PRIu64 ")%s\n", full_name, static_cast(iterations), mean, sdev, throughput); } fflush(stdout); diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp index 9ae8f2222..d71d97a8d 100644 --- a/liblog/tests/liblog_test.cpp +++ b/liblog/tests/liblog_test.cpp @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -85,8 +86,8 @@ TEST(liblog, __android_log_btwrite) { static void* ConcurrentPrintFn(void *arg) { int ret = __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO, - "TEST__android_log_print", "Concurrent %d", - reinterpret_cast(arg)); + "TEST__android_log_print", "Concurrent %" PRIuPTR, + reinterpret_cast(arg)); return reinterpret_cast(ret); } @@ -106,8 +107,9 @@ TEST(liblog, concurrent_name(__android_log_buf_print, NUM_CONCURRENT)) { for (i=0; i < NUM_CONCURRENT; i++) { void* result; ASSERT_EQ(0, pthread_join(t[i], &result)); - if ((0 == ret) && (0 != reinterpret_cast(result))) { - ret = reinterpret_cast(result); + int this_result = reinterpret_cast(result); + if ((0 == ret) && (0 != this_result)) { + ret = this_result; } } ASSERT_LT(0, ret); diff --git a/libnl_2/Android.mk b/libnl_2/Android.mk index deac9ded3..3721fc6d8 100644 --- a/libnl_2/Android.mk +++ b/libnl_2/Android.mk @@ -26,6 +26,7 @@ LOCAL_C_INCLUDES += \ # Static Library LOCAL_MODULE := libnl_2 LOCAL_MODULE_TAGS := optional +LOCAL_32_BIT_ONLY := true include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) @@ -34,4 +35,5 @@ LOCAL_WHOLE_STATIC_LIBRARIES:= libnl_2 LOCAL_SHARED_LIBRARIES:= liblog LOCAL_MODULE := libnl_2 LOCAL_MODULE_TAGS := optional +LOCAL_32_BIT_ONLY := true include $(BUILD_SHARED_LIBRARY) diff --git a/sdcard/sdcard.c b/sdcard/sdcard.c index 05fbfbad3..4722708f3 100644 --- a/sdcard/sdcard.c +++ b/sdcard/sdcard.c @@ -200,7 +200,7 @@ static bool str_icase_equals(void *keyA, void *keyB) { } static int int_hash(void *key) { - return (int) key; + return (int) (uintptr_t) key; } static bool int_equals(void *keyA, void *keyB) { @@ -487,7 +487,7 @@ static void derive_permissions_locked(struct fuse* fuse, struct node *parent, break; case PERM_ANDROID_DATA: case PERM_ANDROID_OBB: - appid = (appid_t) hashmapGet(fuse->package_to_appid, node->name); + appid = (appid_t) (uintptr_t) hashmapGet(fuse->package_to_appid, node->name); if (appid != 0) { node->uid = multiuser_get_uid(parent->userid, appid); } @@ -511,7 +511,7 @@ static bool get_caller_has_rw_locked(struct fuse* fuse, const struct fuse_in_hea } appid_t appid = multiuser_get_app_id(hdr->uid); - return hashmapContainsKey(fuse->appid_with_rw, (void*) appid); + return hashmapContainsKey(fuse->appid_with_rw, (void*) (uintptr_t) appid); } /* Kernel has already enforced everything we returned through @@ -1621,12 +1621,12 @@ static int read_package_list(struct fuse *fuse) { if (sscanf(buf, "%s %d %*d %*s %*s %s", package_name, &appid, gids) == 3) { char* package_name_dup = strdup(package_name); - hashmapPut(fuse->package_to_appid, package_name_dup, (void*) appid); + hashmapPut(fuse->package_to_appid, package_name_dup, (void*) (uintptr_t) appid); char* token = strtok(gids, ","); while (token != NULL) { if (strtoul(token, NULL, 10) == fuse->write_gid) { - hashmapPut(fuse->appid_with_rw, (void*) appid, (void*) 1); + hashmapPut(fuse->appid_with_rw, (void*) (uintptr_t) appid, (void*) (uintptr_t) 1); break; } token = strtok(NULL, ",");