From 373d3c7257fa815d0b9ee8f16874470a6002042e Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 18 Oct 2017 16:28:14 -0700 Subject: Use -Werror in system/extras * Remove unused variables. * Fix redefined macro warnings. * Fix sign-compare warnings. * Fix 'return false' in main(). * Keep existing warnings to fix later. Bug: 66996870 Test: build with WITH_TIDY=1 Change-Id: Ib92ef5297693595fb84ed4f8e61665bda4cee312 --- tests/audio/alsa/Android.mk | 1 + tests/binder/benchmarks/Android.mk | 1 + tests/cpueater/Android.mk | 3 ++- tests/crypto/Android.mk | 2 +- tests/crypto/get_dm_versions.c | 1 - tests/directiotest/Android.mk | 1 + tests/ext4/Android.mk | 1 + tests/framebuffer/Android.mk | 4 ++-- tests/framebuffer/fb_test.c | 1 - tests/framebuffer/refresh.c | 1 - tests/fstest/Android.mk | 1 + tests/fstest/recovery_test.cpp | 2 -- tests/iptables/qtaguid/Android.mk | 2 +- tests/kernel.config/Android.mk | 5 +++-- tests/pagingtest/Android.mk | 2 ++ tests/pagingtest/mmap_test.c | 5 ++--- tests/pftest/Android.mk | 2 +- tests/schedtest/Android.mk | 2 +- tests/storage/Android.mk | 2 ++ tests/timetest/Android.mk | 1 + tests/uevents/Android.mk | 2 +- 21 files changed, 24 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/audio/alsa/Android.mk b/tests/audio/alsa/Android.mk index c6e5a8af..7d37af96 100644 --- a/tests/audio/alsa/Android.mk +++ b/tests/audio/alsa/Android.mk @@ -20,6 +20,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_MODULE := pcmtest LOCAL_SRC_FILES := pcmtest.cpp +LOCAL_CFLAGS:= -Wall -Werror LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libtinyalsa LOCAL_STATIC_LIBRARIES += libtestUtil LOCAL_C_INCLUDES += system/extras/tests/include external/tinyalsa/include diff --git a/tests/binder/benchmarks/Android.mk b/tests/binder/benchmarks/Android.mk index b43dd326..e3812ff7 100644 --- a/tests/binder/benchmarks/Android.mk +++ b/tests/binder/benchmarks/Android.mk @@ -36,5 +36,6 @@ LOCAL_C_INCLUDES += \ LOCAL_MODULE := binderAddInts LOCAL_COMPATIBILITY_SUITE := device-tests LOCAL_SRC_FILES := binderAddInts.cpp +LOCAL_CFLAGS:= -Wall -Werror include $(BUILD_NATIVE_BENCHMARK) diff --git a/tests/cpueater/Android.mk b/tests/cpueater/Android.mk index 0bb08d9d..3ee7a379 100644 --- a/tests/cpueater/Android.mk +++ b/tests/cpueater/Android.mk @@ -20,7 +20,7 @@ LOCAL_MODULE := cpueater LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := cpueater.c -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) @@ -28,6 +28,7 @@ LOCAL_MODULE := daemonize LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := daemonize.c +LOCAL_CFLAGS := -Wall -Werror LOCAL_SHARED_LIBRARIES := libhardware_legacy include $(BUILD_EXECUTABLE) diff --git a/tests/crypto/Android.mk b/tests/crypto/Android.mk index e118e5d0..d48f7229 100644 --- a/tests/crypto/Android.mk +++ b/tests/crypto/Android.mk @@ -7,5 +7,5 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= get_dm_versions.c LOCAL_MODULE:= get_dm_versions LOCAL_MODULE_TAGS := optional -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_EXECUTABLE) diff --git a/tests/crypto/get_dm_versions.c b/tests/crypto/get_dm_versions.c index 8ffe0a19..ba6b8953 100644 --- a/tests/crypto/get_dm_versions.c +++ b/tests/crypto/get_dm_versions.c @@ -27,7 +27,6 @@ int main(int argc, char *argv[]) char buffer[DM_CRYPT_BUF_SIZE]; struct dm_ioctl *io; struct dm_target_versions *v; - int i; int fd; fd = open("/dev/device-mapper", O_RDWR); diff --git a/tests/directiotest/Android.mk b/tests/directiotest/Android.mk index fb5f12a2..2bde675f 100644 --- a/tests/directiotest/Android.mk +++ b/tests/directiotest/Android.mk @@ -5,4 +5,5 @@ LOCAL_MODULE := directiotest LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := directiotest.c +LOCAL_CFLAGS := -Wall -Werror include $(BUILD_EXECUTABLE) diff --git a/tests/ext4/Android.mk b/tests/ext4/Android.mk index bdd4072a..a9a684d2 100644 --- a/tests/ext4/Android.mk +++ b/tests/ext4/Android.mk @@ -5,6 +5,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= rand_emmc_perf.c +LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE:= rand_emmc_perf LOCAL_MULTILIB := both LOCAL_MODULE_STEM_32:= rand_emmc_perf diff --git a/tests/framebuffer/Android.mk b/tests/framebuffer/Android.mk index 7f4c7125..1c4f5df7 100644 --- a/tests/framebuffer/Android.mk +++ b/tests/framebuffer/Android.mk @@ -9,7 +9,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE:= test-fb-refresh -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_EXECUTABLE) @@ -20,5 +20,5 @@ LOCAL_SRC_FILES := fb_test.c LOCAL_MODULE = test-fb-simple LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_STATIC_LIBRARIES := libc -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_EXECUTABLE) diff --git a/tests/framebuffer/fb_test.c b/tests/framebuffer/fb_test.c index 0b8bc68c..6d386299 100644 --- a/tests/framebuffer/fb_test.c +++ b/tests/framebuffer/fb_test.c @@ -206,7 +206,6 @@ uint32_t black32 = 0x0; void draw_grid(int w, int h, void* _loc) { int i, j; - int v; int stride = fi.line_length / (vi.bits_per_pixel >> 3); uint16_t *loc = _loc; uint32_t *loc32 = _loc; diff --git a/tests/framebuffer/refresh.c b/tests/framebuffer/refresh.c index 38e78719..0c2bb9d5 100644 --- a/tests/framebuffer/refresh.c +++ b/tests/framebuffer/refresh.c @@ -32,7 +32,6 @@ int main(int argc, char** argv) 0 }; int fd = -1; int i=0; - int j=0; char name[64]; while ((fd==-1) && device_template[i]) { snprintf(name, 64, device_template[i], 0); diff --git a/tests/fstest/Android.mk b/tests/fstest/Android.mk index 8ea48818..52f113ce 100644 --- a/tests/fstest/Android.mk +++ b/tests/fstest/Android.mk @@ -18,6 +18,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := tests LOCAL_MODULE := recovery_test LOCAL_SRC_FILES := recovery_test.cpp +LOCAL_CFLAGS := -Wall -Werror LOCAL_SHARED_LIBRARIES += libcutils libutils libbase liblog \ liblogwrap libext4_utils LOCAL_STATIC_LIBRARIES += libtestUtil libfs_mgr diff --git a/tests/fstest/recovery_test.cpp b/tests/fstest/recovery_test.cpp index e2371395..c34607d6 100644 --- a/tests/fstest/recovery_test.cpp +++ b/tests/fstest/recovery_test.cpp @@ -216,7 +216,6 @@ class FsRecoveryTest : public ::testing::Test { UMOUNT_BIN, cache_str, }; - int status; return android_fork_execvp_ext(ARRAY_SIZE(umount_argv), umount_argv, NULL, true, LOG_KLOG, false, NULL, NULL, 0) >= 0; @@ -230,7 +229,6 @@ class FsRecoveryTest : public ::testing::Test { storage_str, mountall_str, }; - int status; return android_fork_execvp_ext(ARRAY_SIZE(mountall_argv), mountall_argv, NULL, true, LOG_KLOG, false, NULL, NULL, 0) >= 0; diff --git a/tests/iptables/qtaguid/Android.mk b/tests/iptables/qtaguid/Android.mk index 6328883d..bc09bdd8 100644 --- a/tests/iptables/qtaguid/Android.mk +++ b/tests/iptables/qtaguid/Android.mk @@ -23,6 +23,6 @@ LOCAL_SRC_FILES := socketTag.cpp LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libbase LOCAL_STATIC_LIBRARIES += libtestUtil LOCAL_C_INCLUDES += system/extras/tests/include -LOCAL_CFLAGS += -fno-strict-aliasing +LOCAL_CFLAGS += -Wall -Werror -fno-strict-aliasing include $(BUILD_NATIVE_TEST) diff --git a/tests/kernel.config/Android.mk b/tests/kernel.config/Android.mk index 0c87107f..aa506c08 100644 --- a/tests/kernel.config/Android.mk +++ b/tests/kernel.config/Android.mk @@ -33,7 +33,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := kernel-config-unit-tests LOCAL_MODULE_TAGS := tests LOCAL_CFLAGS := $(test_c_flags) -LOCAL_CFLAGS := -DHAS_KCMP +LOCAL_CFLAGS += -DHAS_KCMP LOCAL_SRC_FILES := $(test_src_files) LOCAL_SHARED_LIBRARIES := libbase include $(BUILD_NATIVE_TEST) @@ -42,7 +42,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := CtsKernelConfigTestCases LOCAL_MODULE_TAGS := optional LOCAL_CFLAGS := $(test_c_flags) -LOCAL_CFLAGS := -DHAS_KCMP +LOCAL_CFLAGS += -DHAS_KCMP LOCAL_SRC_FILES := $(cts_src_files) LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest LOCAL_MULTILIB := both @@ -60,4 +60,5 @@ LOCAL_SRC_FILES := \ scrape_mmap_addr.cpp LOCAL_MODULE := scrape_mmap_addr +LOCAL_CFLAGS := -Wall -Werror include $(BUILD_NATIVE_TEST) diff --git a/tests/pagingtest/Android.mk b/tests/pagingtest/Android.mk index 727e3b81..de952ce3 100644 --- a/tests/pagingtest/Android.mk +++ b/tests/pagingtest/Android.mk @@ -10,6 +10,8 @@ LOCAL_SRC_FILES:= \ LOCAL_MODULE:= pagingtest +LOCAL_CFLAGS := -Wall -Werror + LOCAL_MODULE_TAGS := tests LOCAL_MODULE_PATH := $(local_target_dir) diff --git a/tests/pagingtest/mmap_test.c b/tests/pagingtest/mmap_test.c index d0d9846a..93859880 100644 --- a/tests/pagingtest/mmap_test.c +++ b/tests/pagingtest/mmap_test.c @@ -10,7 +10,6 @@ int mmap_test(int test_runs, unsigned long long alloc_size) { void *buf; int ret = -1; - int rc; int i; struct timeval begin_time, end_time, elapsed_time; struct timeval total_time_mmap, total_time_munmap, total_time_in, total_time_out; @@ -43,8 +42,8 @@ int mmap_test(int test_runs, unsigned long long alloc_size) { ret = 0; goto end; -err: - munmap(buf, alloc_size); +// err: + munmap(buf, alloc_size); // unreached? end: err_map: return ret; diff --git a/tests/pftest/Android.mk b/tests/pftest/Android.mk index bedbd0cb..1f829370 100644 --- a/tests/pftest/Android.mk +++ b/tests/pftest/Android.mk @@ -13,6 +13,6 @@ LOCAL_MODULE:= pftest LOCAL_MODULE_TAGS := optional ## LOCAL_CFLAGS += -fstack-protector-all -LOCAL_CFLAGS += -fomit-frame-pointer +LOCAL_CFLAGS += -fomit-frame-pointer -Wall -Werror include $(BUILD_EXECUTABLE) diff --git a/tests/schedtest/Android.mk b/tests/schedtest/Android.mk index 036c9fec..a018cb50 100644 --- a/tests/schedtest/Android.mk +++ b/tests/schedtest/Android.mk @@ -6,6 +6,6 @@ LOCAL_SRC_FILES := \ schedtest.c LOCAL_MODULE := schedtest -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror include $(BUILD_EXECUTABLE) diff --git a/tests/storage/Android.mk b/tests/storage/Android.mk index 462ebef6..41bbd661 100644 --- a/tests/storage/Android.mk +++ b/tests/storage/Android.mk @@ -6,12 +6,14 @@ include $(CLEAR_VARS) include $(CLEAR_VARS) LOCAL_SRC_FILES := opentest.c LOCAL_MODULE := opentest +LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) include $(CLEAR_VARS) LOCAL_SRC_FILES := wipe_blkdev.c LOCAL_MODULE := wipe_blkdev +LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE_TAGS := optional include $(BUILD_EXECUTABLE) diff --git a/tests/timetest/Android.mk b/tests/timetest/Android.mk index 0485caec..af3447fd 100644 --- a/tests/timetest/Android.mk +++ b/tests/timetest/Android.mk @@ -5,6 +5,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := timetest.c LOCAL_MODULE := timetest +LOCAL_CFLAGS := -Wall -Werror LOCAL_MODULE_TAGS := tests LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_STATIC_LIBRARIES := libc diff --git a/tests/uevents/Android.mk b/tests/uevents/Android.mk index fb8a8518..46e712d4 100644 --- a/tests/uevents/Android.mk +++ b/tests/uevents/Android.mk @@ -6,6 +6,6 @@ LOCAL_SRC_FILES := uevents.c LOCAL_SHARED_LIBRARIES += libcutils LOCAL_MODULE:= uevents -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter include $(BUILD_EXECUTABLE) -- cgit v1.2.3