Merge "Factor out duplicated warning options"
diff --git a/android/app/Android.bp b/android/app/Android.bp
index 5af8cfd..2b1d388 100644
--- a/android/app/Android.bp
+++ b/android/app/Android.bp
@@ -69,12 +69,6 @@
         "libbluetooth",
         "libc++fs",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wextra",
-        "-Wno-unused-parameter",
-    ],
     sanitize: {
         scs: true,
     },
diff --git a/system/audio_bluetooth_hw/Android.bp b/system/audio_bluetooth_hw/Android.bp
index 9dc7f53..cc89bdf 100644
--- a/system/audio_bluetooth_hw/Android.bp
+++ b/system/audio_bluetooth_hw/Android.bp
@@ -9,8 +9,18 @@
     default_applicable_licenses: ["system_bt_license"],
 }
 
+cc_defaults {
+    name: "audio_bluetooth_hw_defaults",
+    defaults: ["fluoride_common_options"],
+    cflags: [
+        // suppress the warning in stream_apis.cc
+        "-Wno-sign-compare",
+    ],
+}
+
 cc_library_shared {
     name: "audio.bluetooth.default",
+    defaults: ["audio_bluetooth_hw_defaults"],
     relative_install_path: "hw",
     proprietary: true,
     srcs: [
@@ -37,15 +47,11 @@
         "libbluetooth_audio_session",
         "libhidlbase",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
 }
 
 cc_test {
     name: "audio_bluetooth_hw_test",
+    defaults: ["audio_bluetooth_hw_defaults"],
     srcs: [
         "utils.cc",
         "utils_unittest.cc",
@@ -56,9 +62,4 @@
         "liblog",
         "libutils",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-    ],
 }
diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index 732d585..f522cf4 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -35,14 +35,11 @@
 
 cc_library {
     name: "libstatslog_bt",
+    defaults: ["fluoride_common_options"],
     host_supported: true,
     generated_sources: ["statslog_bt.cpp"],
     generated_headers: ["statslog_bt.h"],
     export_generated_headers: ["statslog_bt.h"],
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
     shared_libs: [
         "libcutils",
     ],
diff --git a/system/build/Android.bp b/system/build/Android.bp
index 32f7971..37dae66 100644
--- a/system/build/Android.bp
+++ b/system/build/Android.bp
@@ -23,8 +23,20 @@
     pluginFor: ["soong_build"],
 }
 
+cc_defaults {
+    name: "fluoride_common_options",
+    cflags: [
+        "-Wall",
+        "-Wextra",
+        "-Werror",
+        // there are too many unused parameters in all the code.
+        "-Wno-unused-parameter",
+    ],
+}
+
 fluoride_defaults {
     name: "libchrome_support_defaults",
+    defaults: ["fluoride_common_options"],
     static_libs: [
         "libchrome",
         "libmodpb64",
@@ -33,11 +45,6 @@
     shared_libs: [
       "libbase",
     ],
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-    ],
     target: {
         darwin: {
             enabled: false,
@@ -54,12 +61,8 @@
 // default to be used only on platform libs that can rely on shared libchrome
 fluoride_defaults {
     name: "libchrome_shared_support_defaults",
+    defaults: ["fluoride_common_options"],
     shared_libs: ["libchrome"],
-    cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
-    ],
     target: {
         darwin: {
             enabled: false,
@@ -72,13 +75,12 @@
 // requires no shared libraries, and no explicit sanitization.
 fluoride_defaults {
     name: "fluoride_types_defaults_fuzzable",
+    defaults: ["fluoride_common_options"],
     cflags: [
         "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
         "-fvisibility=hidden",
         // struct BT_HDR is defined as a variable-size header in a struct.
         "-Wno-gnu-variable-sized-type-not-at-end",
-        // there are too many unused parameters in all the code.
-        "-Wno-unused-parameter",
         "-DLOG_NDEBUG=1",
     ],
     conlyflags: [
diff --git a/system/embdrv/lc3/Android.bp b/system/embdrv/lc3/Android.bp
index a16f30e..6f92aee 100644
--- a/system/embdrv/lc3/Android.bp
+++ b/system/embdrv/lc3/Android.bp
@@ -21,9 +21,7 @@
     cflags: [
         "-O3",
         "-ffast-math",
-        "-Werror",
         "-Wmissing-braces",
-        "-Wno-unused-parameter",
         "-Wno-#warnings",
         "-Wuninitialized",
         "-Wno-self-assign",
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index 4d971bf..2c47475 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -10,6 +10,9 @@
 
 cc_defaults {
     name: "gd_defaults",
+    defaults: [
+        "fluoride_common_options",
+    ],
     tidy_checks: [
         "-performance-unnecessary-value-param",
     ],
@@ -42,14 +45,12 @@
         "-fvisibility=hidden",
         "-DLOG_NDEBUG=1",
         "-DGOOGLE_PROTOBUF_NO_RTTI",
-        "-Wno-unused-parameter",
         "-Wno-unused-result",
     ],
     conlyflags: [
         "-std=c99",
     ],
     header_libs: ["jni_headers"],
-
 }
 
 // Enables code coverage for a set of source files. Must be combined with
diff --git a/system/gd/dumpsys/Android.bp b/system/gd/dumpsys/Android.bp
index 2245651..a7fdaa2 100644
--- a/system/gd/dumpsys/Android.bp
+++ b/system/gd/dumpsys/Android.bp
@@ -177,7 +177,7 @@
 cc_test {
     name: "bluetooth_flatbuffer_tests",
     test_suites: ["device-tests"],
-    defaults: ["mts_defaults"],
+    defaults: ["fluoride_common_options", "mts_defaults"],
     host_supported: true,
     test_options: {
         unit_test: true,
@@ -192,9 +192,4 @@
     generated_headers: [
         "BluetoothFlatbufferTestData_h",
     ],
-    cflags: [
-        "-Werror",
-        "-Wall",
-        "-Wextra",
-    ],
 }
diff --git a/system/gd/dumpsys/bundler/Android.bp b/system/gd/dumpsys/bundler/Android.bp
index ce2c4e2..3754611 100644
--- a/system/gd/dumpsys/bundler/Android.bp
+++ b/system/gd/dumpsys/bundler/Android.bp
@@ -46,13 +46,8 @@
 
 cc_defaults {
     name: "bluetooth_flatbuffer_bundler_defaults",
+    defaults: ["fluoride_common_options"],
     cpp_std: "c++17",
-    cflags: [
-        "-Wall",
-        "-Werror",
-        "-Wno-unused-parameter",
-        "-Wno-unused-variable",
-    ],
     generated_headers: [
         "BluetoothGeneratedBundlerSchema_h_bfbs",
     ],
diff --git a/system/gd/dumpsys/bundler/bundler.cc b/system/gd/dumpsys/bundler/bundler.cc
index 08a2cca..f2e6559 100644
--- a/system/gd/dumpsys/bundler/bundler.cc
+++ b/system/gd/dumpsys/bundler/bundler.cc
@@ -153,7 +153,7 @@
   fprintf(fp, "extern const std::string& GetBundledSchemaData();\n");
   fprintf(fp, "const unsigned char %sdata_[%zu] = {\n", namespace_prefix.c_str(), data_len);
 
-  for (auto i = 0; i < data_len; i++) {
+  for (size_t i = 0; i < data_len; i++) {
     fprintf(fp, " 0x%02x", data[i]);
     if (i != data_len - 1) {
       fprintf(fp, ",");
diff --git a/system/gd/dumpsys/bundler/test.cc b/system/gd/dumpsys/bundler/test.cc
index 929b6ff..24d2f91 100644
--- a/system/gd/dumpsys/bundler/test.cc
+++ b/system/gd/dumpsys/bundler/test.cc
@@ -66,7 +66,7 @@
   std::vector<flatbuffers::Offset<bluetooth::dumpsys::BundledSchemaMap>> vector_map;
   std::list<std::string> bundled_names;
   ASSERT_TRUE(CreateBinarySchemaBundle(&builder, filenames, &vector_map, &bundled_names));
-  ASSERT_EQ(0, vector_map.size());
+  ASSERT_EQ((unsigned int)0, vector_map.size());
 }
 
 TEST_F(BundlerTest, WriteHeaderFile) {
diff --git a/system/test/rootcanal/Android.bp b/system/test/rootcanal/Android.bp
index 38a6cdd..bf81f49 100644
--- a/system/test/rootcanal/Android.bp
+++ b/system/test/rootcanal/Android.bp
@@ -51,9 +51,6 @@
     ],
     cflags: [
         "-fvisibility=hidden",
-        "-Wall",
-        "-Wextra",
-        "-Werror",
         "-DHAS_NO_BDROID_BUILDCFG",
     ],
     generated_headers: [
@@ -106,9 +103,6 @@
         "libprotobuf-cpp-lite",
     ],
     cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
         "-DHAS_NO_BDROID_BUILDCFG",
     ],
     generated_headers: [
diff --git a/system/vendor_libs/linux/interface/Android.bp b/system/vendor_libs/linux/interface/Android.bp
index 85fde7d..a92124e 100644
--- a/system/vendor_libs/linux/interface/Android.bp
+++ b/system/vendor_libs/linux/interface/Android.bp
@@ -24,6 +24,7 @@
 
 cc_binary {
     name: "android.hardware.bluetooth@1.1-service.btlinux",
+    defaults: ["fluoride_common_options"],
     proprietary: true,
     relative_install_path: "hw",
     srcs: [
@@ -32,10 +33,6 @@
         "bluetooth_hci.cc",
         "service.cc",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
     header_libs: ["libbluetooth_headers"],
     shared_libs: [
         "android.hardware.bluetooth@1.0",
@@ -57,14 +54,11 @@
 
 cc_library_static {
     name: "async_fd_watcher",
+    defaults: ["fluoride_common_options"],
     proprietary: true,
     srcs: [
         "async_fd_watcher.cc",
     ],
-    cflags: [
-        "-Wall",
-        "-Werror",
-    ],
     shared_libs: [
         "liblog",
     ],
diff --git a/tools/rootcanal/Android.bp b/tools/rootcanal/Android.bp
index 11a3478..702ddd3 100644
--- a/tools/rootcanal/Android.bp
+++ b/tools/rootcanal/Android.bp
@@ -16,14 +16,12 @@
 cc_defaults {
     name: "rootcanal_defaults",
     defaults: [
+        "fluoride_common_options",
         "gd_defaults",
         "gd_clang_tidy",
         "gd_clang_tidy_ignore_android",
     ],
     cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
         "-fvisibility=hidden",
         "-DROOTCANAL_LMP",
     ],
@@ -157,6 +155,7 @@
 cc_test_host {
     name: "rootcanal_test_host",
     defaults: [
+        "fluoride_common_options",
         "clang_file_coverage",
         "clang_coverage_bin",
     ],
@@ -185,9 +184,6 @@
         "libbt-rootcanal",
     ],
     cflags: [
-        "-Wall",
-        "-Wextra",
-        "-Werror",
         "-fvisibility=hidden",
         "-DLOG_NDEBUG=1",
     ],