Libhardware: Fix tests

Fix some warnings. Silence another. Less build noise.

Change-Id: Ibdbba093c2aca45343bfbe72c551b15d0f94e1b5
diff --git a/tests/camera2/CameraMultiStreamTests.cpp b/tests/camera2/CameraMultiStreamTests.cpp
index 3e29ad6..eb64db1 100644
--- a/tests/camera2/CameraMultiStreamTests.cpp
+++ b/tests/camera2/CameraMultiStreamTests.cpp
@@ -495,9 +495,6 @@
         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 fc5fb36..bf7fb42 100644
--- a/tests/camera2/CameraStreamFixture.h
+++ b/tests/camera2/CameraStreamFixture.h
@@ -186,7 +186,6 @@
     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 d962939..c63c32a 100644
--- a/tests/camera2/camera2_utils.cpp
+++ b/tests/camera2/camera2_utils.cpp
@@ -208,13 +208,13 @@
     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 @@
         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 @@
         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 @@
         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 4207ea8..acb9d2d 100644
--- a/tests/hardware/struct-size.cpp
+++ b/tests/hardware/struct-size.cpp
@@ -27,11 +27,11 @@
 
 template<size_t> 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 4cae9eb..367f5f4 100644
--- a/tests/hwc/Android.mk
+++ b/tests/hwc/Android.mk
@@ -3,6 +3,7 @@
 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 76f4564..5c16afb 100644
--- a/tests/hwc/cnativewindow.c
+++ b/tests/hwc/cnativewindow.c
@@ -337,8 +337,8 @@
 		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 @@
 	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 167cbc2..8761da8 100644
--- a/tests/input/evdev/Android.mk
+++ b/tests/input/evdev/Android.mk
@@ -17,6 +17,11 @@
 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 e5e1dfd..6266d40 100644
--- a/tests/keymaster/keymaster_test.cpp
+++ b/tests/keymaster/keymaster_test.cpp
@@ -395,8 +395,8 @@
 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 @@
 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 @@
     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 @@
     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 @@
     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_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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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_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 @@
     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 @@
     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 3c8eae9..55b7785 100644
--- a/tests/nusensors/nusensors.cpp
+++ b/tests/nusensors/nusensors.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <inttypes.h>
 #include <string.h>
 #include <stdint.h>
 #include <string.h>
@@ -57,7 +58,7 @@
     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 @@
             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 @@
                 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 @@
                 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],