Eliminate warnings, add -Wall and -Werror to all projects.
This change enables all warnings and treats warnings as errors. As
a result, nobody should be able to submit new code to bluedroid
that contains compiler warnings. Instead, they should fix the warnings
before submitting.
This change has already caught a type mismatch bug in
stack/avrc/avrc_api.c where an integer was being stored in a boolean.
Change-Id: Ic41960754b39a1a6aa37f1c1095003195f466183
diff --git a/Android.mk b/Android.mk
index 5f2d274..f0f6970 100644
--- a/Android.mk
+++ b/Android.mk
@@ -9,6 +9,8 @@
bdroid_CFLAGS := -DHAS_NO_BDROID_BUILDCFG
endif
+bdroid_CFLAGS += -Wall -Werror
+
include $(call all-subdir-makefiles)
# Cleanup our locals
diff --git a/gki/Android.mk b/gki/Android.mk
index 4520e45..ec4546a 100644
--- a/gki/Android.mk
+++ b/gki/Android.mk
@@ -11,7 +11,7 @@
$(LOCAL_PATH)/../utils/include \
$(bdroid_C_INCLUDES) \
-LOCAL_CFLAGS += -Werror -Wno-error=unused-parameter $(bdroid_CFLAGS) -std=c99
+LOCAL_CFLAGS += -Wno-error=unused-parameter $(bdroid_CFLAGS) -std=c99
ifeq ($(BOARD_HAVE_BLUETOOTH_BCM),true)
LOCAL_CFLAGS += \
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c
index c572f94..09f167a 100644
--- a/stack/avrc/avrc_api.c
+++ b/stack/avrc/avrc_api.c
@@ -528,7 +528,7 @@
tAVRC_MSG msg;
UINT8 *p_data;
UINT8 *p_begin;
- BOOLEAN drop = FALSE;
+ UINT8 drop = 0;
BOOLEAN free = TRUE;
BT_HDR *p_rsp = NULL;
UINT8 *p_rsp_data;
diff --git a/test/bluedroidtest/bluedroidtest.c b/test/bluedroidtest/bluedroidtest.c
index 2b517df..8ec0e1e 100644
--- a/test/bluedroidtest/bluedroidtest.c
+++ b/test/bluedroidtest/bluedroidtest.c
@@ -58,6 +58,8 @@
#define CASE_RETURN_STR(const) case const: return #const;
+#define UNUSED __attribute__((unused))
+
/************************************************************************************
** Local type definitions
************************************************************************************/
@@ -469,7 +471,7 @@
}
}
-static void dut_mode_recv(uint16_t opcode, uint8_t *buf, uint8_t len)
+static void dut_mode_recv(uint16_t UNUSED opcode, uint8_t UNUSED *buf, uint8_t UNUSED len)
{
bdt_log("DUT MODE RECV : NOT IMPLEMENTED");
}
@@ -611,7 +613,7 @@
** Console commands
*******************************************************************************/
-void do_help(char *p)
+void do_help(char UNUSED *p)
{
int i = 0;
int max = 0;
@@ -626,7 +628,7 @@
}
}
-void do_quit(char *p)
+void do_quit(char UNUSED *p)
{
bdt_shutdown();
}
@@ -639,17 +641,17 @@
*
*/
-void do_init(char *p)
+void do_init(char UNUSED *p)
{
bdt_init();
}
-void do_enable(char *p)
+void do_enable(char UNUSED *p)
{
bdt_enable();
}
-void do_disable(char *p)
+void do_disable(char UNUSED *p)
{
bdt_disable();
}
@@ -663,7 +665,7 @@
bdt_le_test_mode(p);
}
-void do_cleanup(char *p)
+void do_cleanup(char UNUSED *p)
{
bdt_cleanup();
}
@@ -731,7 +733,7 @@
do_help(NULL);
}
-int main (int argc, char * argv[])
+int main (int UNUSED argc, char UNUSED *argv[])
{
int opt;
char cmd[128];
diff --git a/utils/Android.mk b/utils/Android.mk
index 4589e5c..d0327e9 100644
--- a/utils/Android.mk
+++ b/utils/Android.mk
@@ -6,7 +6,7 @@
$(LOCAL_PATH)/../gki/ulinux \
$(bdroid_C_INCLUDES)
-LOCAL_CFLAGS += -Werror $(bdroid_CFLAGS) -std=c99
+LOCAL_CFLAGS += $(bdroid_CFLAGS) -std=c99
LOCAL_PRELINK_MODULE:=false
LOCAL_SRC_FILES:= \