From 1aa58f9ef95e0c15bd3e41bb987dd6d8f48aa978 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Wed, 16 Dec 2015 14:17:44 -0800 Subject: [PATCH] Libhardware: Fix tests Fix some warnings. Silence another. Less build noise. Change-Id: Ibdbba093c2aca45343bfbe72c551b15d0f94e1b5 --- tests/camera2/CameraMultiStreamTests.cpp | 3 -- tests/camera2/CameraStreamFixture.h | 1 - tests/camera2/camera2_utils.cpp | 29 ++++++++----- tests/hardware/struct-size.cpp | 4 +- tests/hwc/Android.mk | 1 + tests/hwc/cnativewindow.c | 6 +-- tests/input/evdev/Android.mk | 5 +++ tests/keymaster/keymaster_test.cpp | 52 ++++++++++++------------ tests/nusensors/nusensors.cpp | 11 ++--- 9 files changed, 62 insertions(+), 50 deletions(-) diff --git a/tests/camera2/CameraMultiStreamTests.cpp b/tests/camera2/CameraMultiStreamTests.cpp index 3e29ad62..eb64db1f 100644 --- a/tests/camera2/CameraMultiStreamTests.cpp +++ b/tests/camera2/CameraMultiStreamTests.cpp @@ -495,9 +495,6 @@ TEST_F(CameraMultiStreamTest, DISABLED_MultiBurst) { jpegData = availableJpegSizes.data.i32; jpegCount = availableJpegSizes.count; } else { - const int32_t *implDefResolutions; - size_t implDefResolutionsCount; - getResolutionList(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, &implDefData, &implDefCount); ASSERT_NE(0u, implDefCount) << "Missing implementation defined sizes"; diff --git a/tests/camera2/CameraStreamFixture.h b/tests/camera2/CameraStreamFixture.h index fc5fb368..bf7fb42b 100644 --- a/tests/camera2/CameraStreamFixture.h +++ b/tests/camera2/CameraStreamFixture.h @@ -186,7 +186,6 @@ protected: void getResolutionList(int32_t format, const int32_t **list, size_t *count) { - status_t res; ALOGV("Getting resolutions for format %x", format); if (getDeviceVersion() < CAMERA_DEVICE_API_VERSION_3_2) { return; diff --git a/tests/camera2/camera2_utils.cpp b/tests/camera2/camera2_utils.cpp index d9629396..c63c32ad 100644 --- a/tests/camera2/camera2_utils.cpp +++ b/tests/camera2/camera2_utils.cpp @@ -208,13 +208,13 @@ int MetadataQueue::consumer_dequeue(const camera2_request_queue_src_ops_t *q, return queue->dequeue(buffer, true); } -int MetadataQueue::consumer_free(const camera2_request_queue_src_ops_t *q, +int MetadataQueue::consumer_free(const camera2_request_queue_src_ops_t * /* q */, camera_metadata_t *old_buffer) { free_camera_metadata(old_buffer); return OK; } -int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t *q, +int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t * /* q */, size_t entries, size_t bytes, camera_metadata_t **buffer) { camera_metadata_t *new_buffer = @@ -224,7 +224,7 @@ int MetadataQueue::producer_dequeue(const camera2_frame_queue_dst_ops_t *q, return OK; } -int MetadataQueue::producer_cancel(const camera2_frame_queue_dst_ops_t *q, +int MetadataQueue::producer_cancel(const camera2_frame_queue_dst_ops_t * /* q */, camera_metadata_t *old_buffer) { free_camera_metadata(old_buffer); return OK; @@ -386,12 +386,21 @@ status_t StreamAdapter::connectToDevice(camera2_device_t *d, return res; } - res = native_window_set_buffers_geometry(mConsumerInterface.get(), - mWidth, mHeight, mFormat); + res = native_window_set_buffers_dimensions(mConsumerInterface.get(), + mWidth, mHeight); if (res != OK) { - ALOGE("%s: Unable to configure buffer geometry" - " %d x %d, format 0x%x for stream %d", - __FUNCTION__, mWidth, mHeight, mFormat, mId); + ALOGE("%s: Unable to configure buffer dimensions" + " %d x %d for stream %d", + __FUNCTION__, mWidth, mHeight, mId); + mState = CONNECTED; + return res; + } + res = native_window_set_buffers_format(mConsumerInterface.get(), + mFormat); + if (res != OK) { + ALOGE("%s: Unable to configure buffer format" + " 0x%x for stream %d", + __FUNCTION__, mFormat, mId); mState = CONNECTED; return res; } @@ -454,8 +463,8 @@ cleanUpBuffers: res = mConsumerInterface->cancelBuffer(mConsumerInterface.get(), anwBuffers[i], -1); } - delete anwBuffers; - delete buffers; + delete[] anwBuffers; + delete[] buffers; return res; } diff --git a/tests/hardware/struct-size.cpp b/tests/hardware/struct-size.cpp index 4207ea80..acb9d2d6 100644 --- a/tests/hardware/struct-size.cpp +++ b/tests/hardware/struct-size.cpp @@ -27,11 +27,11 @@ template static constexpr size_t CheckSizeHelper(size_t, size_t); -template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t size64) { +template<> constexpr size_t CheckSizeHelper<4>(size_t size32, size_t /* size64 */) { return size32; } -template<> constexpr size_t CheckSizeHelper<8>(size_t size32, size_t size64) { +template<> constexpr size_t CheckSizeHelper<8>(size_t /* size32 */, size_t size64) { return size64; } diff --git a/tests/hwc/Android.mk b/tests/hwc/Android.mk index 4cae9eb1..367f5f47 100644 --- a/tests/hwc/Android.mk +++ b/tests/hwc/Android.mk @@ -3,6 +3,7 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libcnativewindow LOCAL_SRC_FILES := cnativewindow.c util.c +LOCAL_CFLAGS := -Wno-unused-parameter include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) diff --git a/tests/hwc/cnativewindow.c b/tests/hwc/cnativewindow.c index 76f45643..5c16afbe 100644 --- a/tests/hwc/cnativewindow.c +++ b/tests/hwc/cnativewindow.c @@ -337,8 +337,8 @@ static int cnw_perform(aWindow *base, int op, ...) { TRACE("set scaling mode %d\n", va_arg(ap,int)); return 0; case NATIVE_WINDOW_SET_BUFFERS_DIMENSIONS: { - int w = va_arg(ap,int); - int h = va_arg(ap,int); + unsigned int w = va_arg(ap,unsigned int); + unsigned int h = va_arg(ap,unsigned int); if ((w == win->width) && (h == win->height)) { TRACE("set buffers dimensions %d x %d\n", w, h); return 0; @@ -377,7 +377,7 @@ static int hwc_init(CNativeWindow *win) { unsigned i; int r; uint32_t configs[32]; - uint32_t numconfigs = 32; + size_t numconfigs = 32; int32_t values[8]; if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) { diff --git a/tests/input/evdev/Android.mk b/tests/input/evdev/Android.mk index 167cbc28..8761da8b 100644 --- a/tests/input/evdev/Android.mk +++ b/tests/input/evdev/Android.mk @@ -17,6 +17,11 @@ LOCAL_CLANG := true LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter LOCAL_CPPFLAGS += -std=c++14 +# 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 +# mkfifo fails on existing files. +LOCAL_CFLAGS += -Wno-deprecated-declarations + LOCAL_MODULE := libinput_evdevtests LOCAL_MODULE_TAGS := tests diff --git a/tests/keymaster/keymaster_test.cpp b/tests/keymaster/keymaster_test.cpp index e5e1dfd2..6266d40e 100644 --- a/tests/keymaster/keymaster_test.cpp +++ b/tests/keymaster/keymaster_test.cpp @@ -395,8 +395,8 @@ class KeymasterGenerateECTest : public KeymasterBaseTest, TEST_P(KeymasterGenerateRSATest, GenerateKeyPair_RSA_Success) { keymaster_keypair_t key_type = TYPE_RSA; keymaster_rsa_keygen_params_t params = { - modulus_size: GetParam(), - public_exponent: RSA_F4, + .modulus_size = GetParam(), + .public_exponent = RSA_F4, }; uint8_t* key_blob; @@ -443,7 +443,7 @@ INSTANTIATE_TEST_CASE_P(RSA, TEST_P(KeymasterGenerateECTest, GenerateKeyPair_EC_Success) { keymaster_keypair_t key_type = TYPE_EC; keymaster_ec_keygen_params_t params = { - field_size: GetParam(), + .field_size = GetParam(), }; uint8_t* key_blob; @@ -864,8 +864,8 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_Success) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; uint8_t* sig; @@ -904,7 +904,7 @@ TEST_F(KeymasterTest, SignData_EC_Success) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_ec_sign_params_t params = { - digest_type: DIGEST_NONE, + .digest_type = DIGEST_NONE, }; uint8_t* sig; @@ -952,8 +952,8 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_InvalidSizeInput_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; uint8_t* sig; @@ -971,8 +971,8 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_InvalidSizeInput_Failure) { TEST_F(KeymasterTest, SignData_RSA_Raw_NullKey_Failure) { keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; uint8_t* sig; @@ -1002,8 +1002,8 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_NullInput_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; uint8_t* sig; @@ -1030,8 +1030,8 @@ TEST_F(KeymasterTest, SignData_RSA_Raw_NullOutput_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; uint8_t* sig; @@ -1061,8 +1061,8 @@ TEST_F(KeymasterTest, VerifyData_RSA_Raw_Success) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1)); @@ -1092,7 +1092,7 @@ TEST_F(KeymasterTest, VerifyData_EC_Raw_Success) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_ec_sign_params_t params = { - digest_type: DIGEST_NONE, + .digest_type = DIGEST_NONE, }; uint8_t* sig; @@ -1129,8 +1129,8 @@ TEST_F(KeymasterTest, VerifyData_RSA_Raw_BadSignature_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; ASSERT_EQ(-1, @@ -1154,7 +1154,7 @@ TEST_F(KeymasterTest, VerifyData_EC_Raw_BadSignature_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_ec_sign_params_t params = { - digest_type: DIGEST_NONE, + .digest_type = DIGEST_NONE, }; ASSERT_EQ(-1, @@ -1166,8 +1166,8 @@ TEST_F(KeymasterTest, VerifyData_EC_Raw_BadSignature_Failure) { TEST_F(KeymasterTest, VerifyData_RSA_Raw_NullKey_Failure) { keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1)); @@ -1194,8 +1194,8 @@ TEST_F(KeymasterTest, VerifyData_RSA_NullInput_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; UniqueReadOnlyBlob testSig(TEST_SIGN_RSA_SIGNATURE_1, sizeof(TEST_SIGN_RSA_SIGNATURE_1)); @@ -1222,8 +1222,8 @@ TEST_F(KeymasterTest, VerifyData_RSA_NullSignature_Failure) { UniqueKey key(&sDevice, key_blob, key_blob_length); keymaster_rsa_sign_params_t params = { - digest_type: DIGEST_NONE, - padding_type: PADDING_NONE, + .digest_type = DIGEST_NONE, + .padding_type = PADDING_NONE, }; UniqueReadOnlyBlob testData(TEST_SIGN_DATA_1, sizeof(TEST_SIGN_DATA_1)); diff --git a/tests/nusensors/nusensors.cpp b/tests/nusensors/nusensors.cpp index 3c8eae99..55b77850 100644 --- a/tests/nusensors/nusensors.cpp +++ b/tests/nusensors/nusensors.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -57,7 +58,7 @@ char const* getSensorName(int type) { return "ukn"; } -int main(int argc, char** argv) +int main(int /* argc */, char** /* argv */) { int err; struct sensors_poll_device_t* device; @@ -131,7 +132,7 @@ int main(int argc, char** argv) const sensors_event_t& data = buffer[i]; if (data.version != sizeof(sensors_event_t)) { - printf("incorrect event version (version=%d, expected=%d", + printf("incorrect event version (version=%d, expected=%zu", data.version, sizeof(sensors_event_t)); break; } @@ -144,7 +145,7 @@ int main(int argc, char** argv) case SENSOR_TYPE_GRAVITY: case SENSOR_TYPE_LINEAR_ACCELERATION: case SENSOR_TYPE_ROTATION_VECTOR: - printf("sensor=%s, time=%lld, value=<%5.1f,%5.1f,%5.1f>\n", + printf("sensor=%s, time=%" PRId64 ", value=<%5.1f,%5.1f,%5.1f>\n", getSensorName(data.type), data.timestamp, data.data[0], @@ -158,14 +159,14 @@ int main(int argc, char** argv) case SENSOR_TYPE_PROXIMITY: case SENSOR_TYPE_RELATIVE_HUMIDITY: case SENSOR_TYPE_AMBIENT_TEMPERATURE: - printf("sensor=%s, time=%lld, value=%f\n", + printf("sensor=%s, time=%" PRId64 ", value=%f\n", getSensorName(data.type), data.timestamp, data.data[0]); break; default: - printf("sensor=%d, time=%lld, value=<%f,%f,%f, ...>\n", + printf("sensor=%d, time=% " PRId64 ", value=<%f,%f,%f, ...>\n", data.type, data.timestamp, data.data[0],