Use -Werror in hardware/libhardware/modules

* Remove unused local variables.
* Remove or comment out unused static functions.
* Fix trivial bugs found by unused value warnings.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I99389b883c89551850180d25241a35a40bb77b26
diff --git a/modules/audio_remote_submix/audio_hw.cpp b/modules/audio_remote_submix/audio_hw.cpp
index 6c538ce..cc9d263 100644
--- a/modules/audio_remote_submix/audio_hw.cpp
+++ b/modules/audio_remote_submix/audio_hw.cpp
@@ -486,7 +486,6 @@
                                              const struct submix_stream_in * const in,
                                              const struct submix_stream_out * const out)
 {
-    MonoPipe* sink;
     ALOGV("submix_audio_device_destroy_pipe_l()");
     int route_idx = -1;
     if (in != NULL) {
@@ -1086,7 +1085,6 @@
 {
     struct submix_stream_in * const in = audio_stream_in_get_submix_stream_in(stream);
     struct submix_audio_device * const rsxadev = in->dev;
-    struct audio_config *format;
     const size_t frame_size = audio_stream_in_frame_size(stream);
     const size_t frames_to_read = bytes / frame_size;
 
diff --git a/modules/camera/3_0/Android.mk b/modules/camera/3_0/Android.mk
index ae68ed5..3071a03 100644
--- a/modules/camera/3_0/Android.mk
+++ b/modules/camera/3_0/Android.mk
@@ -38,7 +38,7 @@
 	libsync \
 	libutils \
 
-LOCAL_CFLAGS += -Wall -Wextra -fvisibility=hidden
+LOCAL_CFLAGS += -Wall -Wextra -Werror -fvisibility=hidden
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/modules/camera/3_4/Android.mk b/modules/camera/3_4/Android.mk
index d4201ba..ddf843f 100644
--- a/modules/camera/3_4/Android.mk
+++ b/modules/camera/3_4/Android.mk
@@ -32,7 +32,7 @@
 
 v4l2_static_libs :=
 
-v4l2_cflags := -fno-short-enums -Wall -Wextra -fvisibility=hidden
+v4l2_cflags := -fno-short-enums -Wall -Wextra -Werror -fvisibility=hidden
 
 v4l2_c_includes := $(call include-path-for, camera)
 
diff --git a/modules/hwcomposer/Android.mk b/modules/hwcomposer/Android.mk
index da0f6db..5dbabe2 100644
--- a/modules/hwcomposer/Android.mk
+++ b/modules/hwcomposer/Android.mk
@@ -26,4 +26,5 @@
 LOCAL_MODULE := hwcomposer.default
 LOCAL_CFLAGS:= -DLOG_TAG=\"hwcomposer\"
 LOCAL_MODULE_TAGS := optional
+LOCAL_CFLAGS += -Wall -Werror
 include $(BUILD_SHARED_LIBRARY)
diff --git a/modules/hwcomposer/hwcomposer.cpp b/modules/hwcomposer/hwcomposer.cpp
index 31e362a..cc0d873 100644
--- a/modules/hwcomposer/hwcomposer.cpp
+++ b/modules/hwcomposer/hwcomposer.cpp
@@ -55,6 +55,7 @@
 
 /*****************************************************************************/
 
+#if 0
 static void dump_layer(hwc_layer_1_t const* l) {
     ALOGD("\ttype=%d, flags=%08x, handle=%p, tr=%02x, blend=%04x, {%d,%d,%d,%d}, {%d,%d,%d,%d}",
             l->compositionType, l->flags, l->handle, l->transform, l->blending,
@@ -67,6 +68,7 @@
             l->displayFrame.right,
             l->displayFrame.bottom);
 }
+#endif
 
 static int hwc_prepare(hwc_composer_device_1_t * /*dev*/,
         size_t /*numDisplays*/, hwc_display_contents_1_t** displays) {
diff --git a/modules/input/evdev/Android.mk b/modules/input/evdev/Android.mk
index cb12964..df16b53 100644
--- a/modules/input/evdev/Android.mk
+++ b/modules/input/evdev/Android.mk
@@ -55,7 +55,7 @@
     liblog
 
 LOCAL_CLANG := true
-LOCAL_CPPFLAGS += -Wno-unused-parameter
+LOCAL_CPPFLAGS += -Wall -Werror -Wno-unused-parameter
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/modules/input/evdev/InputDevice.cpp b/modules/input/evdev/InputDevice.cpp
index 5f90982..3b72f1f 100644
--- a/modules/input/evdev/InputDevice.cpp
+++ b/modules/input/evdev/InputDevice.cpp
@@ -95,19 +95,6 @@
     return INPUT_DEVICE_CLASS_JOYSTICK;
 }
 
-static bool getBooleanProperty(const InputProperty& prop) {
-    const char* propValue = prop.getValue();
-    if (propValue == nullptr) return false;
-
-    char* end;
-    int value = std::strtol(propValue, &end, 10);
-    if (*end != '\0') {
-        ALOGW("Expected boolean for property %s; value=%s", prop.getKey(), propValue);
-        return false;
-    }
-    return value;
-}
-
 EvdevDevice::EvdevDevice(InputHostInterface* host, const std::shared_ptr<InputDeviceNode>& node) :
     mHost(host), mDeviceNode(node), mDeviceDefinition(mHost->createDeviceDefinition()) {
 
diff --git a/modules/sensors/Android.mk b/modules/sensors/Android.mk
index ca277e6..5ef6a97 100644
--- a/modules/sensors/Android.mk
+++ b/modules/sensors/Android.mk
@@ -25,7 +25,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_PROPRIETARY_MODULE := true
 
-LOCAL_CFLAGS := -DLOG_TAG=\"MultiHal\"
+LOCAL_CFLAGS := -Wall -Werror -DLOG_TAG=\"MultiHal\"
 
 LOCAL_SRC_FILES := \
     multihal.cpp \
diff --git a/modules/sensors/tests/Android.mk b/modules/sensors/tests/Android.mk
index 010bb90..dcf4f24 100644
--- a/modules/sensors/tests/Android.mk
+++ b/modules/sensors/tests/Android.mk
@@ -5,7 +5,7 @@
 LOCAL_SRC_FILES := \
 	SensorEventQueue_test.cpp
 
-#LOCAL_CFLAGS := -g
+LOCAL_CFLAGS := -Wall -Werror
 LOCAL_MODULE := sensorstests
 
 LOCAL_STATIC_LIBRARIES := libcutils libutils
diff --git a/modules/usbcamera/Android.mk b/modules/usbcamera/Android.mk
index 162b158..6a36ac4 100644
--- a/modules/usbcamera/Android.mk
+++ b/modules/usbcamera/Android.mk
@@ -38,7 +38,7 @@
 	libsync \
 	libutils \
 
-LOCAL_CFLAGS += -Wall -Wextra -fvisibility=hidden
+LOCAL_CFLAGS += -Wall -Wextra -Werror -fvisibility=hidden
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/modules/vehicle/Android.mk b/modules/vehicle/Android.mk
index 34c943c..ad2e527 100644
--- a/modules/vehicle/Android.mk
+++ b/modules/vehicle/Android.mk
@@ -21,6 +21,7 @@
 LOCAL_MODULE_RELATIVE_PATH := hw
 LOCAL_PROPRIETARY_MODULE := true
 LOCAL_SRC_FILES := vehicle.c timeUtil.cpp
+LOCAL_CFLAGS := -Wall -Werror
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_SHARED_LIBRARIES := liblog libcutils libutils
 LOCAL_MODULE_TAGS := optional
diff --git a/modules/vehicle/vehicle.c b/modules/vehicle/vehicle.c
index 66e29c0..66a2137 100644
--- a/modules/vehicle/vehicle.c
+++ b/modules/vehicle/vehicle.c
@@ -465,6 +465,9 @@
     }
     int ret_code = pthread_create(
                                   &sub->thread, NULL, (void *(*)(void*))fake_event_thread, sub);
+    if (ret_code != 0) {
+        return -ret_code;
+    }
     print_subscribe_info(impl);
     pthread_mutex_unlock(&lock_);
     return 0;
diff --git a/modules/vr/Android.mk b/modules/vr/Android.mk
index 0305745..2cdcb1b 100644
--- a/modules/vr/Android.mk
+++ b/modules/vr/Android.mk
@@ -23,6 +23,6 @@
 LOCAL_HEADER_LIBRARIES := libhardware_headers
 LOCAL_SHARED_LIBRARIES := libcutils
 LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS += -Wno-unused-parameter
+LOCAL_CFLAGS += -Wall -Werror -Wno-unused-parameter
 
 include $(BUILD_SHARED_LIBRARY)