AudioFlinger: Group common compile flags together

Test: compiles
Bug: 286936439
Merged-In: Ie15e07886e2e4fcc813b1cea18ad87bc1b892fd4
Change-Id: Ie15e07886e2e4fcc813b1cea18ad87bc1b892fd4
(cherry picked from commit 7bac54fc96ceb933a9f06e75c3c20f1df46fea5b)
diff --git a/services/audioflinger/Android.bp b/services/audioflinger/Android.bp
index 90b4057..5bb545a 100644
--- a/services/audioflinger/Android.bp
+++ b/services/audioflinger/Android.bp
@@ -94,37 +94,38 @@
     "-performance-no-int-to-ptr",
 ]
 
+audioflinger_base_cflags = [
+    "-Wall",
+    "-Wdeprecated",
+    "-Werror",
+    "-Werror=implicit-fallthrough",
+    "-Werror=sometimes-uninitialized",
+    "-Werror=conditional-uninitialized",
+    "-Wextra",
+
+    // suppress some warning chatter.
+    "-Wno-deprecated-copy-with-dtor",
+    "-Wno-deprecated-copy-with-user-provided-dtor",
+
+    "-Wredundant-decls",
+    "-Wshadow",
+    "-Wstrict-aliasing",
+    "-fstrict-aliasing",
+    "-Wthread-safety",
+    //"-Wthread-safety-negative", // experimental - looks broken in R.
+    "-Wunreachable-code",
+    "-Wunreachable-code-break",
+    "-Wunreachable-code-return",
+    "-Wunused",
+    "-Wused-but-marked-unused",
+]
+
 // Eventually use common tidy defaults
 cc_defaults {
     name: "audioflinger_flags_defaults",
     // https://clang.llvm.org/docs/UsersManual.html#command-line-options
     // https://clang.llvm.org/docs/DiagnosticsReference.html
-    cflags: [
-        "-Wall",
-        "-Wdeprecated",
-        "-Werror",
-        "-Werror=implicit-fallthrough",
-        "-Werror=sometimes-uninitialized",
-        "-Werror=conditional-uninitialized",
-        "-Wextra",
-
-        // suppress some warning chatter.
-        "-Wno-deprecated-copy-with-dtor",
-        "-Wno-deprecated-copy-with-user-provided-dtor",
-
-        "-Wredundant-decls",
-        "-Wshadow",
-        "-Wstrict-aliasing",
-        "-fstrict-aliasing",
-        "-Wthread-safety",
-        //"-Wthread-safety-negative", // experimental - looks broken in R.
-        "-Wunreachable-code",
-        "-Wunreachable-code-break",
-        "-Wunreachable-code-return",
-        "-Wunused",
-        "-Wused-but-marked-unused",
-        "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
-    ],
+    cflags: audioflinger_base_cflags,
     // https://clang.llvm.org/extra/clang-tidy/
     tidy: true,
     tidy_checks: tidy_errors,
diff --git a/services/audioflinger/afutils/Android.bp b/services/audioflinger/afutils/Android.bp
index 5eac519..08376ba 100644
--- a/services/audioflinger/afutils/Android.bp
+++ b/services/audioflinger/afutils/Android.bp
@@ -69,32 +69,7 @@
     name: "audioflinger_utils_flags_defaults",
     // https://clang.llvm.org/docs/UsersManual.html#command-line-options
     // https://clang.llvm.org/docs/DiagnosticsReference.html
-    cflags: [
-        "-Wall",
-        "-Wdeprecated",
-        "-Werror",
-        "-Werror=implicit-fallthrough",
-        "-Werror=sometimes-uninitialized",
-        "-Werror=conditional-uninitialized",
-        "-Wextra",
-
-        // suppress some warning chatter.
-        "-Wno-deprecated-copy-with-dtor",
-        "-Wno-deprecated-copy-with-user-provided-dtor",
-
-        "-Wredundant-decls",
-        "-Wshadow",
-        "-Wstrict-aliasing",
-        "-fstrict-aliasing",
-        "-Wthread-safety",
-        //"-Wthread-safety-negative", // experimental - looks broken in R.
-        "-Wunreachable-code",
-        "-Wunreachable-code-break",
-        "-Wunreachable-code-return",
-        "-Wunused",
-        "-Wused-but-marked-unused",
-        "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
-    ],
+    cflags: audioflinger_base_cflags,
     // https://clang.llvm.org/extra/clang-tidy/
     tidy: true,
     tidy_checks: audioflinger_utils_tidy_errors,
diff --git a/services/audioflinger/fastpath/Android.bp b/services/audioflinger/fastpath/Android.bp
index 6c024e7..f555f67 100644
--- a/services/audioflinger/fastpath/Android.bp
+++ b/services/audioflinger/fastpath/Android.bp
@@ -70,32 +70,7 @@
     name: "fastpath_flags_defaults",
     // https://clang.llvm.org/docs/UsersManual.html#command-line-options
     // https://clang.llvm.org/docs/DiagnosticsReference.html
-    cflags: [
-        "-Wall",
-        "-Wdeprecated",
-        "-Werror",
-        "-Werror=implicit-fallthrough",
-        "-Werror=sometimes-uninitialized",
-        "-Werror=conditional-uninitialized",
-        "-Wextra",
-
-        // suppress some warning chatter.
-        "-Wno-deprecated-copy-with-dtor",
-        "-Wno-deprecated-copy-with-user-provided-dtor",
-
-        "-Wredundant-decls",
-        "-Wshadow",
-        "-Wstrict-aliasing",
-        "-fstrict-aliasing",
-        "-Wthread-safety",
-        //"-Wthread-safety-negative", // experimental - looks broken in R.
-        "-Wunreachable-code",
-        "-Wunreachable-code-break",
-        "-Wunreachable-code-return",
-        "-Wunused",
-        "-Wused-but-marked-unused",
-        "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS",
-    ],
+    cflags: audioflinger_base_cflags,
     // https://clang.llvm.org/extra/clang-tidy/
     tidy: true,
     tidy_checks: fastpath_tidy_errors,