From d286796fce1e6fff407b719a53eb2afbeb96c327 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 3 Jun 2014 15:22:34 -0700 Subject: [PATCH] Turn on -Wunused and fix the mistakes it uncovers. Change-Id: I023d2d8b547fbc21d4124bb7510d42b06a0dc501 --- benchmarks/Android.mk | 2 +- libc/Android.mk | 4 ++-- libc/bionic/libc_init_dynamic.cpp | 2 +- libc/bionic/libc_init_static.cpp | 2 +- libdl/Android.mk | 2 +- linker/Android.mk | 2 +- linker/linked_list.h | 1 - linker/linker.cpp | 2 +- linker/tests/Android.mk | 2 +- tests/Android.mk | 2 +- 10 files changed, 10 insertions(+), 11 deletions(-) diff --git a/benchmarks/Android.mk b/benchmarks/Android.mk index cf3d692ac..f9722ae86 100644 --- a/benchmarks/Android.mk +++ b/benchmarks/Android.mk @@ -24,7 +24,7 @@ LOCAL_PATH := $(call my-dir) benchmark_c_flags = \ -O2 \ - -Wall -Wextra \ + -Wall -Wextra -Wunused \ -Werror \ -fno-builtin \ -std=gnu++11 \ diff --git a/libc/Android.mk b/libc/Android.mk index 4783bd386..02fad3bce 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -486,7 +486,7 @@ libc_arch_static_src_files := \ # ======================================================== libc_common_cflags := \ -D_LIBC=1 \ - -Wall -Wextra \ + -Wall -Wextra -Wunused \ # Try to catch typical 32-bit assumptions that break with 64-bit pointers. libc_common_cflags += \ @@ -709,7 +709,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files) LOCAL_CFLAGS := \ $(libc_common_cflags) \ - -Wno-sign-compare -Wno-uninitialized \ + -Wno-sign-compare -Wno-uninitialized -Wno-unused-parameter \ -Werror \ -I$(LOCAL_PATH)/upstream-openbsd/android/include \ -I$(LOCAL_PATH)/upstream-openbsd/lib/libc/include \ diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp index 659cf398a..7c463643b 100644 --- a/libc/bionic/libc_init_dynamic.cpp +++ b/libc/bionic/libc_init_dynamic.cpp @@ -94,7 +94,7 @@ __LIBC_HIDDEN__ void __libc_postfini() { // Note that the dynamic linker has also run all constructors in the // executable at this point. __noreturn void __libc_init(void* raw_args, - void (*onexit)(void), + void (*onexit)(void) __unused, int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp index e45422ed9..ab0b3a69f 100644 --- a/libc/bionic/libc_init_static.cpp +++ b/libc/bionic/libc_init_static.cpp @@ -85,7 +85,7 @@ static void apply_gnu_relro() { } __noreturn void __libc_init(void* raw_args, - void (*onexit)(void), + void (*onexit)(void) __unused, int (*slingshot)(int, char**, char**), structors_array_t const * const structors) { KernelArgumentBlock args(raw_args); diff --git a/libdl/Android.mk b/libdl/Android.mk index 3d60474f0..cb1cb7d28 100644 --- a/libdl/Android.mk +++ b/libdl/Android.mk @@ -22,7 +22,7 @@ LOCAL_LDFLAGS_x86 := -Wl,--exclude-libs=libgcc_eh.a LOCAL_LDFLAGS_x86_64 := $(LOCAL_LDFLAGS_x86) LOCAL_SRC_FILES:= libdl.c -LOCAL_CFLAGS := -Wall -Wextra -Werror +LOCAL_CFLAGS := -Wall -Wextra -Wunused -Werror LOCAL_MODULE := libdl LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk diff --git a/linker/Android.mk b/linker/Android.mk index d2bcfaf0b..811cf6e8e 100644 --- a/linker/Android.mk +++ b/linker/Android.mk @@ -26,7 +26,7 @@ LOCAL_CFLAGS += \ -fno-stack-protector \ -Wstrict-overflow=5 \ -fvisibility=hidden \ - -Wall -Wextra -Werror \ + -Wall -Wextra -Wunused -Werror \ LOCAL_CONLYFLAGS += \ -std=gnu99 \ diff --git a/linker/linked_list.h b/linker/linked_list.h index a6bea6c8f..52af0f110 100644 --- a/linker/linked_list.h +++ b/linker/linked_list.h @@ -59,7 +59,6 @@ class LinkedList { template void remove_if(F&& predicate) { - LinkedListEntry* e = head_; for (LinkedListEntry* e = head_; e != nullptr; e = e->next) { if (e->element != nullptr && predicate(e->element)) { e->element = nullptr; diff --git a/linker/linker.cpp b/linker/linker.cpp index 98cb1789b..5452f3011 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -827,7 +827,7 @@ void do_android_update_LD_LIBRARY_PATH(const char* ld_library_path) { } } -soinfo* do_dlopen(const char* name, int flags, soinfo* caller, const android_dlextinfo* extinfo) { +soinfo* do_dlopen(const char* name, int flags, soinfo* /*caller*/, const android_dlextinfo* extinfo) { if ((flags & ~(RTLD_NOW|RTLD_LAZY|RTLD_LOCAL|RTLD_GLOBAL|RTLD_NOLOAD)) != 0) { DL_ERR("invalid flags to dlopen: %x", flags); return NULL; diff --git a/linker/tests/Android.mk b/linker/tests/Android.mk index 831cfcb96..683f9ee80 100644 --- a/linker/tests/Android.mk +++ b/linker/tests/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk -LOCAL_CFLAGS += -g -Wall -Wextra -Werror -std=gnu++11 +LOCAL_CFLAGS += -g -Wall -Wextra -Wunused -Werror -std=gnu++11 LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../libc/ LOCAL_SRC_FILES := \ diff --git a/tests/Android.mk b/tests/Android.mk index db8dd8cc7..811c12a5a 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -34,7 +34,7 @@ endif test_cflags = \ -fstack-protector-all \ -g \ - -Wall -Wextra \ + -Wall -Wextra -Wunused \ -Werror \ -fno-builtin \