From 4224d9ea16ea2f9813d080b5d20f3992114d33ca Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Fri, 1 Dec 2017 11:28:37 -0800 Subject: [PATCH] Use -Werror in hardware/libhardware/tests * Remove unused local variables. * Suppress warning of unused template functions. * Fix error of unused expression value. Bug: 66996870 Test: build with WITH_TIDY=1 Change-Id: I5a37c24f3be0f61b0ae4552e34b7311f561d499e --- tests/camera3/Android.mk | 2 +- tests/hardware/Android.mk | 2 +- tests/hardware/struct-size.cpp | 2 +- tests/hwc/Android.mk | 6 +++--- tests/hwc/cnativewindow.c | 6 +++--- tests/hwc/util.c | 4 ++-- tests/input/evdev/Android.mk | 2 +- tests/keymaster/Android.mk | 2 ++ tests/keymaster/keymaster_test.cpp | 6 ------ tests/vehicle/Android.mk | 2 +- 10 files changed, 15 insertions(+), 19 deletions(-) diff --git a/tests/camera3/Android.mk b/tests/camera3/Android.mk index 652851af..fbfde68a 100644 --- a/tests/camera3/Android.mk +++ b/tests/camera3/Android.mk @@ -12,7 +12,7 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_C_INCLUDES += \ system/media/camera/include \ -LOCAL_CFLAGS += -Wall -Wextra +LOCAL_CFLAGS += -Wall -Wextra -Werror LOCAL_MODULE:= camera3_tests LOCAL_MODULE_TAGS := tests diff --git a/tests/hardware/Android.mk b/tests/hardware/Android.mk index 99273433..02a3596e 100644 --- a/tests/hardware/Android.mk +++ b/tests/hardware/Android.mk @@ -4,7 +4,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := static-hal-check LOCAL_SRC_FILES := struct-size.cpp struct-offset.cpp struct-last.cpp LOCAL_SHARED_LIBRARIES := libhardware -LOCAL_CFLAGS := -O0 +LOCAL_CFLAGS := -O0 -Wall -Werror LOCAL_C_INCLUDES += \ system/media/camera/include diff --git a/tests/hardware/struct-size.cpp b/tests/hardware/struct-size.cpp index 232b55da..14a26efe 100644 --- a/tests/hardware/struct-size.cpp +++ b/tests/hardware/struct-size.cpp @@ -24,7 +24,7 @@ #include #include -template static constexpr size_t CheckSizeHelper(size_t, size_t); +template static constexpr size_t CheckSizeHelper(size_t, size_t) __attribute((unused)); template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t /* size64 */) { return size32; diff --git a/tests/hwc/Android.mk b/tests/hwc/Android.mk index 0416ff1c..a5f59f11 100644 --- a/tests/hwc/Android.mk +++ b/tests/hwc/Android.mk @@ -1,9 +1,9 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) -LOCAL_MODULE := libcnativewindow +LOCAL_MODULE := libcnativewindow LOCAL_SRC_FILES := cnativewindow.c util.c -LOCAL_CFLAGS := -Wno-unused-parameter +LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libdl libhardware libnativewindow include $(BUILD_STATIC_LIBRARY) @@ -12,5 +12,5 @@ LOCAL_MODULE := hwc-test-arrows LOCAL_SRC_FILES := test-arrows.c LOCAL_STATIC_LIBRARIES := libcnativewindow LOCAL_SHARED_LIBRARIES := libEGL libGLESv2 libdl libhardware libnativewindow -LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES +LOCAL_CFLAGS := -DGL_GLEXT_PROTOTYPES -Wall -Werror include $(BUILD_EXECUTABLE) diff --git a/tests/hwc/cnativewindow.c b/tests/hwc/cnativewindow.c index 5b1d78ea..65a814de 100644 --- a/tests/hwc/cnativewindow.c +++ b/tests/hwc/cnativewindow.c @@ -181,7 +181,7 @@ static void hwc_post(CNativeWindow *win, aBuffer *buf, int ffd) { hwc_composer_device_1_t *hwc = win->hwc; hwc_display_contents_1_t *dc = &(win->dc); hwc_layer_1_t *dl = win->dc.hwLayers; - int r, i; + int r; dc->retireFenceFd = -1; dc->outbufAcquireFenceFd = -1; @@ -462,8 +462,8 @@ static int cnw_init(CNativeWindow *win) { hw_module_t const* module; framebuffer_device_t *fb = NULL; alloc_device_t *gr; - int err, i, n; - unsigned usage, format; + int err, i; + unsigned usage; memset(win, 0, sizeof(CNativeWindow)); diff --git a/tests/hwc/util.c b/tests/hwc/util.c index 89313054..51d59748 100644 --- a/tests/hwc/util.c +++ b/tests/hwc/util.c @@ -36,7 +36,7 @@ void matrix_init_ortho(GLfloat *m, float w, float h) { m[7] = -1.0; m[8] = 0.0; m[9] = 0.0; - m[10] -1.0; + m[10] = -1.0; m[11] = 0.0; m[12] = 0.0; m[13] = 0.0; @@ -111,7 +111,7 @@ fail_frag: int select_config_for_window(EGLDisplay dpy, EGLint *attr, unsigned format, EGLConfig *config) { - EGLint R,G,B,A,r,g,b,a; + EGLint R,G,B,A; EGLint i, n, max; EGLConfig *cfg; diff --git a/tests/input/evdev/Android.mk b/tests/input/evdev/Android.mk index 7f62649b..b09a8ac2 100644 --- a/tests/input/evdev/Android.mk +++ b/tests/input/evdev/Android.mk @@ -20,7 +20,7 @@ LOCAL_SHARED_LIBRARIES := \ libutils LOCAL_CLANG := true -LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter +LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter # TestHelpers uses mktemp. As the path is given to TempFile, we can't do too much # here (e.g., use mkdtemp first). At least races will lead to an early failure, as diff --git a/tests/keymaster/Android.mk b/tests/keymaster/Android.mk index 0c117954..173fccc9 100644 --- a/tests/keymaster/Android.mk +++ b/tests/keymaster/Android.mk @@ -14,6 +14,8 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE := keymaster_test +LOCAL_CFLAGS := -Wall -Werror + LOCAL_MODULE_TAGS := tests include $(BUILD_NATIVE_TEST) diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp index b6903f38..e6b41c7a 100644 --- a/tests/keymaster/keymaster_test.cpp +++ b/tests/keymaster/keymaster_test.cpp @@ -649,9 +649,6 @@ TEST_F(KeymasterTest, GetKeypairPublic_EC_Success) { } TEST_F(KeymasterTest, GetKeypairPublic_NullKey_Failure) { - uint8_t* key_blob; - size_t key_blob_length; - uint8_t* x509_data = NULL; size_t x509_data_length; ASSERT_EQ(-1, @@ -1033,9 +1030,6 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_NullOutput_Failure) { .padding_type = PADDING_NONE, }; - uint8_t* sig; - size_t sig_length; - UniqueReadOnlyBlob testData(TEST_RSA_KEY_1, sizeof(TEST_RSA_KEY_1)); ASSERT_TRUE(testData.get() != NULL); diff --git a/tests/vehicle/Android.mk b/tests/vehicle/Android.mk index eb41725f..ab412fb9 100644 --- a/tests/vehicle/Android.mk +++ b/tests/vehicle/Android.mk @@ -25,7 +25,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog \ libhardware \ -LOCAL_CFLAGS += -Wall -Wextra +LOCAL_CFLAGS += -Wall -Wextra -Werror LOCAL_MODULE:= vehicle_tests LOCAL_MODULE_TAGS := tests