Use -Werror in hardware/libhardware
* Remove unused local variables and function.
* Fix unused return value warning.
Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I269eca76cda2222c7a0176e85e92df0bb0924a0e
diff --git a/modules/consumerir/Android.bp b/modules/consumerir/Android.bp
index 6ba37b6..4f700c2 100644
--- a/modules/consumerir/Android.bp
+++ b/modules/consumerir/Android.bp
@@ -17,6 +17,7 @@
relative_install_path: "hw",
proprietary: true,
srcs: ["consumerir.c"],
+ cflags: ["-Wall", "-Werror"],
header_libs: ["libhardware_headers"],
shared_libs: [
"liblog",
diff --git a/modules/fingerprint/Android.bp b/modules/fingerprint/Android.bp
index a824608..22648b1 100644
--- a/modules/fingerprint/Android.bp
+++ b/modules/fingerprint/Android.bp
@@ -17,6 +17,7 @@
relative_install_path: "hw",
proprietary: true,
srcs: ["fingerprint.c"],
+ cflags: ["-Wall", "-Werror"],
header_libs: ["libhardware_headers"],
shared_libs: ["liblog"],
}
diff --git a/modules/local_time/Android.bp b/modules/local_time/Android.bp
index 153b7e4..9f140b3 100644
--- a/modules/local_time/Android.bp
+++ b/modules/local_time/Android.bp
@@ -26,6 +26,7 @@
relative_install_path: "hw",
proprietary: true,
srcs: ["local_time_hw.c"],
+ cflags: ["-Wall", "-Werror"],
header_libs: ["libhardware_headers"],
shared_libs: [
"liblog",
diff --git a/modules/local_time/local_time_hw.c b/modules/local_time/local_time_hw.c
index a2d1a9e..0350e24 100644
--- a/modules/local_time/local_time_hw.c
+++ b/modules/local_time/local_time_hw.c
@@ -72,8 +72,6 @@
hw_device_t** device)
{
struct stub_local_time_device *ltdev;
- struct timespec ts;
- int ret;
if (strcmp(name, LOCAL_TIME_HARDWARE_INTERFACE) != 0)
return -EINVAL;
diff --git a/modules/nfc-nci/Android.bp b/modules/nfc-nci/Android.bp
index 90d2a28..4688a81 100644
--- a/modules/nfc-nci/Android.bp
+++ b/modules/nfc-nci/Android.bp
@@ -21,4 +21,5 @@
"liblog",
"libcutils",
],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/modules/nfc/Android.bp b/modules/nfc/Android.bp
index b4bc9b1..7c69f11 100644
--- a/modules/nfc/Android.bp
+++ b/modules/nfc/Android.bp
@@ -17,6 +17,7 @@
relative_install_path: "hw",
proprietary: true,
srcs: ["nfc_pn544_example.c"],
+ cflags: ["-Wall", "-Werror"],
header_libs: ["libhardware_headers"],
shared_libs: [
"liblog",
diff --git a/modules/power/Android.bp b/modules/power/Android.bp
index 41ac45c..6b0b31f 100644
--- a/modules/power/Android.bp
+++ b/modules/power/Android.bp
@@ -17,6 +17,7 @@
relative_install_path: "hw",
proprietary: true,
srcs: ["power.c"],
+ cflags: ["-Wall", "-Werror"],
header_libs: [
"libhardware_headers",
"libutils_headers",
diff --git a/modules/sensors/Android.bp b/modules/sensors/Android.bp
index 1d15065..64cf2a9 100644
--- a/modules/sensors/Android.bp
+++ b/modules/sensors/Android.bp
@@ -12,4 +12,5 @@
"libdl"
],
export_include_dirs: ["."],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/modules/sensors/multihal.cpp b/modules/sensors/multihal.cpp
index b5360cc..a1f0104 100644
--- a/modules/sensors/multihal.cpp
+++ b/modules/sensors/multihal.cpp
@@ -515,6 +515,7 @@
if (ctx != NULL) {
int retval = ctx->close();
delete ctx;
+ return retval;
}
if (sub_hw_modules != nullptr) {
@@ -586,15 +587,6 @@
static int open_sensors(const struct hw_module_t* module, const char* name,
struct hw_device_t** device);
-static bool starts_with(const char* s, const char* prefix) {
- if (s == NULL || prefix == NULL) {
- return false;
- }
- size_t s_size = strlen(s);
- size_t prefix_size = strlen(prefix);
- return s_size >= prefix_size && strncmp(s, prefix, prefix_size) == 0;
-}
-
/*
* Adds valid paths from the config file to the vector passed in.
* The vector must not be null.
diff --git a/modules/tv_input/Android.bp b/modules/tv_input/Android.bp
index 4d2369e..b9d8afa 100644
--- a/modules/tv_input/Android.bp
+++ b/modules/tv_input/Android.bp
@@ -22,4 +22,5 @@
"liblog",
],
srcs: ["tv_input.cpp"],
+ cflags: ["-Wall", "-Werror"],
}
diff --git a/modules/vibrator/Android.bp b/modules/vibrator/Android.bp
index fdbfd61..13ffc83 100644
--- a/modules/vibrator/Android.bp
+++ b/modules/vibrator/Android.bp
@@ -21,5 +21,6 @@
proprietary: true,
header_libs: ["libhardware_headers"],
srcs: ["vibrator.c"],
+ cflags: ["-Wall", "-Werror"],
shared_libs: ["liblog"],
}
diff --git a/modules/vibrator/vibrator.c b/modules/vibrator/vibrator.c
index 950bc59..8042b57 100644
--- a/modules/vibrator/vibrator.c
+++ b/modules/vibrator/vibrator.c
@@ -108,7 +108,6 @@
static bool vibra_led_exists()
{
- int fd;
char file_str[50];
snprintf(file_str, sizeof(file_str), "%s/%s", LED_DEVICE, "activate");