diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index af84be9..b385ea5 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -3,7 +3,7 @@
     cflags: [
         "-Wall",
         "-Wextra",
-        "-Wno-error",
+        "-Werror",
         "-Wno-nullability-completeness",
         "-Os",
     ],
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 57a6c44..38b711f 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -199,10 +199,6 @@
   pid_t main_tid;
   pid_t pseudothread_tid;
 
-  if (target == 1) {
-    LOG(FATAL) << "target died before we could attach (received main tid = " << main_tid << ")";
-  }
-
   if (!android::base::ParseInt(argv[1], &main_tid, 1, std::numeric_limits<pid_t>::max())) {
     LOG(FATAL) << "invalid main tid: " << argv[1];
   }
@@ -211,6 +207,10 @@
     LOG(FATAL) << "invalid pseudothread tid: " << argv[2];
   }
 
+  if (target == 1) {
+    LOG(FATAL) << "target died before we could attach (received main tid = " << main_tid << ")";
+  }
+
   android::procinfo::ProcessInfo target_info;
   if (!android::procinfo::GetProcessInfo(main_tid, &target_info)) {
     LOG(FATAL) << "failed to fetch process info for target " << main_tid;
diff --git a/debuggerd/libdebuggerd/include/tombstone.h b/debuggerd/libdebuggerd/include/tombstone.h
index 8e60278..d2a4a4b 100644
--- a/debuggerd/libdebuggerd/include/tombstone.h
+++ b/debuggerd/libdebuggerd/include/tombstone.h
@@ -43,6 +43,7 @@
                                 ucontext_t* ucontext);
 
 // Compatibility shim.
+__attribute__((__unused__))
 static void engrave_tombstone_ucontext(int tombstone_fd, pid_t, pid_t, uintptr_t abort_msg_address,
                                        siginfo_t* siginfo, ucontext_t* ucontext) {
   engrave_tombstone_ucontext(tombstone_fd, abort_msg_address, siginfo, ucontext);
diff --git a/demangle/Android.bp b/demangle/Android.bp
new file mode 100644
index 0000000..e80cdc5
--- /dev/null
+++ b/demangle/Android.bp
@@ -0,0 +1,65 @@
+//
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_defaults {
+    name: "libdemangle_defaults",
+
+    host_supported: true,
+
+    cflags: [
+        "-Wall",
+        "-Werror",
+        "-Wextra",
+    ],
+}
+
+cc_library {
+    name: "libdemangle",
+    defaults: ["libdemangle_defaults"],
+
+    srcs: [
+        "Demangler.cpp",
+    ],
+
+    local_include_dirs: [
+       "include",
+    ],
+
+    export_include_dirs: [
+       "include",
+    ],
+}
+
+//-------------------------------------------------------------------------
+// Unit Tests
+//-------------------------------------------------------------------------
+cc_test {
+    name: "libdemangle_test",
+    defaults: ["libdemangle_defaults"],
+
+    srcs: [
+        "DemangleTest.cpp",
+    ],
+
+    cflags: [
+        "-O0",
+        "-g",
+    ],
+
+    shared_libs: [
+        "libdemangle",
+    ],
+}
diff --git a/demangle/DemangleTest.cpp b/demangle/DemangleTest.cpp
new file mode 100644
index 0000000..fb68119
--- /dev/null
+++ b/demangle/DemangleTest.cpp
@@ -0,0 +1,436 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include <gtest/gtest.h>
+
+#include <demangle.h>
+
+#include "Demangler.h"
+
+TEST(DemangleTest, VoidArgumentTest) {
+  Demangler demangler;
+
+  ASSERT_EQ("func()", demangler.Parse("_ZN4funcEv"));
+  ASSERT_EQ("func(void&)", demangler.Parse("_ZN4funcERv"));
+  ASSERT_EQ("func(void, void)", demangler.Parse("_ZN4funcEvv"));
+  ASSERT_EQ("func(void*)", demangler.Parse("_ZN4funcEPv"));
+  ASSERT_EQ("func(void const)", demangler.Parse("_ZN4funcEKv"));
+  ASSERT_EQ("func(void volatile)", demangler.Parse("_ZN4funcEVv"));
+}
+
+TEST(DemangleTest, ArgumentModifiers) {
+  Demangler demangler;
+
+  ASSERT_EQ("func(char)", demangler.Parse("_ZN4funcEc"));
+  ASSERT_EQ("func(char*)", demangler.Parse("_ZN4funcEPc"));
+  ASSERT_EQ("func(char**)", demangler.Parse("_ZN4funcEPPc"));
+  ASSERT_EQ("func(char***)", demangler.Parse("_ZN4funcEPPPc"));
+  ASSERT_EQ("func(char&)", demangler.Parse("_ZN4funcERc"));
+  ASSERT_EQ("func(char*&)", demangler.Parse("_ZN4funcERPc"));
+  ASSERT_EQ("func(char&)", demangler.Parse("_ZN4funcERRc"));
+  ASSERT_EQ("func(char*&*)", demangler.Parse("_ZN4funcEPRPc"));
+  ASSERT_EQ("func(char**&)", demangler.Parse("_ZN4funcERRPPc"));
+  ASSERT_EQ("func(char const)", demangler.Parse("_ZN4funcEKc"));
+  ASSERT_EQ("func(char volatile)", demangler.Parse("_ZN4funcEVc"));
+  ASSERT_EQ("func(char volatile const)", demangler.Parse("_ZN4funcEKVc"));
+  ASSERT_EQ("func(char const volatile)", demangler.Parse("_ZN4funcEVKc"));
+  ASSERT_EQ("func(char const* volatile&)", demangler.Parse("_ZN4funcERVPKc"));
+  ASSERT_EQ("func(void, char, short)", demangler.Parse("_ZN4funcEvcs"));
+  ASSERT_EQ("func(void*, char&, short&*)", demangler.Parse("_ZN4funcEPvRcPRs"));
+}
+
+TEST(DemangleTest, FunctionModifiers) {
+  Demangler demangler;
+
+  ASSERT_EQ("func() const", demangler.Parse("_ZNK4funcEv"));
+  ASSERT_EQ("func() volatile", demangler.Parse("_ZNV4funcEv"));
+  ASSERT_EQ("func() volatile const", demangler.Parse("_ZNKV4funcEv"));
+  ASSERT_EQ("func() const volatile", demangler.Parse("_ZNVK4funcEv"));
+}
+
+TEST(DemangleTest, MultiplePartsInName) {
+  Demangler demangler;
+
+  ASSERT_EQ("one::two()", demangler.Parse("_ZN3one3twoEv"));
+  ASSERT_EQ("one::two::three()", demangler.Parse("_ZN3one3two5threeEv"));
+  ASSERT_EQ("one::two::three::four()", demangler.Parse("_ZN3one3two5three4fourEv"));
+  ASSERT_EQ("one::two::three::four::five()", demangler.Parse("_ZN3one3two5three4four4fiveEv"));
+  ASSERT_EQ("one(two::three::four::five)", demangler.Parse("_ZN3oneEN3two5three4four4fiveE"));
+}
+
+TEST(DemangleTest, AnonymousNamespace) {
+  Demangler demangler;
+
+  ASSERT_EQ("(anonymous namespace)::two()", demangler.Parse("_ZN12_GLOBAL__N_13twoEv"));
+  ASSERT_EQ("one::two((anonymous namespace))", demangler.Parse("_ZN3one3twoE12_GLOBAL__N_1"));
+}
+
+TEST(DemangleTest, DestructorValues) {
+  Demangler demangler;
+
+  ASSERT_EQ("one::two::~two()", demangler.Parse("_ZN3one3twoD0Ev"));
+  ASSERT_EQ("one::two::~two()", demangler.Parse("_ZN3one3twoD1Ev"));
+  ASSERT_EQ("one::two::~two()", demangler.Parse("_ZN3one3twoD2Ev"));
+  ASSERT_EQ("one::two::~two()", demangler.Parse("_ZN3one3twoD5Ev"));
+  ASSERT_EQ("one::two::three::~three()", demangler.Parse("_ZN3one3two5threeD0Ev"));
+
+  ASSERT_EQ("_ZN3one3twoD3Ev", demangler.Parse("_ZN3one3twoD3Ev"));
+  ASSERT_EQ("_ZN3one3twoD4Ev", demangler.Parse("_ZN3one3twoD4Ev"));
+  ASSERT_EQ("_ZN3one3twoD6Ev", demangler.Parse("_ZN3one3twoD6Ev"));
+  ASSERT_EQ("_ZN3one3twoD7Ev", demangler.Parse("_ZN3one3twoD7Ev"));
+  ASSERT_EQ("_ZN3one3twoD8Ev", demangler.Parse("_ZN3one3twoD8Ev"));
+  ASSERT_EQ("_ZN3one3twoD9Ev", demangler.Parse("_ZN3one3twoD9Ev"));
+
+  ASSERT_EQ("one::two<three::four>::~two()", demangler.Parse("_ZN3one3twoIN5three4fourEED2Ev"));
+}
+
+TEST(DemangleTest, ConstructorValues) {
+  Demangler demangler;
+
+  ASSERT_EQ("one::two::two()", demangler.Parse("_ZN3one3twoC1Ev"));
+  ASSERT_EQ("one::two::two()", demangler.Parse("_ZN3one3twoC2Ev"));
+  ASSERT_EQ("one::two::two()", demangler.Parse("_ZN3one3twoC3Ev"));
+  ASSERT_EQ("one::two::two()", demangler.Parse("_ZN3one3twoC5Ev"));
+  ASSERT_EQ("one::two::three::three()", demangler.Parse("_ZN3one3two5threeC1Ev"));
+
+  ASSERT_EQ("_ZN3one3twoC0Ev", demangler.Parse("_ZN3one3twoC0Ev"));
+  ASSERT_EQ("_ZN3one3twoC4Ev", demangler.Parse("_ZN3one3twoC4Ev"));
+  ASSERT_EQ("_ZN3one3twoC6Ev", demangler.Parse("_ZN3one3twoC6Ev"));
+  ASSERT_EQ("_ZN3one3twoC7Ev", demangler.Parse("_ZN3one3twoC7Ev"));
+  ASSERT_EQ("_ZN3one3twoC8Ev", demangler.Parse("_ZN3one3twoC8Ev"));
+  ASSERT_EQ("_ZN3one3twoC9Ev", demangler.Parse("_ZN3one3twoC9Ev"));
+
+  ASSERT_EQ("one::two<three::four>::two()", demangler.Parse("_ZN3one3twoIN5three4fourEEC1Ev"));
+}
+
+TEST(DemangleTest, OperatorValues) {
+  Demangler demangler;
+
+  ASSERT_EQ("operator&&()", demangler.Parse("_Zaav"));
+  ASSERT_EQ("operator&()", demangler.Parse("_Zadv"));
+  ASSERT_EQ("operator&()", demangler.Parse("_Zanv"));
+  ASSERT_EQ("operator&=()", demangler.Parse("_ZaNv"));
+  ASSERT_EQ("operator=()", demangler.Parse("_ZaSv"));
+  ASSERT_EQ("operator()()", demangler.Parse("_Zclv"));
+  ASSERT_EQ("operator,()", demangler.Parse("_Zcmv"));
+  ASSERT_EQ("operator~()", demangler.Parse("_Zcov"));
+  ASSERT_EQ("operator delete[]()", demangler.Parse("_Zdav"));
+  ASSERT_EQ("operator*()", demangler.Parse("_Zdev"));
+  ASSERT_EQ("operator delete()", demangler.Parse("_Zdlv"));
+  ASSERT_EQ("operator/()", demangler.Parse("_Zdvv"));
+  ASSERT_EQ("operator/=()", demangler.Parse("_ZdVv"));
+  ASSERT_EQ("operator^()", demangler.Parse("_Zeov"));
+  ASSERT_EQ("operator^=()", demangler.Parse("_ZeOv"));
+  ASSERT_EQ("operator==()", demangler.Parse("_Zeqv"));
+  ASSERT_EQ("operator>=()", demangler.Parse("_Zgev"));
+  ASSERT_EQ("operator>()", demangler.Parse("_Zgtv"));
+  ASSERT_EQ("operator[]()", demangler.Parse("_Zixv"));
+  ASSERT_EQ("operator<=()", demangler.Parse("_Zlev"));
+  ASSERT_EQ("operator<<()", demangler.Parse("_Zlsv"));
+  ASSERT_EQ("operator<<=()", demangler.Parse("_ZlSv"));
+  ASSERT_EQ("operator<()", demangler.Parse("_Zltv"));
+  ASSERT_EQ("operator-()", demangler.Parse("_Zmiv"));
+  ASSERT_EQ("operator-=()", demangler.Parse("_ZmIv"));
+  ASSERT_EQ("operator*()", demangler.Parse("_Zmlv"));
+  ASSERT_EQ("operator*=()", demangler.Parse("_ZmLv"));
+  ASSERT_EQ("operator--()", demangler.Parse("_Zmmv"));
+  ASSERT_EQ("operator new[]()", demangler.Parse("_Znav"));
+  ASSERT_EQ("operator!=()", demangler.Parse("_Znev"));
+  ASSERT_EQ("operator-()", demangler.Parse("_Zngv"));
+  ASSERT_EQ("operator!()", demangler.Parse("_Zntv"));
+  ASSERT_EQ("operator new()", demangler.Parse("_Znwv"));
+  ASSERT_EQ("operator||()", demangler.Parse("_Zoov"));
+  ASSERT_EQ("operator|()", demangler.Parse("_Zorv"));
+  ASSERT_EQ("operator|=()", demangler.Parse("_ZoRv"));
+  ASSERT_EQ("operator->*()", demangler.Parse("_Zpmv"));
+  ASSERT_EQ("operator+()", demangler.Parse("_Zplv"));
+  ASSERT_EQ("operator+=()", demangler.Parse("_ZpLv"));
+  ASSERT_EQ("operator++()", demangler.Parse("_Zppv"));
+  ASSERT_EQ("operator+()", demangler.Parse("_Zpsv"));
+  ASSERT_EQ("operator->()", demangler.Parse("_Zptv"));
+  ASSERT_EQ("operator?()", demangler.Parse("_Zquv"));
+  ASSERT_EQ("operator%()", demangler.Parse("_Zrmv"));
+  ASSERT_EQ("operator%=()", demangler.Parse("_ZrMv"));
+  ASSERT_EQ("operator>>()", demangler.Parse("_Zrsv"));
+  ASSERT_EQ("operator>>=()", demangler.Parse("_ZrSv"));
+
+  // Spot check using an operator as part of function name.
+  ASSERT_EQ("operator&&()", demangler.Parse("_ZNaaEv"));
+  ASSERT_EQ("operator++()", demangler.Parse("_ZNppEv"));
+  ASSERT_EQ("one::operator++()", demangler.Parse("_ZN3oneppEv"));
+
+  // Spot check using an operator in an argument name.
+  ASSERT_EQ("operator+(operator|=)", demangler.Parse("_ZNpsENoRE"));
+  ASSERT_EQ("operator==()", demangler.Parse("_Zeqv"));
+  ASSERT_EQ("one(arg1::operator|=, arg2::operator==)",
+            demangler.Parse("_ZN3oneEN4arg1oREN4arg2eqE"));
+}
+
+TEST(DemangleTest, FunctionStartsWithNumber) {
+  Demangler demangler;
+
+  ASSERT_EQ("value(char, int)", demangler.Parse("_Z5valueci"));
+  ASSERT_EQ("abcdefjklmn(signed char)", demangler.Parse("_Z11abcdefjklmna"));
+  ASSERT_EQ("value(one, signed char)", demangler.Parse("_Z5value3onea"));
+}
+
+TEST(DemangleTest, StdTypes) {
+  Demangler demangler;
+
+  ASSERT_EQ("std::one", demangler.Parse("_ZNSt3oneE"));
+  ASSERT_EQ("std::one(std::two)", demangler.Parse("_ZNSt3oneESt3two"));
+  ASSERT_EQ("std::std::one(std::two)", demangler.Parse("_ZNStSt3oneESt3two"));
+  ASSERT_EQ("std()", demangler.Parse("_ZNStEv"));
+  ASSERT_EQ("one::std::std::two::~two(one::std::std::two)",
+            demangler.Parse("_ZN3oneStSt3twoD0ES0_"));
+
+  ASSERT_EQ("std::allocator", demangler.Parse("_ZNSaE"));
+  ASSERT_EQ("std::basic_string", demangler.Parse("_ZNSbE"));
+  ASSERT_EQ("_ZNScE", demangler.Parse("_ZNScE"));
+  ASSERT_EQ("std::iostream", demangler.Parse("_ZNSdE"));
+  ASSERT_EQ("_ZNSeE", demangler.Parse("_ZNSeE"));
+  ASSERT_EQ("_ZNSfE", demangler.Parse("_ZNSfE"));
+  ASSERT_EQ("_ZNSgE", demangler.Parse("_ZNSgE"));
+  ASSERT_EQ("_ZNShE", demangler.Parse("_ZNShE"));
+  ASSERT_EQ("std::istream", demangler.Parse("_ZNSiE"));
+  ASSERT_EQ("_ZNSjE", demangler.Parse("_ZNSjE"));
+  ASSERT_EQ("_ZNSkE", demangler.Parse("_ZNSkE"));
+  ASSERT_EQ("_ZNSlE", demangler.Parse("_ZNSlE"));
+  ASSERT_EQ("_ZNSmE", demangler.Parse("_ZNSmE"));
+  ASSERT_EQ("_ZNSnE", demangler.Parse("_ZNSnE"));
+  ASSERT_EQ("std::ostream", demangler.Parse("_ZNSoE"));
+  ASSERT_EQ("_ZNSpE", demangler.Parse("_ZNSpE"));
+  ASSERT_EQ("_ZNSqE", demangler.Parse("_ZNSqE"));
+  ASSERT_EQ("_ZNSrE", demangler.Parse("_ZNSrE"));
+  ASSERT_EQ("std::string", demangler.Parse("_ZNSsE"));
+  ASSERT_EQ("_ZNSuE", demangler.Parse("_ZNSuE"));
+  ASSERT_EQ("_ZNSvE", demangler.Parse("_ZNSvE"));
+  ASSERT_EQ("_ZNSwE", demangler.Parse("_ZNSwE"));
+  ASSERT_EQ("_ZNSxE", demangler.Parse("_ZNSxE"));
+  ASSERT_EQ("_ZNSyE", demangler.Parse("_ZNSyE"));
+  ASSERT_EQ("_ZNSzE", demangler.Parse("_ZNSzE"));
+}
+
+TEST(DemangleTest, SingleLetterArguments) {
+  Demangler demangler;
+
+  ASSERT_EQ("func(signed char)", demangler.Parse("_ZN4funcEa"));
+  ASSERT_EQ("func(bool)", demangler.Parse("_ZN4funcEb"));
+  ASSERT_EQ("func(char)", demangler.Parse("_ZN4funcEc"));
+  ASSERT_EQ("func(double)", demangler.Parse("_ZN4funcEd"));
+  ASSERT_EQ("func(long double)", demangler.Parse("_ZN4funcEe"));
+  ASSERT_EQ("func(float)", demangler.Parse("_ZN4funcEf"));
+  ASSERT_EQ("func(__float128)", demangler.Parse("_ZN4funcEg"));
+  ASSERT_EQ("func(unsigned char)", demangler.Parse("_ZN4funcEh"));
+  ASSERT_EQ("func(int)", demangler.Parse("_ZN4funcEi"));
+  ASSERT_EQ("func(unsigned int)", demangler.Parse("_ZN4funcEj"));
+  ASSERT_EQ("_ZN4funcEk", demangler.Parse("_ZN4funcEk"));
+  ASSERT_EQ("func(long)", demangler.Parse("_ZN4funcEl"));
+  ASSERT_EQ("func(unsigned long)", demangler.Parse("_ZN4funcEm"));
+  ASSERT_EQ("func(__int128)", demangler.Parse("_ZN4funcEn"));
+  ASSERT_EQ("func(unsigned __int128)", demangler.Parse("_ZN4funcEo"));
+  ASSERT_EQ("_ZN4funcEp", demangler.Parse("_ZN4funcEp"));
+  ASSERT_EQ("_ZN4funcEq", demangler.Parse("_ZN4funcEq"));
+  ASSERT_EQ("_ZN4funcEr", demangler.Parse("_ZN4funcEr"));
+  ASSERT_EQ("func(short)", demangler.Parse("_ZN4funcEs"));
+  ASSERT_EQ("func(unsigned short)", demangler.Parse("_ZN4funcEt"));
+  ASSERT_EQ("_ZN4funcEu", demangler.Parse("_ZN4funcEu"));
+  ASSERT_EQ("func()", demangler.Parse("_ZN4funcEv"));
+  ASSERT_EQ("func(wchar_t)", demangler.Parse("_ZN4funcEw"));
+  ASSERT_EQ("func(long long)", demangler.Parse("_ZN4funcEx"));
+  ASSERT_EQ("func(unsigned long long)", demangler.Parse("_ZN4funcEy"));
+  ASSERT_EQ("func(...)", demangler.Parse("_ZN4funcEz"));
+}
+
+TEST(DemangleTest, DArguments) {
+  Demangler demangler;
+
+  ASSERT_EQ("func(auto)", demangler.Parse("_ZN4funcEDa"));
+  ASSERT_EQ("_ZN4funcEDb", demangler.Parse("_ZN4funcEDb"));
+  ASSERT_EQ("_ZN4funcEDc", demangler.Parse("_ZN4funcEDc"));
+  ASSERT_EQ("func(decimal64)", demangler.Parse("_ZN4funcEDd"));
+  ASSERT_EQ("func(decimal128)", demangler.Parse("_ZN4funcEDe"));
+  ASSERT_EQ("func(decimal32)", demangler.Parse("_ZN4funcEDf"));
+  ASSERT_EQ("_ZN4funcEDg", demangler.Parse("_ZN4funcEDg"));
+  ASSERT_EQ("func(half)", demangler.Parse("_ZN4funcEDh"));
+  ASSERT_EQ("func(char32_t)", demangler.Parse("_ZN4funcEDi"));
+  ASSERT_EQ("_ZN4funcEDj", demangler.Parse("_ZN4funcEDj"));
+  ASSERT_EQ("_ZN4funcEDk", demangler.Parse("_ZN4funcEDk"));
+  ASSERT_EQ("_ZN4funcEDl", demangler.Parse("_ZN4funcEDl"));
+  ASSERT_EQ("_ZN4funcEDm", demangler.Parse("_ZN4funcEDm"));
+  ASSERT_EQ("func(decltype(nullptr))", demangler.Parse("_ZN4funcEDn"));
+  ASSERT_EQ("_ZN4funcEDo", demangler.Parse("_ZN4funcEDo"));
+  ASSERT_EQ("_ZN4funcEDp", demangler.Parse("_ZN4funcEDp"));
+  ASSERT_EQ("_ZN4funcEDq", demangler.Parse("_ZN4funcEDq"));
+  ASSERT_EQ("_ZN4funcEDr", demangler.Parse("_ZN4funcEDr"));
+  ASSERT_EQ("func(char16_t)", demangler.Parse("_ZN4funcEDs"));
+  ASSERT_EQ("_ZN4funcEDt", demangler.Parse("_ZN4funcEDt"));
+  ASSERT_EQ("_ZN4funcEDu", demangler.Parse("_ZN4funcEDu"));
+  ASSERT_EQ("_ZN4funcEDv", demangler.Parse("_ZN4funcEDv"));
+  ASSERT_EQ("_ZN4funcEDw", demangler.Parse("_ZN4funcEDw"));
+  ASSERT_EQ("_ZN4funcEDx", demangler.Parse("_ZN4funcEDx"));
+  ASSERT_EQ("_ZN4funcEDy", demangler.Parse("_ZN4funcEDy"));
+  ASSERT_EQ("_ZN4funcEDz", demangler.Parse("_ZN4funcEDz"));
+}
+
+TEST(DemangleTest, FunctionArguments) {
+  Demangler demangler;
+
+  ASSERT_EQ("func(char ())", demangler.Parse("_ZN4funcEFcvE"));
+  ASSERT_EQ("func(char (*)())", demangler.Parse("_ZN4funcEPFcvE"));
+  ASSERT_EQ("func(char (&)())", demangler.Parse("_ZN4funcERFcvE"));
+  ASSERT_EQ("func(char (&)())", demangler.Parse("_ZN4funcERFcvE"));
+  ASSERT_EQ("func(char (*&)())", demangler.Parse("_ZN4funcERPFcvE"));
+  ASSERT_EQ("func(char (*)(int) const)", demangler.Parse("_ZN4funcEPKFciE"));
+  ASSERT_EQ("func(char (&)() const)", demangler.Parse("_ZN4funcERKFcvE"));
+  ASSERT_EQ("func(char (&)() volatile)", demangler.Parse("_ZN4funcERVFcvE"));
+  ASSERT_EQ("func(char (&)() volatile const)", demangler.Parse("_ZN4funcERKVFcvE"));
+  ASSERT_EQ("func(char (&)() const volatile)", demangler.Parse("_ZN4funcERVKFcvE"));
+  ASSERT_EQ("func(char (&)(int, signed char) const)", demangler.Parse("_ZN4funcERKFciaE"));
+  ASSERT_EQ("fake(char (&* volatile const)(void, void, signed char), signed char)",
+            demangler.Parse("_ZN4fakeEKVPRFcvvaEa"));
+}
+
+TEST(DemangleTest, TemplateFunction) {
+  Demangler demangler;
+
+  ASSERT_EQ("one<char>", demangler.Parse("_ZN3oneIcEE"));
+  ASSERT_EQ("one<void>", demangler.Parse("_ZN3oneIvEE"));
+  ASSERT_EQ("one<void*>", demangler.Parse("_ZN3oneIPvEE"));
+  ASSERT_EQ("one<void const>", demangler.Parse("_ZN3oneIKvEE"));
+  ASSERT_EQ("one<char, int, bool>", demangler.Parse("_ZN3oneIcibEE"));
+  ASSERT_EQ("one::two<three>", demangler.Parse("_ZN3one3twoIN5threeEEE"));
+  ASSERT_EQ("one<char, int, two::three>", demangler.Parse("_ZN3oneIciN3two5threeEEE"));
+  // Template within templates.
+  ASSERT_EQ("one::two<three<char, int>>", demangler.Parse("_ZN3one3twoIN5threeIciEEEE"));
+  ASSERT_EQ("one::two<three<char, four<int>>>", demangler.Parse("_ZN3one3twoIN5threeIcN4fourIiEEEEEE"));
+}
+
+TEST(DemangleTest, TemplateArguments) {
+  Demangler demangler;
+
+  ASSERT_EQ("one(two<char>)", demangler.Parse("_ZN3oneE3twoIcE"));
+  ASSERT_EQ("one(two<char, void>)", demangler.Parse("_ZN3oneE3twoIcvE"));
+  ASSERT_EQ("one(two<char, void, three<four, int>>)",
+            demangler.Parse("_ZN3oneE3twoIcv5threeI4fouriEE"));
+}
+
+TEST(DemangleTest, SubstitutionUnderscore) {
+  Demangler demangler;
+
+  ASSERT_EQ("a::a", demangler.Parse("_ZN1aS_E"));
+  ASSERT_EQ("one::one", demangler.Parse("_ZN3oneS_E"));
+  ASSERT_EQ("one::two::one", demangler.Parse("_ZN3one3twoS_E"));
+  ASSERT_EQ("one::two::three::one", demangler.Parse("_ZN3one3two5threeS_E"));
+  ASSERT_EQ("one::two(one)", demangler.Parse("_ZN3one3twoES_"));
+  ASSERT_EQ("one::two(three::one)", demangler.Parse("_ZN3one3twoEN5threeS_E"));
+
+  // Special case that St is part of the saved value used in the substitution.
+  ASSERT_EQ("std::one::std::one", demangler.Parse("_ZNSt3oneS_E"));
+
+  // Multiple substitutions in the string.
+  ASSERT_EQ("one::one(one, one)", demangler.Parse("_ZN3oneS_ES_S_"));
+  ASSERT_EQ("std::one::two::std::one(std::one)", demangler.Parse("_ZNSt3one3twoS_ES_"));
+}
+
+TEST(DemangleTest, SubstitutionByNumber) {
+  Demangler demangler;
+
+  // Basic substitution.
+  ASSERT_EQ("a::b::c(a::b)", demangler.Parse("_ZN1a1b1cES0_"));
+  ASSERT_EQ("_ZN1a1b1cES1_", demangler.Parse("_ZN1a1b1cES1_"));
+  ASSERT_EQ("a::b::c::d(a::b::c)", demangler.Parse("_ZN1a1b1c1dES1_"));
+  ASSERT_EQ("a::b::c::d::e::f::g::h::i::j::k::l::m::n::o::p::q(a::b::c::d::e::f::g::h::i::j::k::l)",
+            demangler.Parse("_ZN1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1qESA_"));
+  ASSERT_EQ("a::b::c::d::e::f::g::h::i::j::k::l::m::n::o::p::q(a::b::c::d::e::f::g::h::i::j::k::l::m)",
+            demangler.Parse("_ZN1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1qESB_"));
+
+  // Verify argument modifiers are included in substitution list.
+  ASSERT_EQ("one::two(char&* volatile const, char&)", demangler.Parse("_ZN3one3twoEKVPRcS0_"));
+  ASSERT_EQ("one::two(char&* volatile const, char&*)", demangler.Parse("_ZN3one3twoEKVPRcS1_"));
+  ASSERT_EQ("one::two(char&* volatile const, char&* volatile const)",
+            demangler.Parse("_ZN3one3twoEKVPRcS2_"));
+  ASSERT_EQ("one::two(int&* volatile* const, int&)", demangler.Parse("_ZN3one3twoEKPVPRiS0_"));
+  ASSERT_EQ("one::two(int&* volatile const, int&*)", demangler.Parse("_ZN3one3twoEKVPRiS1_"));
+  ASSERT_EQ("one::two(int&* volatile const, int&* volatile const)",
+            demangler.Parse("_ZN3one3twoEKVPRiS2_"));
+
+  // Verify Constructor/Destructor does properly save from function name.
+  ASSERT_EQ("_ZN1a1bES0_", demangler.Parse("_ZN1a1bES0_"));
+  ASSERT_EQ("a::b::b(a::b)", demangler.Parse("_ZN1a1bC1ES0_"));
+  ASSERT_EQ("a::b::~b(a::b)", demangler.Parse("_ZN1a1bD0ES0_"));
+
+  // Make sure substitution values are not saved.
+  ASSERT_EQ("a::b::b(a::b, char*, char*)", demangler.Parse("_ZN1a1bC1ES0_PcS1_"));
+}
+
+TEST(DemangleTest, ComplexSubstitution) {
+  Demangler demangler;
+
+  ASSERT_EQ("one::two<one::three>::two()", demangler.Parse("_ZN3one3twoINS_5threeEEC1Ev"));
+  ASSERT_EQ("one::two::two(one::two const&, bool, one::three*)",
+            demangler.Parse("_ZN3one3twoC2ERKS0_bPNS_5threeE"));
+  ASSERT_EQ("one::two::three::four<one::five>::~four(one::two*)",
+            demangler.Parse("_ZN3one3two5three4fourINS_4fiveEED2EPS0_"));
+  ASSERT_EQ("one::two::three::four<one::five>::~four(one::two::three*)",
+            demangler.Parse("_ZN3one3two5three4fourINS_4fiveEED2EPS1_"));
+  ASSERT_EQ("one::two::three::four<one::five>::~four(one::two::three::four*)",
+            demangler.Parse("_ZN3one3two5three4fourINS_4fiveEED2EPS2_"));
+  ASSERT_EQ("one::two::three::four<one::five>::~four(one::five*)",
+            demangler.Parse("_ZN3one3two5three4fourINS_4fiveEED2EPS3_"));
+}
+
+TEST(DemangleTest, StringTooLong) {
+  Demangler demangler;
+
+  ASSERT_EQ("_ZN3one3twoC2ERKS0_bPNS_5threeE",
+            demangler.Parse("_ZN3one3twoC2ERKS0_bPNS_5threeE", 10));
+  ASSERT_EQ("_ZN3one3twoC2ERKS0_bPNS_5threeE",
+            demangler.Parse("_ZN3one3twoC2ERKS0_bPNS_5threeE", 30));
+  ASSERT_EQ("one::two::two(one::two const&, bool, one::three*)",
+            demangler.Parse("_ZN3one3twoC2ERKS0_bPNS_5threeE", 31));
+
+  // Check the length check only occurs after the two letter value
+  // has been processed.
+  ASSERT_EQ("one::two(auto)", demangler.Parse("_ZN3one3twoEDa", 15));
+  ASSERT_EQ("one::two(auto)", demangler.Parse("_ZN3one3twoEDa", 14));
+  ASSERT_EQ("one::two(auto)", demangler.Parse("_ZN3one3twoEDa", 13));
+  ASSERT_EQ("_ZN3one3twoEDa", demangler.Parse("_ZN3one3twoEDa", 12));
+}
+
+TEST(DemangleTest, demangle) {
+  std::string str;
+
+  str = demangle("_ZN1a1b1cES0_");
+  ASSERT_EQ("a::b::c(a::b)", str);
+
+  str = demangle("_");
+  ASSERT_EQ("_", str);
+
+  str = demangle("_Z");
+  ASSERT_EQ("_Z", str);
+
+  str = demangle("_Za");
+  ASSERT_EQ("_Za", str);
+
+  str = demangle("_Zaa");
+  ASSERT_EQ("operator&&", str);
+
+  str = demangle("Xa");
+  ASSERT_EQ("Xa", str);
+}
diff --git a/demangle/Demangler.cpp b/demangle/Demangler.cpp
new file mode 100644
index 0000000..77cfd3b
--- /dev/null
+++ b/demangle/Demangler.cpp
@@ -0,0 +1,746 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+
+#include <cctype>
+#include <stack>
+#include <string>
+#include <vector>
+
+#include "Demangler.h"
+
+constexpr const char* Demangler::kTypes[];
+constexpr const char* Demangler::kDTypes[];
+constexpr const char* Demangler::kSTypes[];
+
+void Demangler::Save(const std::string& str, bool is_name) {
+  saves_.push_back(str);
+  last_save_name_ = is_name;
+}
+
+std::string Demangler::GetArgumentsString() {
+  size_t num_args = cur_state_.args.size();
+  std::string arg_str;
+  if (num_args > 0) {
+    arg_str = cur_state_.args[0];
+    for (size_t i = 1; i < num_args; i++) {
+      arg_str += ", " + cur_state_.args[i];
+    }
+  }
+  return arg_str;
+}
+
+const char* Demangler::AppendOperatorString(const char* name) {
+  const char* oper = nullptr;
+  switch (*name) {
+  case 'a':
+    name++;
+    switch (*name) {
+    case 'a':
+      oper = "operator&&";
+      break;
+    case 'd':
+    case 'n':
+      oper = "operator&";
+      break;
+    case 'N':
+      oper = "operator&=";
+      break;
+    case 'S':
+      oper = "operator=";
+      break;
+    }
+    break;
+  case 'c':
+    name++;
+    switch (*name) {
+    case 'l':
+      oper = "operator()";
+      break;
+    case 'm':
+      oper = "operator,";
+      break;
+    case 'o':
+      oper = "operator~";
+      break;
+    }
+    break;
+  case 'd':
+    name++;
+    switch (*name) {
+    case 'a':
+      oper = "operator delete[]";
+      break;
+    case 'e':
+      oper = "operator*";
+      break;
+    case 'l':
+      oper = "operator delete";
+      break;
+    case 'v':
+      oper = "operator/";
+      break;
+    case 'V':
+      oper = "operator/=";
+      break;
+    }
+    break;
+  case 'e':
+    name++;
+    switch (*name) {
+    case 'o':
+      oper = "operator^";
+      break;
+    case 'O':
+      oper = "operator^=";
+      break;
+    case 'q':
+      oper = "operator==";
+      break;
+    }
+    break;
+  case 'g':
+    name++;
+    switch (*name) {
+    case 'e':
+      oper = "operator>=";
+      break;
+    case 't':
+      oper = "operator>";
+      break;
+    }
+    break;
+  case 'i':
+    name++;
+    switch (*name) {
+    case 'x':
+      oper = "operator[]";
+      break;
+    }
+    break;
+  case 'l':
+    name++;
+    switch (*name) {
+    case 'e':
+      oper = "operator<=";
+      break;
+    case 's':
+      oper = "operator<<";
+      break;
+    case 'S':
+      oper = "operator<<=";
+      break;
+    case 't':
+      oper = "operator<";
+      break;
+    }
+    break;
+  case 'm':
+    name++;
+    switch (*name) {
+    case 'i':
+      oper = "operator-";
+      break;
+    case 'I':
+      oper = "operator-=";
+      break;
+    case 'l':
+      oper = "operator*";
+      break;
+    case 'L':
+      oper = "operator*=";
+      break;
+    case 'm':
+      oper = "operator--";
+      break;
+    }
+    break;
+  case 'n':
+    name++;
+    switch (*name) {
+    case 'a':
+      oper = "operator new[]";
+      break;
+    case 'e':
+      oper = "operator!=";
+      break;
+    case 'g':
+      oper = "operator-";
+      break;
+    case 't':
+      oper = "operator!";
+      break;
+    case 'w':
+      oper = "operator new";
+      break;
+    }
+    break;
+  case 'o':
+    name++;
+    switch (*name) {
+    case 'o':
+      oper = "operator||";
+      break;
+    case 'r':
+      oper = "operator|";
+      break;
+    case 'R':
+      oper = "operator|=";
+      break;
+    }
+    break;
+  case 'p':
+    name++;
+    switch (*name) {
+    case 'm':
+      oper = "operator->*";
+      break;
+    case 'l':
+      oper = "operator+";
+      break;
+    case 'L':
+      oper = "operator+=";
+      break;
+    case 'p':
+      oper = "operator++";
+      break;
+    case 's':
+      oper = "operator+";
+      break;
+    case 't':
+      oper = "operator->";
+      break;
+    }
+    break;
+  case 'q':
+    name++;
+    switch (*name) {
+    case 'u':
+      oper = "operator?";
+      break;
+    }
+    break;
+  case 'r':
+    name++;
+    switch (*name) {
+    case 'm':
+      oper = "operator%";
+      break;
+    case 'M':
+      oper = "operator%=";
+      break;
+    case 's':
+      oper = "operator>>";
+      break;
+    case 'S':
+      oper = "operator>>=";
+      break;
+    }
+    break;
+  }
+  if (oper == nullptr) {
+    return nullptr;
+  }
+  AppendCurrent(oper);
+  cur_state_.last_save = oper;
+  return name + 1;
+}
+
+const char* Demangler::GetStringFromLength(const char* name, std::string* str) {
+  assert(std::isdigit(*name));
+
+  size_t length = *name - '0';
+  name++;
+  while (*name != '\0' && std::isdigit(*name)) {
+    length = length * 10 + *name - '0';
+    name++;
+  }
+
+  std::string read_str;
+  while (*name != '\0' && length != 0) {
+    read_str += *name;
+    name++;
+    length--;
+  }
+  if (length != 0) {
+    return nullptr;
+  }
+  // Special replacement of _GLOBAL__N_1 to (anonymous namespace).
+  if (read_str == "_GLOBAL__N_1") {
+    *str += "(anonymous namespace)";
+  } else {
+    *str += read_str;
+  }
+  return name;
+}
+
+void Demangler::AppendCurrent(const std::string& str) {
+  if (!cur_state_.str.empty()) {
+    cur_state_.str += "::";
+  }
+  cur_state_.str += str;
+}
+
+void Demangler::AppendCurrent(const char* str) {
+  if (!cur_state_.str.empty()) {
+    cur_state_.str += "::";
+  }
+  cur_state_.str += str;
+}
+
+const char* Demangler::ParseS(const char* name) {
+  if (std::islower(*name)) {
+    const char* type = kSTypes[*name - 'a'];
+    if (type == nullptr) {
+      return nullptr;
+    }
+    AppendCurrent(type);
+    return name + 1;
+  }
+
+  if (saves_.empty()) {
+    return nullptr;
+  }
+
+  if (*name == '_') {
+    last_save_name_ = false;
+    AppendCurrent(saves_[0]);
+    return name + 1;
+  }
+
+  bool isdigit = std::isdigit(*name);
+  if (!isdigit && !std::isupper(*name)) {
+    return nullptr;
+  }
+
+  size_t index;
+  if (isdigit) {
+    index = *name - '0' + 1;
+  } else {
+    index = *name - 'A' + 11;
+  }
+  name++;
+  if (*name != '_') {
+    return nullptr;
+  }
+
+  if (index >= saves_.size()) {
+    return nullptr;
+  }
+
+  last_save_name_ = false;
+  AppendCurrent(saves_[index]);
+  return name + 1;
+}
+
+const char* Demangler::ParseFunctionName(const char* name) {
+  if (*name == 'E') {
+    if (parse_funcs_.empty()) {
+      return nullptr;
+    }
+    parse_func_ = parse_funcs_.back();
+    parse_funcs_.pop_back();
+
+    // Remove the last saved part so that the full function name is not saved.
+    // But only if the last save was not something like a substitution.
+    if (!saves_.empty() && last_save_name_) {
+      saves_.pop_back();
+    }
+
+    function_name_ = cur_state_.str;
+    while (!cur_state_.suffixes.empty()) {
+      function_suffix_ += cur_state_.suffixes.back();
+      cur_state_.suffixes.pop_back();
+    }
+    cur_state_.Clear();
+
+    return name + 1;
+  }
+
+  return ParseComplexString(name);
+}
+
+const char* Demangler::ParseComplexArgument(const char* name) {
+  if (*name == 'E') {
+    if (parse_funcs_.empty()) {
+      return nullptr;
+    }
+    parse_func_ = parse_funcs_.back();
+    parse_funcs_.pop_back();
+
+    AppendArgument(cur_state_.str);
+    cur_state_.str.clear();
+
+    return name + 1;
+  }
+
+  return ParseComplexString(name);
+}
+
+void Demangler::FinalizeTemplate() {
+  std::string arg_str(GetArgumentsString());
+  cur_state_ = state_stack_.top();
+  state_stack_.pop();
+  cur_state_.str += '<' + arg_str + '>';
+}
+
+const char* Demangler::ParseComplexString(const char* name) {
+  if (*name == 'S') {
+    name++;
+    if (*name == 't') {
+      AppendCurrent("std");
+      return name + 1;
+    }
+    return ParseS(name);
+  }
+  if (*name == 'L') {
+    name++;
+    if (!std::isdigit(*name)) {
+      return nullptr;
+    }
+  }
+  if (std::isdigit(*name)) {
+    std::string str;
+    name = GetStringFromLength(name, &str);
+    if (name == nullptr) {
+      return name;
+    }
+    AppendCurrent(str);
+    Save(cur_state_.str, true);
+    cur_state_.last_save = std::move(str);
+    return name;
+  }
+  if (*name == 'D') {
+    name++;
+    if (saves_.empty() || (*name != '0' && *name != '1' && *name != '2'
+        && *name != '5')) {
+      return nullptr;
+    }
+    last_save_name_ = false;
+    AppendCurrent("~" + cur_state_.last_save);
+    return name + 1;
+  }
+  if (*name == 'C') {
+    name++;
+    if (saves_.empty() || (*name != '1' && *name != '2' && *name != '3'
+        && *name != '5')) {
+      return nullptr;
+    }
+    last_save_name_ = false;
+    AppendCurrent(cur_state_.last_save);
+    return name + 1;
+  }
+  if (*name == 'K') {
+    cur_state_.suffixes.push_back(" const");
+    return name + 1;
+  }
+  if (*name == 'V') {
+    cur_state_.suffixes.push_back(" volatile");
+    return name + 1;
+  }
+  if (*name == 'I') {
+    // Save the current argument state.
+    state_stack_.push(cur_state_);
+    cur_state_.Clear();
+
+    parse_funcs_.push_back(parse_func_);
+    parse_func_ = &Demangler::ParseTemplateArgumentsComplex;
+    return name + 1;
+  }
+  name = AppendOperatorString(name);
+  if (name != nullptr) {
+    Save(cur_state_.str, true);
+  }
+  return name;
+}
+
+void Demangler::AppendArgument(const std::string& str) {
+  std::string arg(str);
+  while (!cur_state_.suffixes.empty()) {
+    arg += cur_state_.suffixes.back();
+    cur_state_.suffixes.pop_back();
+    Save(arg, false);
+  }
+  cur_state_.args.push_back(arg);
+}
+
+const char* Demangler::ParseFunctionArgument(const char* name) {
+  if (*name == 'E') {
+    // The first argument is the function modifier.
+    // The second argument is the function type.
+    // The third argument is the return type of the function.
+    // The rest of the arguments are the function arguments.
+    size_t num_args = cur_state_.args.size();
+    if (num_args < 4) {
+      return nullptr;
+    }
+    std::string function_modifier = cur_state_.args[0];
+    std::string function_type = cur_state_.args[1];
+
+    std::string str = cur_state_.args[2] + ' ';
+    if (!cur_state_.args[1].empty()) {
+      str += '(' + cur_state_.args[1] + ')';
+    }
+
+    if (num_args == 4 && cur_state_.args[3] == "void") {
+      str += "()";
+    } else {
+      str += '(' + cur_state_.args[3];
+      for (size_t i = 4; i < num_args; i++) {
+        str += ", " + cur_state_.args[i];
+      }
+      str += ')';
+    }
+    str += cur_state_.args[0];
+
+    cur_state_ = state_stack_.top();
+    state_stack_.pop();
+    cur_state_.args.emplace_back(std::move(str));
+
+    parse_func_ = parse_funcs_.back();
+    parse_funcs_.pop_back();
+    return name + 1;
+  }
+  return ParseArguments(name);
+}
+
+const char* Demangler::ParseArguments(const char* name) {
+  switch (*name) {
+  case 'P':
+    cur_state_.suffixes.push_back("*");
+    return name + 1;
+
+  case 'R':
+    // This should always be okay because the string is guaranteed to have
+    // at least two characters before this. A mangled string always starts
+    // with _Z.
+    if (name[-1] != 'R') {
+      // Multiple 'R's in a row only add a single &.
+      cur_state_.suffixes.push_back("&");
+    }
+    return name + 1;
+
+  case 'K':
+  case 'V': {
+    const char* suffix;
+    if (*name == 'K') {
+      suffix = " const";
+    } else {
+      suffix = " volatile";
+    }
+    if (name[-1] == 'K' || name[-1] == 'V') {
+      // Special case, const/volatile apply as a single entity.
+      assert(!cur_state_.suffixes.empty());
+      size_t index = cur_state_.suffixes.size();
+      cur_state_.suffixes[index-1].insert(0, suffix);
+    } else {
+      cur_state_.suffixes.push_back(suffix);
+    }
+    return name + 1;
+  }
+
+  case 'F': {
+    std::string function_modifier;
+    std::string function_type;
+    if (!cur_state_.suffixes.empty()) {
+      // If the first element starts with a ' ', then this modifies the
+      // function itself.
+      if (cur_state_.suffixes.back()[0] == ' ') {
+        function_modifier = cur_state_.suffixes.back();
+        cur_state_.suffixes.pop_back();
+      }
+      while (!cur_state_.suffixes.empty()) {
+        function_type += cur_state_.suffixes.back();
+        cur_state_.suffixes.pop_back();
+      }
+    }
+
+    state_stack_.push(cur_state_);
+
+    cur_state_.Clear();
+
+    // The function parameter has this format:
+    //   First argument is the function modifier.
+    //   Second argument is the function type.
+    //   Third argument will be the return function type but has not
+    //     been parsed yet.
+    //   Any other parameters are the arguments to the function. There
+    //     must be at least one or this isn't valid.
+    cur_state_.args.push_back(function_modifier);
+    cur_state_.args.push_back(function_type);
+
+    parse_funcs_.push_back(parse_func_);
+    parse_func_ = &Demangler::ParseFunctionArgument;
+    return name + 1;
+  }
+
+  case 'N':
+    parse_funcs_.push_back(parse_func_);
+    parse_func_ = &Demangler::ParseComplexArgument;
+    return name + 1;
+
+  case 'S':
+    name++;
+    if (*name == 't') {
+      cur_state_.str = "std::";
+      return name + 1;
+    }
+    name = ParseS(name);
+    if (name == nullptr) {
+      return nullptr;
+    }
+    AppendArgument(cur_state_.str);
+    cur_state_.str.clear();
+    return name;
+
+  case 'D':
+    name++;
+    if (*name >= 'a' && *name <= 'z') {
+      const char* arg = Demangler::kDTypes[*name - 'a'];
+      if (arg == nullptr) {
+        return nullptr;
+      }
+      AppendArgument(arg);
+      return name + 1;
+    }
+    return nullptr;
+
+  case 'I':
+    // Save the current argument state.
+    state_stack_.push(cur_state_);
+    cur_state_.Clear();
+
+    parse_funcs_.push_back(parse_func_);
+    parse_func_ = &Demangler::ParseTemplateArguments;
+    return name + 1;
+
+  case 'v':
+    AppendArgument("void");
+    return name + 1;
+
+  default:
+    if (*name >= 'a' && *name <= 'z') {
+      const char* arg = Demangler::kTypes[*name - 'a'];
+      if (arg == nullptr) {
+        return nullptr;
+      }
+      AppendArgument(arg);
+      return name + 1;
+    } else if (std::isdigit(*name)) {
+      std::string arg = cur_state_.str;
+      name = GetStringFromLength(name, &arg);
+      if (name == nullptr) {
+        return nullptr;
+      }
+      Save(arg, true);
+      if (*name == 'I') {
+        // There is one case where this argument is not complete, and that's
+        // where this is a template argument.
+        cur_state_.str = arg;
+      } else {
+        AppendArgument(arg);
+        cur_state_.str.clear();
+      }
+      return name;
+    }
+  }
+  return nullptr;
+}
+
+const char* Demangler::ParseTemplateArgumentsComplex(const char* name) {
+  if (*name == 'E') {
+    if (parse_funcs_.empty()) {
+      return nullptr;
+    }
+    parse_func_ = parse_funcs_.back();
+    parse_funcs_.pop_back();
+    FinalizeTemplate();
+    Save(cur_state_.str, false);
+    return name + 1;
+  }
+  return ParseArguments(name);
+}
+
+const char* Demangler::ParseTemplateArguments(const char* name) {
+  if (*name == 'E') {
+    if (parse_funcs_.empty()) {
+      return nullptr;
+    }
+    parse_func_ = parse_funcs_.back();
+    parse_funcs_.pop_back();
+    FinalizeTemplate();
+    AppendArgument(cur_state_.str);
+    cur_state_.str.clear();
+    return name + 1;
+  }
+  return ParseArguments(name);
+}
+
+const char* Demangler::FindFunctionName(const char* name) {
+  if (*name == 'N') {
+    parse_funcs_.push_back(&Demangler::ParseArguments);
+    parse_func_ = &Demangler::ParseFunctionName;
+    return name + 1;
+  }
+
+  if (std::isdigit(*name)) {
+    name = GetStringFromLength(name, &function_name_);
+  } else {
+    name = AppendOperatorString(name);
+    function_name_ = cur_state_.str;
+  }
+  parse_func_ = &Demangler::ParseArguments;
+  cur_state_.Clear();
+  return name;
+}
+
+std::string Demangler::Parse(const char* name, size_t max_length) {
+  if (name[0] == '\0' || name[0] != '_' || name[1] == '\0' || name[1] != 'Z') {
+    // Name is not mangled.
+    return name;
+  }
+
+  Clear();
+
+  parse_func_ = &Demangler::FindFunctionName;
+  parse_funcs_.push_back(&Demangler::Fail);
+  const char* cur_name = name + 2;
+  while (cur_name != nullptr && *cur_name != '\0'
+      && static_cast<size_t>(cur_name - name) < max_length) {
+    cur_name = (this->*parse_func_)(cur_name);
+  }
+  if (cur_name == nullptr || *cur_name != '\0' || function_name_.empty()) {
+    return name;
+  }
+
+  std::string arg_str;
+  if (cur_state_.args.size() == 1 && cur_state_.args[0] == "void") {
+    // If the only argument is void, then don't print any args.
+    arg_str = "()";
+  } else {
+    arg_str = GetArgumentsString();
+    if (!arg_str.empty()) {
+      arg_str = '(' + arg_str + ')';
+    }
+  }
+  return function_name_ + arg_str + function_suffix_;
+}
+
+std::string demangle(const char* name) {
+  Demangler demangler;
+  return demangler.Parse(name);
+}
diff --git a/demangle/Demangler.h b/demangle/Demangler.h
new file mode 100644
index 0000000..3bd4f3c
--- /dev/null
+++ b/demangle/Demangler.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LIB_DEMANGLE_DEMANGLER_H
+#define __LIB_DEMANGLE_DEMANGLER_H
+
+#include <assert.h>
+
+#include <stack>
+#include <string>
+#include <vector>
+
+class Demangler {
+ public:
+  Demangler() = default;
+
+  // NOTE: The max_length is not guaranteed to be the absolute max length
+  // of a string that will be rejected. Under certain circumstances the
+  // length check will not occur until after the second letter of a pair
+  // is checked.
+  std::string Parse(const char* name, size_t max_length = kMaxDefaultLength);
+
+  void AppendCurrent(const std::string& str);
+  void AppendCurrent(const char* str);
+  void AppendArgument(const std::string& str);
+  std::string GetArgumentsString();
+  void FinalizeTemplate();
+  const char* ParseS(const char* name);
+  const char* AppendOperatorString(const char* name);
+  void Save(const std::string& str, bool is_name);
+
+ private:
+  void Clear() {
+    parse_funcs_.clear();
+    function_name_.clear();
+    function_suffix_.clear();
+    first_save_.clear();
+    cur_state_.Clear();
+    saves_.clear();
+    while (!state_stack_.empty()) {
+      state_stack_.pop();
+    }
+    last_save_name_ = false;
+  }
+
+  using parse_func_type = const char* (Demangler::*)(const char*);
+  parse_func_type parse_func_;
+  std::vector<parse_func_type> parse_funcs_;
+  std::vector<std::string> saves_;
+  bool last_save_name_;
+
+  std::string function_name_;
+  std::string function_suffix_;
+
+  struct StateData {
+    void Clear() {
+      str.clear();
+      args.clear();
+      prefix.clear();
+      suffixes.clear();
+      last_save.clear();
+    }
+
+    std::string str;
+    std::vector<std::string> args;
+    std::string prefix;
+    std::vector<std::string> suffixes;
+    std::string last_save;
+  };
+  std::stack<StateData> state_stack_;
+  std::string first_save_;
+  StateData cur_state_;
+
+  static const char* GetStringFromLength(const char* name, std::string* str);
+
+  // Parsing functions.
+  const char* ParseComplexString(const char* name);
+  const char* ParseComplexArgument(const char* name);
+  const char* ParseArguments(const char* name);
+  const char* ParseTemplateArguments(const char* name);
+  const char* ParseTemplateArgumentsComplex(const char* name);
+  const char* ParseFunctionArgument(const char* name);
+  const char* ParseFunctionName(const char* name);
+  const char* FindFunctionName(const char* name);
+  const char* Fail(const char*) { return nullptr; }
+
+  // The default maximum string length string to process.
+  static constexpr size_t kMaxDefaultLength = 2048;
+
+  static constexpr const char* kTypes[] = {
+    "signed char",        // a
+    "bool",               // b
+    "char",               // c
+    "double",             // d
+    "long double",        // e
+    "float",              // f
+    "__float128",         // g
+    "unsigned char",      // h
+    "int",                // i
+    "unsigned int",       // j
+    nullptr,              // k
+    "long",               // l
+    "unsigned long",      // m
+    "__int128",           // n
+    "unsigned __int128",  // o
+    nullptr,              // p
+    nullptr,              // q
+    nullptr,              // r
+    "short",              // s
+    "unsigned short",     // t
+    nullptr,              // u
+    "void",               // v
+    "wchar_t",            // w
+    "long long",          // x
+    "unsigned long long", // y
+    "...",                // z
+  };
+
+  static constexpr const char* kDTypes[] = {
+    "auto",               // a
+    nullptr,              // b
+    nullptr,              // c
+    "decimal64",          // d
+    "decimal128",         // e
+    "decimal32",          // f
+    nullptr,              // g
+    "half",               // h
+    "char32_t",           // i
+    nullptr,              // j
+    nullptr,              // k
+    nullptr,              // l
+    nullptr,              // m
+    "decltype(nullptr)",  // n
+    nullptr,              // o
+    nullptr,              // p
+    nullptr,              // q
+    nullptr,              // r
+    "char16_t",           // s
+    nullptr,              // t
+    nullptr,              // u
+    nullptr,              // v
+    nullptr,              // w
+    nullptr,              // x
+    nullptr,              // y
+    nullptr,              // z
+  };
+
+  static constexpr const char* kSTypes[] = {
+    "std::allocator",     // a
+    "std::basic_string",  // b
+    nullptr,              // c
+    "std::iostream",      // d
+    nullptr,              // e
+    nullptr,              // f
+    nullptr,              // g
+    nullptr,              // h
+    "std::istream",       // i
+    nullptr,              // j
+    nullptr,              // k
+    nullptr,              // l
+    nullptr,              // m
+    nullptr,              // n
+    "std::ostream",       // o
+    nullptr,              // p
+    nullptr,              // q
+    nullptr,              // r
+    "std::string",        // s
+    nullptr,              // t
+    nullptr,              // u
+    nullptr,              // v
+    nullptr,              // w
+    nullptr,              // x
+    nullptr,              // y
+    nullptr,              // z
+  };
+};
+
+#endif  // __LIB_DEMANGLE_DEMANGLER_H
diff --git a/demangle/include/demangle.h b/demangle/include/demangle.h
new file mode 100644
index 0000000..01f1b80
--- /dev/null
+++ b/demangle/include/demangle.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LIB_DEMANGLE_H_
+#define __LIB_DEMANGLE_H_
+
+#include <string>
+
+// If the name cannot be demangled, the original name will be returned as
+// a std::string. If the name can be demangled, then the demangled name
+// will be returned as a std::string.
+std::string demangle(const char* name);
+
+#endif  // __LIB_DEMANGLE_H_
diff --git a/init/.clang-format b/init/.clang-format
deleted file mode 100644
index 48d423f..0000000
--- a/init/.clang-format
+++ /dev/null
@@ -1,14 +0,0 @@
----
-Language:        Cpp
-BasedOnStyle:  Google
-BinPackArguments: true
-BinPackParameters: true
-ColumnLimit:     100
-ConstructorInitializerAllOnOneLineOrOnePerLine: false
-IndentWidth:     4
-Standard:        Auto
-TabWidth:        8
-UseTab:          Never
-DerivePointerAlignment: false
-PointerAlignment: Left
-...
diff --git a/init/.clang-format b/init/.clang-format
new file mode 120000
index 0000000..1af4f51
--- /dev/null
+++ b/init/.clang-format
@@ -0,0 +1 @@
+../.clang-format-4
\ No newline at end of file
diff --git a/libappfuse/FuseBuffer.cc b/libappfuse/FuseBuffer.cc
index 8fb2dbc..13cfc88 100644
--- a/libappfuse/FuseBuffer.cc
+++ b/libappfuse/FuseBuffer.cc
@@ -23,77 +23,132 @@
 #include <algorithm>
 #include <type_traits>
 
+#include <sys/socket.h>
+
 #include <android-base/file.h>
 #include <android-base/logging.h>
 #include <android-base/macros.h>
 
 namespace android {
 namespace fuse {
-
-static_assert(
-    std::is_standard_layout<FuseBuffer>::value,
-    "FuseBuffer must be standard layout union.");
+namespace {
 
 template <typename T>
-bool FuseMessage<T>::CheckHeaderLength(const char* name) const {
-  const auto& header = static_cast<const T*>(this)->header;
-  if (header.len >= sizeof(header) && header.len <= sizeof(T)) {
+bool CheckHeaderLength(const FuseMessage<T>* self, const char* name) {
+    const auto& header = static_cast<const T*>(self)->header;
+    if (header.len >= sizeof(header) && header.len <= sizeof(T)) {
+        return true;
+    } else {
+        LOG(ERROR) << "Invalid header length is found in " << name << ": " << header.len;
+        return false;
+    }
+}
+
+template <typename T>
+ResultOrAgain ReadInternal(FuseMessage<T>* self, int fd, int sockflag) {
+    char* const buf = reinterpret_cast<char*>(self);
+    const ssize_t result = sockflag ? TEMP_FAILURE_RETRY(recv(fd, buf, sizeof(T), sockflag))
+                                    : TEMP_FAILURE_RETRY(read(fd, buf, sizeof(T)));
+
+    switch (result) {
+        case 0:
+            // Expected EOF.
+            return ResultOrAgain::kFailure;
+        case -1:
+            if (errno == EAGAIN) {
+                return ResultOrAgain::kAgain;
+            }
+            PLOG(ERROR) << "Failed to read a FUSE message";
+            return ResultOrAgain::kFailure;
+    }
+
+    const auto& header = static_cast<const T*>(self)->header;
+    if (result < static_cast<ssize_t>(sizeof(header))) {
+        LOG(ERROR) << "Read bytes " << result << " are shorter than header size " << sizeof(header);
+        return ResultOrAgain::kFailure;
+    }
+
+    if (!CheckHeaderLength<T>(self, "Read")) {
+        return ResultOrAgain::kFailure;
+    }
+
+    if (static_cast<uint32_t>(result) != header.len) {
+        LOG(ERROR) << "Read bytes " << result << " are different from header.len " << header.len;
+        return ResultOrAgain::kFailure;
+    }
+
+    return ResultOrAgain::kSuccess;
+}
+
+template <typename T>
+ResultOrAgain WriteInternal(const FuseMessage<T>* self, int fd, int sockflag) {
+    if (!CheckHeaderLength<T>(self, "Write")) {
+        return ResultOrAgain::kFailure;
+    }
+
+    const char* const buf = reinterpret_cast<const char*>(self);
+    const auto& header = static_cast<const T*>(self)->header;
+    const int result = sockflag ? TEMP_FAILURE_RETRY(send(fd, buf, header.len, sockflag))
+                                : TEMP_FAILURE_RETRY(write(fd, buf, header.len));
+
+    if (result == -1) {
+        if (errno == EAGAIN) {
+            return ResultOrAgain::kAgain;
+        }
+        PLOG(ERROR) << "Failed to write a FUSE message";
+        return ResultOrAgain::kFailure;
+    }
+
+    CHECK(static_cast<uint32_t>(result) == header.len);
+    return ResultOrAgain::kSuccess;
+}
+}
+
+static_assert(std::is_standard_layout<FuseBuffer>::value,
+              "FuseBuffer must be standard layout union.");
+
+bool SetupMessageSockets(base::unique_fd (*result)[2]) {
+    base::unique_fd fds[2];
+    {
+        int raw_fds[2];
+        if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, raw_fds) == -1) {
+            PLOG(ERROR) << "Failed to create sockets for proxy";
+            return false;
+        }
+        fds[0].reset(raw_fds[0]);
+        fds[1].reset(raw_fds[1]);
+    }
+
+    constexpr int kMaxMessageSize = sizeof(FuseBuffer);
+    if (setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, &kMaxMessageSize, sizeof(int)) != 0 ||
+        setsockopt(fds[1], SOL_SOCKET, SO_SNDBUF, &kMaxMessageSize, sizeof(int)) != 0) {
+        PLOG(ERROR) << "Failed to update buffer size for socket";
+        return false;
+    }
+
+    (*result)[0] = std::move(fds[0]);
+    (*result)[1] = std::move(fds[1]);
     return true;
-  } else {
-    LOG(ERROR) << "Invalid header length is found in " << name << ": " <<
-        header.len;
-    return false;
-  }
 }
 
 template <typename T>
 bool FuseMessage<T>::Read(int fd) {
-  char* const buf = reinterpret_cast<char*>(this);
-  const ssize_t result = TEMP_FAILURE_RETRY(::read(fd, buf, sizeof(T)));
-  if (result < 0) {
-    PLOG(ERROR) << "Failed to read a FUSE message";
-    return false;
-  }
+    return ReadInternal(this, fd, 0) == ResultOrAgain::kSuccess;
+}
 
-  const auto& header = static_cast<const T*>(this)->header;
-  if (result < static_cast<ssize_t>(sizeof(header))) {
-    LOG(ERROR) << "Read bytes " << result << " are shorter than header size " <<
-        sizeof(header);
-    return false;
-  }
-
-  if (!CheckHeaderLength("Read")) {
-    return false;
-  }
-
-  if (static_cast<uint32_t>(result) > header.len) {
-    LOG(ERROR) << "Read bytes " << result << " are longer than header.len " <<
-        header.len;
-    return false;
-  }
-
-  if (!base::ReadFully(fd, buf + result, header.len - result)) {
-    PLOG(ERROR) << "ReadFully failed";
-    return false;
-  }
-
-  return true;
+template <typename T>
+ResultOrAgain FuseMessage<T>::ReadOrAgain(int fd) {
+    return ReadInternal(this, fd, MSG_DONTWAIT);
 }
 
 template <typename T>
 bool FuseMessage<T>::Write(int fd) const {
-  if (!CheckHeaderLength("Write")) {
-    return false;
-  }
+    return WriteInternal(this, fd, 0) == ResultOrAgain::kSuccess;
+}
 
-  const char* const buf = reinterpret_cast<const char*>(this);
-  const auto& header = static_cast<const T*>(this)->header;
-  if (!base::WriteFully(fd, buf, header.len)) {
-    PLOG(ERROR) << "WriteFully failed";
-    return false;
-  }
-
-  return true;
+template <typename T>
+ResultOrAgain FuseMessage<T>::WriteOrAgain(int fd) const {
+    return WriteInternal(this, fd, MSG_DONTWAIT);
 }
 
 template class FuseMessage<FuseRequest>;
diff --git a/libappfuse/include/libappfuse/FuseBuffer.h b/libappfuse/include/libappfuse/FuseBuffer.h
index 7abd2fa..fbb05d6 100644
--- a/libappfuse/include/libappfuse/FuseBuffer.h
+++ b/libappfuse/include/libappfuse/FuseBuffer.h
@@ -17,6 +17,7 @@
 #ifndef ANDROID_LIBAPPFUSE_FUSEBUFFER_H_
 #define ANDROID_LIBAPPFUSE_FUSEBUFFER_H_
 
+#include <android-base/unique_fd.h>
 #include <linux/fuse.h>
 
 namespace android {
@@ -28,12 +29,24 @@
 constexpr size_t kFuseMaxRead = 128 * 1024;
 constexpr int32_t kFuseSuccess = 0;
 
+// Setup sockets to transfer FuseMessage.
+bool SetupMessageSockets(base::unique_fd (*sockets)[2]);
+
+enum class ResultOrAgain {
+    kSuccess,
+    kFailure,
+    kAgain,
+};
+
 template<typename T>
 class FuseMessage {
  public:
   bool Read(int fd);
   bool Write(int fd) const;
- private:
+  ResultOrAgain ReadOrAgain(int fd);
+  ResultOrAgain WriteOrAgain(int fd) const;
+
+private:
   bool CheckHeaderLength(const char* name) const;
 };
 
@@ -54,7 +67,7 @@
     // for FUSE_READ
     fuse_read_in read_in;
     // for FUSE_LOOKUP
-    char lookup_name[0];
+    char lookup_name[kFuseMaxWrite];
   };
   void Reset(uint32_t data_length, uint32_t opcode, uint64_t unique);
 };
diff --git a/libappfuse/tests/FuseAppLoopTest.cc b/libappfuse/tests/FuseAppLoopTest.cc
index 25906cf..64dd813 100644
--- a/libappfuse/tests/FuseAppLoopTest.cc
+++ b/libappfuse/tests/FuseAppLoopTest.cc
@@ -109,10 +109,7 @@
 
   void SetUp() override {
     base::SetMinimumLogSeverity(base::VERBOSE);
-    int sockets[2];
-    ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets));
-    sockets_[0].reset(sockets[0]);
-    sockets_[1].reset(sockets[1]);
+    ASSERT_TRUE(SetupMessageSockets(&sockets_));
     thread_ = std::thread([this] {
       StartFuseAppLoop(sockets_[1].release(), &callback_);
     });
diff --git a/libappfuse/tests/FuseBridgeLoopTest.cc b/libappfuse/tests/FuseBridgeLoopTest.cc
index e74d9e7..b4c1efb 100644
--- a/libappfuse/tests/FuseBridgeLoopTest.cc
+++ b/libappfuse/tests/FuseBridgeLoopTest.cc
@@ -50,15 +50,8 @@
 
   void SetUp() override {
     base::SetMinimumLogSeverity(base::VERBOSE);
-    int dev_sockets[2];
-    int proxy_sockets[2];
-    ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, dev_sockets));
-    ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_SEQPACKET, 0, proxy_sockets));
-    dev_sockets_[0].reset(dev_sockets[0]);
-    dev_sockets_[1].reset(dev_sockets[1]);
-    proxy_sockets_[0].reset(proxy_sockets[0]);
-    proxy_sockets_[1].reset(proxy_sockets[1]);
-
+    ASSERT_TRUE(SetupMessageSockets(&dev_sockets_));
+    ASSERT_TRUE(SetupMessageSockets(&proxy_sockets_));
     thread_ = std::thread([this] {
       StartFuseBridgeLoop(
           dev_sockets_[1].release(), proxy_sockets_[0].release(), &callback_);
diff --git a/libappfuse/tests/FuseBufferTest.cc b/libappfuse/tests/FuseBufferTest.cc
index 1a1abd5..ade34ac 100644
--- a/libappfuse/tests/FuseBufferTest.cc
+++ b/libappfuse/tests/FuseBufferTest.cc
@@ -112,30 +112,6 @@
   TestWriteInvalidLength(sizeof(fuse_in_header) - 1);
 }
 
-TEST(FuseMessageTest, ShortWriteAndRead) {
-  int raw_fds[2];
-  ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, raw_fds));
-
-  android::base::unique_fd fds[2];
-  fds[0].reset(raw_fds[0]);
-  fds[1].reset(raw_fds[1]);
-
-  const int send_buffer_size = 1024;
-  ASSERT_EQ(0, setsockopt(fds[0], SOL_SOCKET, SO_SNDBUF, &send_buffer_size,
-                          sizeof(int)));
-
-  bool succeed = false;
-  const int sender_fd = fds[0].get();
-  std::thread thread([sender_fd, &succeed] {
-    FuseRequest request;
-    request.header.len = 1024 * 4;
-    succeed = request.Write(sender_fd);
-  });
-  thread.detach();
-  FuseRequest request;
-  ASSERT_TRUE(request.Read(fds[1]));
-}
-
 TEST(FuseResponseTest, Reset) {
   FuseResponse response;
   // Write 1 to the first ten bytes.
@@ -211,5 +187,29 @@
   EXPECT_EQ(-ENOSYS, buffer.response.header.error);
 }
 
+TEST(SetupMessageSocketsTest, Stress) {
+    constexpr int kCount = 1000;
+
+    FuseRequest request;
+    request.header.len = sizeof(FuseRequest);
+
+    base::unique_fd fds[2];
+    SetupMessageSockets(&fds);
+
+    std::thread thread([&fds] {
+        FuseRequest request;
+        for (int i = 0; i < kCount; ++i) {
+            ASSERT_TRUE(request.Read(fds[1]));
+            usleep(1000);
+        }
+    });
+
+    for (int i = 0; i < kCount; ++i) {
+        ASSERT_TRUE(request.Write(fds[0]));
+    }
+
+    thread.join();
+}
+
 } // namespace fuse
 } // namespace android
diff --git a/libbacktrace/BacktraceCurrent.cpp b/libbacktrace/BacktraceCurrent.cpp
index 5173e2c..d7a3b01 100644
--- a/libbacktrace/BacktraceCurrent.cpp
+++ b/libbacktrace/BacktraceCurrent.cpp
@@ -95,11 +95,31 @@
 
 static pthread_mutex_t g_sigaction_mutex = PTHREAD_MUTEX_INITIALIZER;
 
+// Since errno is stored per thread, changing it in the signal handler
+// modifies the value on the thread in which the signal handler executes.
+// If a signal occurs between a call and an errno check, it's possible
+// to get the errno set here. Always save and restore it just in case
+// code would modify it.
+class ErrnoRestorer {
+ public:
+  ErrnoRestorer() : saved_errno_(errno) {}
+  ~ErrnoRestorer() {
+    errno = saved_errno_;
+  }
+
+ private:
+  int saved_errno_;
+};
+
 static void SignalLogOnly(int, siginfo_t*, void*) {
+  ErrnoRestorer restore;
+
   BACK_LOGE("pid %d, tid %d: Received a spurious signal %d\n", getpid(), gettid(), THREAD_SIGNAL);
 }
 
 static void SignalHandler(int, siginfo_t*, void* sigcontext) {
+  ErrnoRestorer restore;
+
   ThreadEntry* entry = ThreadEntry::Get(getpid(), gettid(), false);
   if (!entry) {
     BACK_LOGE("pid %d, tid %d entry not found", getpid(), gettid());
diff --git a/libsync/sync.c b/libsync/sync.c
index 27dab83..baeccda 100644
--- a/libsync/sync.c
+++ b/libsync/sync.c
@@ -16,12 +16,13 @@
  *  limitations under the License.
  */
 
+#include <errno.h>
 #include <fcntl.h>
 #include <malloc.h>
+#include <poll.h>
+#include <stdatomic.h>
 #include <stdint.h>
 #include <string.h>
-#include <errno.h>
-#include <poll.h>
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -79,6 +80,24 @@
 #define SW_SYNC_IOC_CREATE_FENCE _IOWR(SW_SYNC_IOC_MAGIC, 0, struct sw_sync_create_fence_data)
 #define SW_SYNC_IOC_INC _IOW(SW_SYNC_IOC_MAGIC, 1, __u32)
 
+// ---------------------------------------------------------------------------
+// Support for caching the sync uapi version.
+//
+// This library supports both legacy (android/staging) uapi and modern
+// (mainline) sync uapi. Library calls first try one uapi, and if that fails,
+// try the other. Since any given kernel only supports one uapi version, after
+// the first successful syscall we know what the kernel supports and can skip
+// trying the other.
+
+enum uapi_version {
+    UAPI_UNKNOWN,
+    UAPI_MODERN,
+    UAPI_LEGACY
+};
+static atomic_int g_uapi_version = ATOMIC_VAR_INIT(UAPI_UNKNOWN);
+
+// ---------------------------------------------------------------------------
+
 int sync_wait(int fd, int timeout)
 {
     struct pollfd fds;
@@ -109,9 +128,21 @@
     return ret;
 }
 
-int sync_merge(const char *name, int fd1, int fd2)
+static int legacy_sync_merge(const char *name, int fd1, int fd2)
 {
-    struct sync_legacy_merge_data legacy_data;
+    struct sync_legacy_merge_data data;
+    int ret;
+
+    data.fd2 = fd2;
+    strlcpy(data.name, name, sizeof(data.name));
+    ret = ioctl(fd1, SYNC_IOC_LEGACY_MERGE, &data);
+    if (ret < 0)
+        return ret;
+    return data.fence;
+}
+
+static int modern_sync_merge(const char *name, int fd1, int fd2)
+{
     struct sync_merge_data data;
     int ret;
 
@@ -121,20 +152,35 @@
     data.pad = 0;
 
     ret = ioctl(fd1, SYNC_IOC_MERGE, &data);
-    if (ret < 0 && errno == ENOTTY) {
-        legacy_data.fd2 = fd2;
-        strlcpy(legacy_data.name, name, sizeof(legacy_data.name));
-
-        ret = ioctl(fd1, SYNC_IOC_LEGACY_MERGE, &legacy_data);
-        if (ret < 0)
-            return ret;
-
-        return legacy_data.fence;
-    } else if (ret < 0) {
+    if (ret < 0)
         return ret;
+    return data.fence;
+}
+
+int sync_merge(const char *name, int fd1, int fd2)
+{
+    int uapi;
+    int ret;
+
+    uapi = atomic_load_explicit(&g_uapi_version, memory_order_acquire);
+
+    if (uapi == UAPI_MODERN || uapi == UAPI_UNKNOWN) {
+        ret = modern_sync_merge(name, fd1, fd2);
+        if (ret >= 0 || errno != ENOTTY) {
+            if (ret >= 0 && uapi == UAPI_UNKNOWN) {
+                atomic_store_explicit(&g_uapi_version, UAPI_MODERN,
+                                      memory_order_release);
+            }
+            return ret;
+        }
     }
 
-    return data.fence;
+    ret = legacy_sync_merge(name, fd1, fd2);
+    if (ret >= 0 && uapi == UAPI_UNKNOWN) {
+        atomic_store_explicit(&g_uapi_version, UAPI_LEGACY,
+                              memory_order_release);
+    }
+    return ret;
 }
 
 static struct sync_fence_info_data *legacy_sync_fence_info(int fd)
@@ -255,15 +301,29 @@
 struct sync_fence_info_data *sync_fence_info(int fd)
 {
     struct sync_fence_info_data *legacy_info;
+    int uapi;
 
-    legacy_info = legacy_sync_fence_info(fd);
-    if (legacy_info || errno != ENOTTY)
-        return legacy_info;
+    uapi = atomic_load_explicit(&g_uapi_version, memory_order_acquire);
+
+    if (uapi == UAPI_LEGACY || uapi == UAPI_UNKNOWN) {
+        legacy_info = legacy_sync_fence_info(fd);
+        if (legacy_info || errno != ENOTTY) {
+            if (legacy_info && uapi == UAPI_UNKNOWN) {
+                atomic_store_explicit(&g_uapi_version, UAPI_LEGACY,
+                                      memory_order_release);
+            }
+            return legacy_info;
+        }
+    }
 
     struct sync_file_info* file_info;
     file_info = modern_sync_file_info(fd);
     if (!file_info)
         return NULL;
+    if (uapi == UAPI_UNKNOWN) {
+        atomic_store_explicit(&g_uapi_version, UAPI_MODERN,
+                              memory_order_release);
+    }
     legacy_info = sync_file_info_to_legacy_fence_info(file_info);
     sync_file_info_free(file_info);
     return legacy_info;
@@ -272,15 +332,29 @@
 struct sync_file_info* sync_file_info(int32_t fd)
 {
     struct sync_file_info *info;
+    int uapi;
+
+    uapi = atomic_load_explicit(&g_uapi_version, memory_order_acquire);
+
+    if (uapi == UAPI_MODERN || uapi == UAPI_UNKNOWN) {
+        info = modern_sync_file_info(fd);
+        if (info || errno != ENOTTY) {
+            if (info && uapi == UAPI_UNKNOWN) {
+                atomic_store_explicit(&g_uapi_version, UAPI_MODERN,
+                                      memory_order_release);
+            }
+            return info;
+        }
+    }
+
     struct sync_fence_info_data *legacy_info;
-
-    info = modern_sync_file_info(fd);
-    if (info || errno != ENOTTY)
-        return info;
-
     legacy_info = legacy_sync_fence_info(fd);
     if (!legacy_info)
         return NULL;
+    if (uapi == UAPI_UNKNOWN) {
+        atomic_store_explicit(&g_uapi_version, UAPI_LEGACY,
+                              memory_order_release);
+    }
     info = legacy_fence_info_to_sync_file_info(legacy_info);
     sync_fence_info_free(legacy_info);
     return info;
diff --git a/logd/.clang-format b/logd/.clang-format
new file mode 100644
index 0000000..393c309
--- /dev/null
+++ b/logd/.clang-format
@@ -0,0 +1,11 @@
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: false
+
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+PenaltyExcessCharacter: 32
+
+Cpp11BracedListStyle: false
diff --git a/logd/CommandListener.cpp b/logd/CommandListener.cpp
index 6ad7351..06c0ab5 100644
--- a/logd/CommandListener.cpp
+++ b/logd/CommandListener.cpp
@@ -20,8 +20,8 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <netinet/in.h>
-#include <string.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -37,9 +37,9 @@
 #include "LogCommand.h"
 #include "LogUtils.h"
 
-CommandListener::CommandListener(LogBuffer *buf, LogReader * /*reader*/,
-                                 LogListener * /*swl*/) :
-        FrameworkListener(getLogSocket()) {
+CommandListener::CommandListener(LogBuffer* buf, LogReader* /*reader*/,
+                                 LogListener* /*swl*/)
+    : FrameworkListener(getLogSocket()) {
     // registerCmd(new ShutdownCmd(buf, writer, swl));
     registerCmd(new ClearCmd(buf));
     registerCmd(new GetBufSizeCmd(buf));
@@ -53,24 +53,19 @@
     registerCmd(new ExitCmd(this));
 }
 
-CommandListener::ShutdownCmd::ShutdownCmd(LogReader *reader,
-                                          LogListener *swl) :
-        LogCommand("shutdown"),
-        mReader(*reader),
-        mSwl(*swl) {
+CommandListener::ShutdownCmd::ShutdownCmd(LogReader* reader, LogListener* swl)
+    : LogCommand("shutdown"), mReader(*reader), mSwl(*swl) {
 }
 
-int CommandListener::ShutdownCmd::runCommand(SocketClient * /*cli*/,
-                                             int /*argc*/,
-                                             char ** /*argv*/) {
+int CommandListener::ShutdownCmd::runCommand(SocketClient* /*cli*/,
+                                             int /*argc*/, char** /*argv*/) {
     mSwl.stopListener();
     mReader.stopListener();
     exit(0);
 }
 
-CommandListener::ClearCmd::ClearCmd(LogBuffer *buf) :
-        LogCommand("clear"),
-        mBuf(*buf) {
+CommandListener::ClearCmd::ClearCmd(LogBuffer* buf)
+    : LogCommand("clear"), mBuf(*buf) {
 }
 
 static void setname() {
@@ -81,8 +76,8 @@
     }
 }
 
-int CommandListener::ClearCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::ClearCmd::runCommand(SocketClient* cli, int argc,
+                                          char** argv) {
     setname();
     uid_t uid = cli->getUid();
     if (clientHasLogCredentials(cli)) {
@@ -100,17 +95,16 @@
         return 0;
     }
 
-    cli->sendMsg(mBuf.clear((log_id_t) id, uid) ? "busy" : "success");
+    cli->sendMsg(mBuf.clear((log_id_t)id, uid) ? "busy" : "success");
     return 0;
 }
 
-CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer *buf) :
-        LogCommand("getLogSize"),
-        mBuf(*buf) {
+CommandListener::GetBufSizeCmd::GetBufSizeCmd(LogBuffer* buf)
+    : LogCommand("getLogSize"), mBuf(*buf) {
 }
 
-int CommandListener::GetBufSizeCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::GetBufSizeCmd::runCommand(SocketClient* cli, int argc,
+                                               char** argv) {
     setname();
     if (argc < 2) {
         cli->sendMsg("Missing Argument");
@@ -123,20 +117,19 @@
         return 0;
     }
 
-    unsigned long size = mBuf.getSize((log_id_t) id);
+    unsigned long size = mBuf.getSize((log_id_t)id);
     char buf[512];
     snprintf(buf, sizeof(buf), "%lu", size);
     cli->sendMsg(buf);
     return 0;
 }
 
-CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer *buf) :
-        LogCommand("setLogSize"),
-        mBuf(*buf) {
+CommandListener::SetBufSizeCmd::SetBufSizeCmd(LogBuffer* buf)
+    : LogCommand("setLogSize"), mBuf(*buf) {
 }
 
-int CommandListener::SetBufSizeCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::SetBufSizeCmd::runCommand(SocketClient* cli, int argc,
+                                               char** argv) {
     setname();
     if (!clientHasLogCredentials(cli)) {
         cli->sendMsg("Permission Denied");
@@ -155,7 +148,7 @@
     }
 
     unsigned long size = atol(argv[2]);
-    if (mBuf.setSize((log_id_t) id, size)) {
+    if (mBuf.setSize((log_id_t)id, size)) {
         cli->sendMsg("Range Error");
         return 0;
     }
@@ -164,13 +157,12 @@
     return 0;
 }
 
-CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer *buf) :
-        LogCommand("getLogSizeUsed"),
-        mBuf(*buf) {
+CommandListener::GetBufSizeUsedCmd::GetBufSizeUsedCmd(LogBuffer* buf)
+    : LogCommand("getLogSizeUsed"), mBuf(*buf) {
 }
 
-int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::GetBufSizeUsedCmd::runCommand(SocketClient* cli, int argc,
+                                                   char** argv) {
     setname();
     if (argc < 2) {
         cli->sendMsg("Missing Argument");
@@ -183,29 +175,29 @@
         return 0;
     }
 
-    unsigned long size = mBuf.getSizeUsed((log_id_t) id);
+    unsigned long size = mBuf.getSizeUsed((log_id_t)id);
     char buf[512];
     snprintf(buf, sizeof(buf), "%lu", size);
     cli->sendMsg(buf);
     return 0;
 }
 
-CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer *buf) :
-        LogCommand("getStatistics"),
-        mBuf(*buf) {
+CommandListener::GetStatisticsCmd::GetStatisticsCmd(LogBuffer* buf)
+    : LogCommand("getStatistics"), mBuf(*buf) {
 }
 
-static std::string package_string(const std::string &str) {
+static std::string package_string(const std::string& str) {
     // Calculate total buffer size prefix, count is the string length w/o nul
     char fmt[32];
-    for(size_t l = str.length(), y = 0, x = 6; y != x; y = x, x = strlen(fmt) - 2) {
+    for (size_t l = str.length(), y = 0, x = 6; y != x;
+         y = x, x = strlen(fmt) - 2) {
         snprintf(fmt, sizeof(fmt), "%zu\n%%s\n\f", l + x);
     }
     return android::base::StringPrintf(fmt, str.c_str());
 }
 
-int CommandListener::GetStatisticsCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::GetStatisticsCmd::runCommand(SocketClient* cli, int argc,
+                                                  char** argv) {
     setname();
     uid_t uid = cli->getUid();
     if (clientHasLogCredentials(cli)) {
@@ -236,30 +228,28 @@
         }
     }
 
-    cli->sendMsg(package_string(mBuf.formatStatistics(uid, pid,
-                                                      logMask)).c_str());
+    cli->sendMsg(
+        package_string(mBuf.formatStatistics(uid, pid, logMask)).c_str());
     return 0;
 }
 
-CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer *buf) :
-        LogCommand("getPruneList"),
-        mBuf(*buf) {
+CommandListener::GetPruneListCmd::GetPruneListCmd(LogBuffer* buf)
+    : LogCommand("getPruneList"), mBuf(*buf) {
 }
 
-int CommandListener::GetPruneListCmd::runCommand(SocketClient *cli,
-                                         int /*argc*/, char ** /*argv*/) {
+int CommandListener::GetPruneListCmd::runCommand(SocketClient* cli,
+                                                 int /*argc*/, char** /*argv*/) {
     setname();
     cli->sendMsg(package_string(mBuf.formatPrune()).c_str());
     return 0;
 }
 
-CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer *buf) :
-        LogCommand("setPruneList"),
-        mBuf(*buf) {
+CommandListener::SetPruneListCmd::SetPruneListCmd(LogBuffer* buf)
+    : LogCommand("setPruneList"), mBuf(*buf) {
 }
 
-int CommandListener::SetPruneListCmd::runCommand(SocketClient *cli,
-                                         int argc, char **argv) {
+int CommandListener::SetPruneListCmd::runCommand(SocketClient* cli, int argc,
+                                                 char** argv) {
     setname();
     if (!clientHasLogCredentials(cli)) {
         cli->sendMsg("Permission Denied");
@@ -286,22 +276,21 @@
     return 0;
 }
 
-CommandListener::GetEventTagCmd::GetEventTagCmd(LogBuffer *buf) :
-        LogCommand("getEventTag"),
-        mBuf(*buf) {
+CommandListener::GetEventTagCmd::GetEventTagCmd(LogBuffer* buf)
+    : LogCommand("getEventTag"), mBuf(*buf) {
 }
 
-int CommandListener::GetEventTagCmd::runCommand(SocketClient *cli,
-                                         int argc, char ** argv) {
+int CommandListener::GetEventTagCmd::runCommand(SocketClient* cli, int argc,
+                                                char** argv) {
     setname();
     uid_t uid = cli->getUid();
     if (clientHasLogCredentials(cli)) {
         uid = AID_ROOT;
     }
 
-    const char *name = NULL;
-    const char *format = NULL;
-    const char *id = NULL;
+    const char* name = NULL;
+    const char* format = NULL;
+    const char* id = NULL;
     for (int i = 1; i < argc; ++i) {
         static const char _name[] = "name=";
         if (!strncmp(argv[i], _name, strlen(_name))) {
@@ -331,8 +320,8 @@
         return 0;
     }
 
-    cli->sendMsg(package_string(mBuf.formatGetEventTag(uid,
-                                                       name, format)).c_str());
+    cli->sendMsg(
+        package_string(mBuf.formatGetEventTag(uid, name, format)).c_str());
 
     return 0;
 }
@@ -340,8 +329,8 @@
 CommandListener::ReinitCmd::ReinitCmd() : LogCommand("reinit") {
 }
 
-int CommandListener::ReinitCmd::runCommand(SocketClient *cli,
-                                         int /*argc*/, char ** /*argv*/) {
+int CommandListener::ReinitCmd::runCommand(SocketClient* cli, int /*argc*/,
+                                           char** /*argv*/) {
     setname();
 
     reinit_signal_handler(SIGHUP);
@@ -351,13 +340,12 @@
     return 0;
 }
 
-CommandListener::ExitCmd::ExitCmd(CommandListener *parent) :
-        LogCommand("EXIT"),
-        mParent(*parent) {
+CommandListener::ExitCmd::ExitCmd(CommandListener* parent)
+    : LogCommand("EXIT"), mParent(*parent) {
 }
 
-int CommandListener::ExitCmd::runCommand(SocketClient * cli,
-                                         int /*argc*/, char ** /*argv*/) {
+int CommandListener::ExitCmd::runCommand(SocketClient* cli, int /*argc*/,
+                                         char** /*argv*/) {
     setname();
 
     cli->sendMsg("success");
@@ -371,9 +359,8 @@
     int sock = android_get_control_socket(socketName);
 
     if (sock < 0) {
-        sock = socket_local_server(socketName,
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_STREAM);
+        sock = socket_local_server(
+            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM);
     }
 
     return sock;
diff --git a/logd/CommandListener.h b/logd/CommandListener.h
index 39de03b..ed99419 100644
--- a/logd/CommandListener.h
+++ b/logd/CommandListener.h
@@ -18,40 +18,43 @@
 #define _COMMANDLISTENER_H__
 
 #include <sysutils/FrameworkListener.h>
-#include "LogCommand.h"
 #include "LogBuffer.h"
-#include "LogReader.h"
+#include "LogCommand.h"
 #include "LogListener.h"
+#include "LogReader.h"
 
 // See main.cpp for implementation
 void reinit_signal_handler(int /*signal*/);
 
 class CommandListener : public FrameworkListener {
+   public:
+    CommandListener(LogBuffer* buf, LogReader* reader, LogListener* swl);
+    virtual ~CommandListener() {
+    }
 
-public:
-    CommandListener(LogBuffer *buf, LogReader *reader, LogListener *swl);
-    virtual ~CommandListener() {}
-
-private:
+   private:
     static int getLogSocket();
 
     class ShutdownCmd : public LogCommand {
-        LogReader &mReader;
-        LogListener &mSwl;
+        LogReader& mReader;
+        LogListener& mSwl;
 
-    public:
-        ShutdownCmd(LogReader *reader, LogListener *swl);
-        virtual ~ShutdownCmd() {}
-        int runCommand(SocketClient *c, int argc, char ** argv);
+       public:
+        ShutdownCmd(LogReader* reader, LogListener* swl);
+        virtual ~ShutdownCmd() {
+        }
+        int runCommand(SocketClient* c, int argc, char** argv);
     };
 
-#define LogBufferCmd(name)                                       \
-    class name##Cmd : public LogCommand {                        \
-        LogBuffer &mBuf;                                         \
-    public:                                                      \
-        explicit name##Cmd(LogBuffer *buf);                      \
-        virtual ~name##Cmd() {}                                  \
-        int runCommand(SocketClient *c, int argc, char ** argv); \
+#define LogBufferCmd(name)                                      \
+    class name##Cmd : public LogCommand {                       \
+        LogBuffer& mBuf;                                        \
+                                                                \
+       public:                                                  \
+        explicit name##Cmd(LogBuffer* buf);                     \
+        virtual ~name##Cmd() {                                  \
+        }                                                       \
+        int runCommand(SocketClient* c, int argc, char** argv); \
     }
 
     LogBufferCmd(Clear);
@@ -63,29 +66,33 @@
     LogBufferCmd(SetPruneList);
     LogBufferCmd(GetEventTag);
 
-#define LogCmd(name)                                             \
-    class name##Cmd : public LogCommand {                        \
-    public:                                                      \
-        name##Cmd();                                             \
-        virtual ~name##Cmd() {}                                  \
-        int runCommand(SocketClient *c, int argc, char ** argv); \
+#define LogCmd(name)                                            \
+    class name##Cmd : public LogCommand {                       \
+       public:                                                  \
+        name##Cmd();                                            \
+        virtual ~name##Cmd() {                                  \
+        }                                                       \
+        int runCommand(SocketClient* c, int argc, char** argv); \
     }
 
     LogCmd(Reinit);
 
-#define LogParentCmd(name)                                       \
-    class name##Cmd : public LogCommand {                        \
-        CommandListener &mParent;                                \
-    public:                                                      \
-        name##Cmd();                                             \
-        explicit name##Cmd(CommandListener *parent);             \
-        virtual ~name##Cmd() {}                                  \
-        int runCommand(SocketClient *c, int argc, char ** argv); \
-        void release(SocketClient *c) { mParent.release(c); }    \
+#define LogParentCmd(name)                                      \
+    class name##Cmd : public LogCommand {                       \
+        CommandListener& mParent;                               \
+                                                                \
+       public:                                                  \
+        name##Cmd();                                            \
+        explicit name##Cmd(CommandListener* parent);            \
+        virtual ~name##Cmd() {                                  \
+        }                                                       \
+        int runCommand(SocketClient* c, int argc, char** argv); \
+        void release(SocketClient* c) {                         \
+            mParent.release(c);                                 \
+        }                                                       \
     }
 
     LogParentCmd(Exit);
-
 };
 
 #endif
diff --git a/logd/FlushCommand.cpp b/logd/FlushCommand.cpp
index 6a26d00..5a5c0d9 100644
--- a/logd/FlushCommand.cpp
+++ b/logd/FlushCommand.cpp
@@ -26,20 +26,16 @@
 #include "LogTimes.h"
 #include "LogUtils.h"
 
-FlushCommand::FlushCommand(LogReader &reader,
-                           bool nonBlock,
-                           unsigned long tail,
-                           unsigned int logMask,
-                           pid_t pid,
-                           uint64_t start,
-                           uint64_t timeout) :
-        mReader(reader),
-        mNonBlock(nonBlock),
-        mTail(tail),
-        mLogMask(logMask),
-        mPid(pid),
-        mStart(start),
-        mTimeout((start > 1) ? timeout : 0) {
+FlushCommand::FlushCommand(LogReader& reader, bool nonBlock, unsigned long tail,
+                           unsigned int logMask, pid_t pid, uint64_t start,
+                           uint64_t timeout)
+    : mReader(reader),
+      mNonBlock(nonBlock),
+      mTail(tail),
+      mLogMask(logMask),
+      mPid(pid),
+      mStart(start),
+      mTimeout((start > 1) ? timeout : 0) {
 }
 
 // runSocketCommand is called once for every open client on the
@@ -51,13 +47,13 @@
 // global LogTimeEntry::lock() is used to protect access,
 // reference counts are used to ensure that individual
 // LogTimeEntry lifetime is managed when not protected.
-void FlushCommand::runSocketCommand(SocketClient *client) {
-    LogTimeEntry *entry = NULL;
-    LastLogTimes &times = mReader.logbuf().mTimes;
+void FlushCommand::runSocketCommand(SocketClient* client) {
+    LogTimeEntry* entry = NULL;
+    LastLogTimes& times = mReader.logbuf().mTimes;
 
     LogTimeEntry::lock();
     LastLogTimes::iterator it = times.begin();
-    while(it != times.end()) {
+    while (it != times.end()) {
         entry = (*it);
         if (entry->mClient == client) {
             if (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec) {
@@ -77,7 +73,7 @@
 
     if (it == times.end()) {
         // Create LogTimeEntry in notifyNewLog() ?
-        if (mTail == (unsigned long) -1) {
+        if (mTail == (unsigned long)-1) {
             LogTimeEntry::unlock();
             return;
         }
@@ -93,14 +89,14 @@
     LogTimeEntry::unlock();
 }
 
-bool FlushCommand::hasReadLogs(SocketClient *client) {
+bool FlushCommand::hasReadLogs(SocketClient* client) {
     return clientHasLogCredentials(client);
 }
 
-static bool clientHasSecurityCredentials(SocketClient *client) {
+static bool clientHasSecurityCredentials(SocketClient* client) {
     return (client->getUid() == AID_SYSTEM) || (client->getGid() == AID_SYSTEM);
 }
 
-bool FlushCommand::hasSecurityLogs(SocketClient *client) {
+bool FlushCommand::hasSecurityLogs(SocketClient* client) {
     return clientHasSecurityCredentials(client);
 }
diff --git a/logd/FlushCommand.h b/logd/FlushCommand.h
index 1e7818a..45cb9c5 100644
--- a/logd/FlushCommand.h
+++ b/logd/FlushCommand.h
@@ -26,7 +26,7 @@
 class LogReader;
 
 class FlushCommand : public SocketClientCommand {
-    LogReader &mReader;
+    LogReader& mReader;
     bool mNonBlock;
     unsigned long mTail;
     unsigned int mLogMask;
@@ -34,18 +34,15 @@
     uint64_t mStart;
     uint64_t mTimeout;
 
-public:
-    explicit FlushCommand(LogReader &mReader,
-                 bool nonBlock = false,
-                 unsigned long tail = -1,
-                 unsigned int logMask = -1,
-                 pid_t pid = 0,
-                 uint64_t start = 1,
-                 uint64_t timeout = 0);
-    virtual void runSocketCommand(SocketClient *client);
+   public:
+    explicit FlushCommand(LogReader& mReader, bool nonBlock = false,
+                          unsigned long tail = -1, unsigned int logMask = -1,
+                          pid_t pid = 0, uint64_t start = 1,
+                          uint64_t timeout = 0);
+    virtual void runSocketCommand(SocketClient* client);
 
-    static bool hasReadLogs(SocketClient *client);
-    static bool hasSecurityLogs(SocketClient *client);
+    static bool hasReadLogs(SocketClient* client);
+    static bool hasSecurityLogs(SocketClient* client);
 };
 
 #endif
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 92d957f..2d9024a 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -29,38 +29,52 @@
 #include <private/android_filesystem_config.h>
 #include <private/android_logger.h>
 
-#include "libaudit.h"
 #include "LogAudit.h"
 #include "LogBuffer.h"
 #include "LogKlog.h"
 #include "LogReader.h"
 #include "LogUtils.h"
+#include "libaudit.h"
 
-#define KMSG_PRIORITY(PRI)                          \
-    '<',                                            \
-    '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \
-    '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, \
-    '>'
+#define KMSG_PRIORITY(PRI)                               \
+    '<', '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) / 10, \
+        '0' + LOG_MAKEPRI(LOG_AUTH, LOG_PRI(PRI)) % 10, '>'
 
-LogAudit::LogAudit(LogBuffer *buf, LogReader *reader, int fdDmesg) :
-        SocketListener(mSock = getLogSocket(), false),
-        logbuf(buf),
-        reader(reader),
-        fdDmesg(fdDmesg),
-        main(__android_logger_property_get_bool("ro.logd.auditd.main",
+LogAudit::LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg)
+    : SocketListener(mSock = getLogSocket(), false),
+      logbuf(buf),
+      reader(reader),
+      fdDmesg(fdDmesg),
+      main(__android_logger_property_get_bool("ro.logd.auditd.main",
+                                              BOOL_DEFAULT_TRUE)),
+      events(__android_logger_property_get_bool("ro.logd.auditd.events",
                                                 BOOL_DEFAULT_TRUE)),
-        events(__android_logger_property_get_bool("ro.logd.auditd.events",
-                                                  BOOL_DEFAULT_TRUE)),
-        initialized(false),
-        tooFast(false) {
+      initialized(false),
+      tooFast(false) {
     static const char auditd_message[] = { KMSG_PRIORITY(LOG_INFO),
-        'l', 'o', 'g', 'd', '.', 'a', 'u', 'd', 'i', 't', 'd', ':',
-        ' ', 's', 't', 'a', 'r', 't', '\n' };
+                                           'l',
+                                           'o',
+                                           'g',
+                                           'd',
+                                           '.',
+                                           'a',
+                                           'u',
+                                           'd',
+                                           'i',
+                                           't',
+                                           'd',
+                                           ':',
+                                           ' ',
+                                           's',
+                                           't',
+                                           'a',
+                                           'r',
+                                           't',
+                                           '\n' };
     write(fdDmesg, auditd_message, sizeof(auditd_message));
 }
 
 void LogAudit::checkRateLimit() {
-
     // trim list for AUDIT_RATE_LIMIT_BURST_DURATION of history
     log_time oldest(AUDIT_RATE_LIMIT_BURST_DURATION, 0);
     bucket.emplace(android_log_clockid());
@@ -69,8 +83,9 @@
 
     static const size_t upperThreshold =
         ((AUDIT_RATE_LIMIT_BURST_DURATION *
-          (AUDIT_RATE_LIMIT_DEFAULT + AUDIT_RATE_LIMIT_MAX)) + 1) /
-                              2;
+          (AUDIT_RATE_LIMIT_DEFAULT + AUDIT_RATE_LIMIT_MAX)) +
+         1) /
+        2;
     if (bucket.size() >= upperThreshold) {
         // Hit peak, slow down source
         if (!tooFast) {
@@ -89,8 +104,8 @@
 
     if (!tooFast) return;
 
-    static const size_t lowerThreshold = AUDIT_RATE_LIMIT_BURST_DURATION *
-                                         AUDIT_RATE_LIMIT_MAX;
+    static const size_t lowerThreshold =
+        AUDIT_RATE_LIMIT_BURST_DURATION * AUDIT_RATE_LIMIT_MAX;
 
     if (bucket.size() >= lowerThreshold) return;
 
@@ -99,7 +114,7 @@
     audit_rate_limit(mSock, AUDIT_RATE_LIMIT_DEFAULT);
 }
 
-bool LogAudit::onDataAvailable(SocketClient *cli) {
+bool LogAudit::onDataAvailable(SocketClient* cli) {
     if (!initialized) {
         prctl(PR_SET_NAME, "logd.auditd");
         initialized = true;
@@ -123,14 +138,14 @@
     return true;
 }
 
-int LogAudit::logPrint(const char *fmt, ...) {
+int LogAudit::logPrint(const char* fmt, ...) {
     if (fmt == NULL) {
         return -EINVAL;
     }
 
     va_list args;
 
-    char *str = NULL;
+    char* str = NULL;
     va_start(args, fmt);
     int rc = vasprintf(&str, fmt, args);
     va_end(args);
@@ -139,7 +154,7 @@
         return rc;
     }
 
-    char *cp;
+    char* cp;
     // Work around kernels missing
     // https://github.com/torvalds/linux/commit/b8f89caafeb55fba75b74bea25adc4e4cd91be67
     // Such kernels improperly add newlines inside audit messages.
@@ -160,19 +175,19 @@
 
         // Dedupe messages, checking for identical messages starting with avc:
         static unsigned count;
-        static char *last_str;
+        static char* last_str;
         static bool last_info;
 
         if (last_str != NULL) {
             static const char avc[] = "): avc: ";
-            char *avcl = strstr(last_str, avc);
+            char* avcl = strstr(last_str, avc);
             bool skip = false;
 
             if (avcl) {
-                char *avcr = strstr(str, avc);
+                char* avcr = strstr(str, avc);
 
-                skip = avcr && !fastcmp<strcmp>(avcl + strlen(avc),
-                                                avcr + strlen(avc));
+                skip = avcr &&
+                       !fastcmp<strcmp>(avcl + strlen(avc), avcr + strlen(avc));
                 if (skip) {
                     ++count;
                     free(last_str);
@@ -183,19 +198,17 @@
             if (!skip) {
                 static const char resume[] = " duplicate messages suppressed\n";
 
-                iov[0].iov_base = last_info ?
-                    const_cast<char *>(log_info) :
-                    const_cast<char *>(log_warning);
-                iov[0].iov_len = last_info ?
-                    sizeof(log_info) :
-                    sizeof(log_warning);
+                iov[0].iov_base = last_info ? const_cast<char*>(log_info)
+                                            : const_cast<char*>(log_warning);
+                iov[0].iov_len =
+                    last_info ? sizeof(log_info) : sizeof(log_warning);
                 iov[1].iov_base = last_str;
                 iov[1].iov_len = strlen(last_str);
                 if (count > 1) {
-                    iov[2].iov_base = const_cast<char *>(resume);
+                    iov[2].iov_base = const_cast<char*>(resume);
                     iov[2].iov_len = strlen(resume);
                 } else {
-                    iov[2].iov_base = const_cast<char *>(newline);
+                    iov[2].iov_base = const_cast<char*>(newline);
                     iov[2].iov_len = strlen(newline);
                 }
 
@@ -210,15 +223,12 @@
             last_info = info;
         }
         if (count == 0) {
-            iov[0].iov_base = info ?
-                const_cast<char *>(log_info) :
-                const_cast<char *>(log_warning);
-            iov[0].iov_len = info ?
-                sizeof(log_info) :
-                sizeof(log_warning);
+            iov[0].iov_base = info ? const_cast<char*>(log_info)
+                                   : const_cast<char*>(log_warning);
+            iov[0].iov_len = info ? sizeof(log_info) : sizeof(log_warning);
             iov[1].iov_base = str;
             iov[1].iov_len = strlen(str);
-            iov[2].iov_base = const_cast<char *>(newline);
+            iov[2].iov_base = const_cast<char*>(newline);
             iov[2].iov_len = strlen(newline);
 
             writev(fdDmesg, iov, arraysize(iov));
@@ -236,10 +246,10 @@
     log_time now;
 
     static const char audit_str[] = " audit(";
-    char *timeptr = strstr(str, audit_str);
-    if (timeptr
-            && ((cp = now.strptime(timeptr + sizeof(audit_str) - 1, "%s.%q")))
-            && (*cp == ':')) {
+    char* timeptr = strstr(str, audit_str);
+    if (timeptr &&
+        ((cp = now.strptime(timeptr + sizeof(audit_str) - 1, "%s.%q"))) &&
+        (*cp == ':')) {
         memcpy(timeptr + sizeof(audit_str) - 1, "0.0", 3);
         memmove(timeptr + sizeof(audit_str) - 1 + 3, cp, strlen(cp) + 1);
         if (!isMonotonic()) {
@@ -258,7 +268,7 @@
     }
 
     static const char pid_str[] = " pid=";
-    char *pidptr = strstr(str, pid_str);
+    char* pidptr = strstr(str, pid_str);
     if (pidptr && isdigit(pidptr[sizeof(pid_str) - 1])) {
         cp = pidptr + sizeof(pid_str) - 1;
         pid = 0;
@@ -280,19 +290,19 @@
 
     bool notify = false;
 
-    if (events) {   // begin scope for event buffer
+    if (events) {  // begin scope for event buffer
         uint32_t buffer[(n + sizeof(uint32_t) - 1) / sizeof(uint32_t)];
 
-        android_log_event_string_t *event
-            = reinterpret_cast<android_log_event_string_t *>(buffer);
+        android_log_event_string_t* event =
+            reinterpret_cast<android_log_event_string_t*>(buffer);
         event->header.tag = htole32(AUDITD_LOG_TAG);
         event->type = EVENT_TYPE_STRING;
         event->length = htole32(l);
         memcpy(event->data, str, l);
 
         rc = logbuf->log(LOG_ID_EVENTS, now, uid, pid, tid,
-                         reinterpret_cast<char *>(event),
-                         (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX);
+                         reinterpret_cast<char*>(event),
+                         (n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX);
         if (rc >= 0) {
             notify = true;
         }
@@ -302,9 +312,9 @@
     // log to main
 
     static const char comm_str[] = " comm=\"";
-    const char *comm = strstr(str, comm_str);
-    const char *estr = str + strlen(str);
-    const char *commfree = NULL;
+    const char* comm = strstr(str, comm_str);
+    const char* estr = str + strlen(str);
+    const char* commfree = NULL;
     if (comm) {
         estr = comm;
         comm += sizeof(comm_str) - 1;
@@ -320,7 +330,7 @@
         }
     }
 
-    const char *ecomm = strchr(comm, '"');
+    const char* ecomm = strchr(comm, '"');
     if (ecomm) {
         ++ecomm;
         l = ecomm - comm;
@@ -335,7 +345,7 @@
     size_t e = strnlen(ecomm, LOGGER_ENTRY_MAX_PAYLOAD - b);
     n = b + e + l + 2;
 
-    if (main) {   // begin scope for main buffer
+    if (main) {  // begin scope for main buffer
         char newstr[n];
 
         *newstr = info ? ANDROID_LOG_INFO : ANDROID_LOG_WARN;
@@ -344,7 +354,7 @@
         strncpy(newstr + 1 + l + b, ecomm, e);
 
         rc = logbuf->log(LOG_ID_MAIN, now, uid, pid, tid, newstr,
-                         (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX);
+                         (n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX);
 
         if (rc >= 0) {
             notify = true;
@@ -352,7 +362,7 @@
         // end scope for main buffer
     }
 
-    free(const_cast<char *>(commfree));
+    free(const_cast<char*>(commfree));
     free(str);
 
     if (notify) {
@@ -365,8 +375,8 @@
     return rc;
 }
 
-int LogAudit::log(char *buf, size_t len) {
-    char *audit = strstr(buf, " audit(");
+int LogAudit::log(char* buf, size_t len) {
+    char* audit = strstr(buf, " audit(");
     if (!audit || (audit >= &buf[len])) {
         return 0;
     }
@@ -374,7 +384,7 @@
     *audit = '\0';
 
     int rc;
-    char *type = strstr(buf, "type=");
+    char* type = strstr(buf, "type=");
     if (type && (type < &buf[len])) {
         rc = logPrint("%s %s", type, audit + 1);
     } else {
diff --git a/logd/LogAudit.h b/logd/LogAudit.h
index 045d631..5947819 100644
--- a/logd/LogAudit.h
+++ b/logd/LogAudit.h
@@ -26,9 +26,9 @@
 class LogReader;
 
 class LogAudit : public SocketListener {
-    LogBuffer *logbuf;
-    LogReader *reader;
-    int fdDmesg; // fdDmesg >= 0 is functionally bool dmesg
+    LogBuffer* logbuf;
+    LogReader* reader;
+    int fdDmesg;  // fdDmesg >= 0 is functionally bool dmesg
     bool main;
     bool events;
     bool initialized;
@@ -38,18 +38,20 @@
     std::queue<log_time> bucket;
     void checkRateLimit();
 
-public:
-    LogAudit(LogBuffer *buf, LogReader *reader, int fdDmesg);
-    int log(char *buf, size_t len);
-    bool isMonotonic() { return logbuf->isMonotonic(); }
+   public:
+    LogAudit(LogBuffer* buf, LogReader* reader, int fdDmesg);
+    int log(char* buf, size_t len);
+    bool isMonotonic() {
+        return logbuf->isMonotonic();
+    }
 
-protected:
-    virtual bool onDataAvailable(SocketClient *cli);
+   protected:
+    virtual bool onDataAvailable(SocketClient* cli);
 
-private:
+   private:
     static int getLogSocket();
-    int logPrint(const char *fmt, ...)
-        __attribute__ ((__format__ (__printf__, 2, 3)));
+    int logPrint(const char* fmt, ...)
+        __attribute__((__format__(__printf__, 2, 3)));
 };
 
 #endif
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 0df6de0..60d647d 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -72,8 +72,8 @@
         //
         pthread_mutex_lock(&mLogElementsLock);
         LogBufferElementCollection::iterator it = mLogElements.begin();
-        while((it != mLogElements.end())) {
-            LogBufferElement *e = *it;
+        while ((it != mLogElements.end())) {
+            LogBufferElement* e = *it;
             if (monotonic) {
                 if (!android::isMonotonic(e->mRealTime)) {
                     LogKlog::convertRealToMonotonic(e->mRealTime);
@@ -96,8 +96,8 @@
     LogTimeEntry::lock();
 
     LastLogTimes::iterator times = mTimes.begin();
-    while(times != mTimes.end()) {
-        LogTimeEntry *entry = (*times);
+    while (times != mTimes.end()) {
+        LogTimeEntry* entry = (*times);
         if (entry->owned_Locked()) {
             entry->triggerReader_Locked();
         }
@@ -107,9 +107,8 @@
     LogTimeEntry::unlock();
 }
 
-LogBuffer::LogBuffer(LastLogTimes *times):
-        monotonic(android_log_clockid() == CLOCK_MONOTONIC),
-        mTimes(*times) {
+LogBuffer::LogBuffer(LastLogTimes* times)
+    : monotonic(android_log_clockid() == CLOCK_MONOTONIC), mTimes(*times) {
     pthread_mutex_init(&mLogElementsLock, NULL);
 
     log_id_for_each(i) {
@@ -127,28 +126,26 @@
     }
 }
 
-enum match_type {
-    DIFFERENT,
-    SAME,
-    SAME_LIBLOG
-};
+enum match_type { DIFFERENT, SAME, SAME_LIBLOG };
 
-static enum match_type identical(LogBufferElement* elem, LogBufferElement* last) {
+static enum match_type identical(LogBufferElement* elem,
+                                 LogBufferElement* last) {
     // is it mostly identical?
-//  if (!elem) return DIFFERENT;
+    //  if (!elem) return DIFFERENT;
     unsigned short lenl = elem->getMsgLen();
     if (!lenl) return DIFFERENT;
-//  if (!last) return DIFFERENT;
+    //  if (!last) return DIFFERENT;
     unsigned short lenr = last->getMsgLen();
     if (!lenr) return DIFFERENT;
-//  if (elem->getLogId() != last->getLogId()) return DIFFERENT;
+    //  if (elem->getLogId() != last->getLogId()) return DIFFERENT;
     if (elem->getUid() != last->getUid()) return DIFFERENT;
     if (elem->getPid() != last->getPid()) return DIFFERENT;
     if (elem->getTid() != last->getTid()) return DIFFERENT;
 
     // last is more than a minute old, stop squashing identical messages
     if (elem->getRealTime().nsec() >
-        (last->getRealTime().nsec() + 60 * NS_PER_SEC)) return DIFFERENT;
+        (last->getRealTime().nsec() + 60 * NS_PER_SEC))
+        return DIFFERENT;
 
     // Identical message
     const char* msgl = elem->getMsg();
@@ -158,51 +155,54 @@
         // liblog tagged messages (content gets summed)
         if ((elem->getLogId() == LOG_ID_EVENTS) &&
             (lenl == sizeof(android_log_event_int_t)) &&
-            !fastcmp<memcmp>(msgl, msgr,
-                             sizeof(android_log_event_int_t) - sizeof(int32_t)) &&
-            (elem->getTag() == LIBLOG_LOG_TAG)) return SAME_LIBLOG;
+            !fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_int_t) -
+                                             sizeof(int32_t)) &&
+            (elem->getTag() == LIBLOG_LOG_TAG)) {
+            return SAME_LIBLOG;
+        }
     }
 
     // audit message (except sequence number) identical?
     static const char avc[] = "): avc: ";
 
     if (last->isBinary()) {
-        if (fastcmp<memcmp>(msgl, msgr,
-                            sizeof(android_log_event_string_t) -
-                                sizeof(int32_t))) return DIFFERENT;
+        if (fastcmp<memcmp>(msgl, msgr, sizeof(android_log_event_string_t) -
+                                            sizeof(int32_t))) {
+            return DIFFERENT;
+        }
         msgl += sizeof(android_log_event_string_t);
         lenl -= sizeof(android_log_event_string_t);
         msgr += sizeof(android_log_event_string_t);
         lenr -= sizeof(android_log_event_string_t);
     }
-    const char *avcl = android::strnstr(msgl, lenl, avc);
+    const char* avcl = android::strnstr(msgl, lenl, avc);
     if (!avcl) return DIFFERENT;
     lenl -= avcl - msgl;
-    const char *avcr = android::strnstr(msgr, lenr, avc);
+    const char* avcr = android::strnstr(msgr, lenr, avc);
     if (!avcr) return DIFFERENT;
     lenr -= avcr - msgr;
     if (lenl != lenr) return DIFFERENT;
     // TODO: After b/35468874 is addressed, revisit "lenl > strlen(avc)"
     // condition, it might become superflous.
     if (lenl > strlen(avc) &&
-        fastcmp<memcmp>(avcl + strlen(avc),
-                        avcr + strlen(avc),
-                        lenl - strlen(avc))) return DIFFERENT;
+        fastcmp<memcmp>(avcl + strlen(avc), avcr + strlen(avc),
+                        lenl - strlen(avc))) {
+        return DIFFERENT;
+    }
     return SAME;
 }
 
-int LogBuffer::log(log_id_t log_id, log_time realtime,
-                   uid_t uid, pid_t pid, pid_t tid,
-                   const char *msg, unsigned short len) {
+int LogBuffer::log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
+                   pid_t tid, const char* msg, unsigned short len) {
     if ((log_id >= LOG_ID_MAX) || (log_id < 0)) {
         return -EINVAL;
     }
 
-    LogBufferElement *elem = new LogBufferElement(log_id, realtime,
-                                                  uid, pid, tid, msg, len);
+    LogBufferElement* elem =
+        new LogBufferElement(log_id, realtime, uid, pid, tid, msg, len);
     if (log_id != LOG_ID_SECURITY) {
         int prio = ANDROID_LOG_INFO;
-        const char *tag = NULL;
+        const char* tag = NULL;
         if (log_id == LOG_ID_EVENTS) {
             tag = tagToName(elem->getTag());
         } else {
@@ -223,7 +223,7 @@
     pthread_mutex_lock(&mLogElementsLock);
     LogBufferElement* currentLast = lastLoggedElements[log_id];
     if (currentLast) {
-        LogBufferElement *dropped = droppedElements[log_id];
+        LogBufferElement* dropped = droppedElements[log_id];
         unsigned short count = dropped ? dropped->getDropped() : 0;
         //
         // State Init
@@ -313,7 +313,7 @@
                     uint32_t swab = event->payload.data;
                     unsigned long long total = htole32(swab);
                     event = reinterpret_cast<android_log_event_int_t*>(
-                            const_cast<char*>(elem->getMsg()));
+                        const_cast<char*>(elem->getMsg()));
                     swab = event->payload.data;
 
                     lastLoggedElements[LOG_ID_EVENTS] = elem;
@@ -350,15 +350,15 @@
             pthread_mutex_unlock(&mLogElementsLock);
             return len;
         }
-        if (dropped) { // State 1 or 2
-            if (count) { // State 2
-               log(dropped); // report chatty
-            } else { // State 1
-               delete dropped;
+        if (dropped) {         // State 1 or 2
+            if (count) {       // State 2
+                log(dropped);  // report chatty
+            } else {           // State 1
+                delete dropped;
             }
             droppedElements[log_id] = NULL;
-            log(currentLast); // report last message in the series
-        } else { // State 0
+            log(currentLast);  // report last message in the series
+        } else {               // State 0
             delete currentLast;
         }
     }
@@ -394,7 +394,7 @@
         LogTimeEntry::lock();
 
         LastLogTimes::iterator times = mTimes.begin();
-        while(times != mTimes.end()) {
+        while (times != mTimes.end()) {
             LogTimeEntry* entry = (*times);
             if (entry->owned_Locked()) {
                 if (!entry->mNonBlock) {
@@ -409,8 +409,7 @@
             times++;
         }
 
-        if (end_always
-                || (end_set && (end >= (*last)->getSequence()))) {
+        if (end_always || (end_set && (end >= (*last)->getSequence()))) {
             mLogElements.push_back(elem);
         } else {
             mLogElements.insert(last, elem);
@@ -448,30 +447,31 @@
 }
 
 LogBufferElementCollection::iterator LogBuffer::erase(
-        LogBufferElementCollection::iterator it, bool coalesce) {
-    LogBufferElement *element = *it;
+    LogBufferElementCollection::iterator it, bool coalesce) {
+    LogBufferElement* element = *it;
     log_id_t id = element->getLogId();
 
     // Remove iterator references in the various lists that will become stale
     // after the element is erased from the main logging list.
 
-    {   // start of scope for found iterator
-        int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ?
-                element->getTag() : element->getUid();
+    {  // start of scope for found iterator
+        int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY))
+                      ? element->getTag()
+                      : element->getUid();
         LogBufferIteratorMap::iterator found = mLastWorst[id].find(key);
         if ((found != mLastWorst[id].end()) && (it == found->second)) {
             mLastWorst[id].erase(found);
         }
     }
 
-    {   // start of scope for pid found iterator
+    {  // start of scope for pid found iterator
         // element->getUid() may not be AID_SYSTEM for next-best-watermark.
         // will not assume id != LOG_ID_EVENTS or LOG_ID_SECURITY for KISS and
         // long term code stability, find() check should be fast for those ids.
         LogBufferPidIteratorMap::iterator found =
             mLastWorstPidOfSystem[id].find(element->getPid());
-        if ((found != mLastWorstPidOfSystem[id].end())
-                && (it == found->second)) {
+        if ((found != mLastWorstPidOfSystem[id].end()) &&
+            (it == found->second)) {
             mLastWorstPidOfSystem[id].erase(found);
         }
     }
@@ -483,34 +483,35 @@
     }
 #ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
     LogBufferElementCollection::iterator bad = it;
-    int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ?
-            element->getTag() : element->getUid();
+    int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY))
+                  ? element->getTag()
+                  : element->getUid();
 #endif
     it = mLogElements.erase(it);
     if (doSetLast) {
         log_id_for_each(i) {
             if (setLast[i]) {
-                if (__predict_false(it == mLogElements.end())) { // impossible
+                if (__predict_false(it == mLogElements.end())) {  // impossible
                     mLastSet[i] = false;
                     mLast[i] = mLogElements.begin();
                 } else {
-                    mLast[i] = it; // push down the road as next-best-watermark
+                    mLast[i] = it;  // push down the road as next-best-watermark
                 }
             }
         }
     }
 #ifdef DEBUG_CHECK_FOR_STALE_ENTRIES
     log_id_for_each(i) {
-        for(auto b : mLastWorst[i]) {
+        for (auto b : mLastWorst[i]) {
             if (bad == b.second) {
-                android::prdebug("stale mLastWorst[%d] key=%d mykey=%d\n",
-                                 i, b.first, key);
+                android::prdebug("stale mLastWorst[%d] key=%d mykey=%d\n", i,
+                                 b.first, key);
             }
         }
-        for(auto b : mLastWorstPidOfSystem[i]) {
+        for (auto b : mLastWorstPidOfSystem[i]) {
             if (bad == b.second) {
-                android::prdebug("stale mLastWorstPidOfSystem[%d] pid=%d\n",
-                                 i, b.first);
+                android::prdebug("stale mLastWorstPidOfSystem[%d] pid=%d\n", i,
+                                 b.first);
             }
         }
         if (mLastSet[i] && (bad == mLast[i])) {
@@ -543,32 +544,29 @@
         uint64_t value;
     } __packed;
 
-public:
-    LogBufferElementKey(uid_t uid, pid_t pid, pid_t tid):
-            uid(uid),
-            pid(pid),
-            tid(tid)
-    {
+   public:
+    LogBufferElementKey(uid_t uid, pid_t pid, pid_t tid)
+        : uid(uid), pid(pid), tid(tid) {
     }
-    explicit LogBufferElementKey(uint64_t key):value(key) { }
+    explicit LogBufferElementKey(uint64_t key) : value(key) {
+    }
 
-    uint64_t getKey() { return value; }
+    uint64_t getKey() {
+        return value;
+    }
 };
 
 class LogBufferElementLast {
-
-    typedef std::unordered_map<uint64_t, LogBufferElement *> LogBufferElementMap;
+    typedef std::unordered_map<uint64_t, LogBufferElement*> LogBufferElementMap;
     LogBufferElementMap map;
 
-public:
-
-    bool coalesce(LogBufferElement *element, unsigned short dropped) {
-        LogBufferElementKey key(element->getUid(),
-                                element->getPid(),
+   public:
+    bool coalesce(LogBufferElement* element, unsigned short dropped) {
+        LogBufferElementKey key(element->getUid(), element->getPid(),
                                 element->getTid());
         LogBufferElementMap::iterator it = map.find(key.getKey());
         if (it != map.end()) {
-            LogBufferElement *found = it->second;
+            LogBufferElement* found = it->second;
             unsigned short moreDropped = found->getDropped();
             if ((dropped + moreDropped) > USHRT_MAX) {
                 map.erase(it);
@@ -580,9 +578,8 @@
         return false;
     }
 
-    void add(LogBufferElement *element) {
-        LogBufferElementKey key(element->getUid(),
-                                element->getPid(),
+    void add(LogBufferElement* element) {
+        LogBufferElementKey key(element->getUid(), element->getPid(),
                                 element->getTid());
         map[key.getKey()] = element;
     }
@@ -591,20 +588,19 @@
         map.clear();
     }
 
-    void clear(LogBufferElement *element) {
-        uint64_t current = element->getRealTime().nsec()
-                         - (EXPIRE_RATELIMIT * NS_PER_SEC);
-        for(LogBufferElementMap::iterator it = map.begin(); it != map.end();) {
-            LogBufferElement *mapElement = it->second;
-            if ((mapElement->getDropped() >= EXPIRE_THRESHOLD)
-                    && (current > mapElement->getRealTime().nsec())) {
+    void clear(LogBufferElement* element) {
+        uint64_t current =
+            element->getRealTime().nsec() - (EXPIRE_RATELIMIT * NS_PER_SEC);
+        for (LogBufferElementMap::iterator it = map.begin(); it != map.end();) {
+            LogBufferElement* mapElement = it->second;
+            if ((mapElement->getDropped() >= EXPIRE_THRESHOLD) &&
+                (current > mapElement->getRealTime().nsec())) {
                 it = map.erase(it);
             } else {
                 ++it;
             }
         }
     }
-
 };
 
 // prune "pruneRows" of type "id" from the buffer.
@@ -655,7 +651,7 @@
 // mLogElementsLock must be held when this function is called.
 //
 bool LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
-    LogTimeEntry *oldest = NULL;
+    LogTimeEntry* oldest = NULL;
     bool busy = false;
     bool clearAll = pruneRows == ULONG_MAX;
 
@@ -663,13 +659,12 @@
 
     // Region locked?
     LastLogTimes::iterator times = mTimes.begin();
-    while(times != mTimes.end()) {
-        LogTimeEntry *entry = (*times);
-        if (entry->owned_Locked() && entry->isWatching(id)
-                && (!oldest ||
-                    (oldest->mStart > entry->mStart) ||
-                    ((oldest->mStart == entry->mStart) &&
-                     (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec)))) {
+    while (times != mTimes.end()) {
+        LogTimeEntry* entry = (*times);
+        if (entry->owned_Locked() && entry->isWatching(id) &&
+            (!oldest || (oldest->mStart > entry->mStart) ||
+             ((oldest->mStart == entry->mStart) &&
+              (entry->mTimeout.tv_sec || entry->mTimeout.tv_nsec)))) {
             oldest = entry;
         }
         times++;
@@ -677,14 +672,15 @@
 
     LogBufferElementCollection::iterator it;
 
-    if (__predict_false(caller_uid != AID_ROOT)) { // unlikely
+    if (__predict_false(caller_uid != AID_ROOT)) {  // unlikely
         // Only here if clear all request from non system source, so chatty
         // filter logistics is not required.
         it = mLastSet[id] ? mLast[id] : mLogElements.begin();
         while (it != mLogElements.end()) {
-            LogBufferElement *element = *it;
+            LogBufferElement* element = *it;
 
-            if ((element->getLogId() != id) || (element->getUid() != caller_uid)) {
+            if ((element->getLogId() != id) ||
+                (element->getUid() != caller_uid)) {
                 ++it;
                 continue;
             }
@@ -717,26 +713,28 @@
     bool hasBlacklist = (id != LOG_ID_SECURITY) && mPrune.naughty();
     while (!clearAll && (pruneRows > 0)) {
         // recalculate the worst offender on every batched pass
-        int worst = -1; // not valid for getUid() or getKey()
+        int worst = -1;  // not valid for getUid() or getKey()
         size_t worst_sizes = 0;
         size_t second_worst_sizes = 0;
-        pid_t worstPid = 0; // POSIX guarantees PID != 0
+        pid_t worstPid = 0;  // POSIX guarantees PID != 0
 
         if (worstUidEnabledForLogid(id) && mPrune.worstUidEnabled()) {
             // Calculate threshold as 12.5% of available storage
             size_t threshold = log_buffer_size(id) / 8;
 
             if ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) {
-                stats.sortTags(AID_ROOT, (pid_t)0, 2, id).findWorst(
-                    worst, worst_sizes, second_worst_sizes, threshold);
+                stats.sortTags(AID_ROOT, (pid_t)0, 2, id)
+                    .findWorst(worst, worst_sizes, second_worst_sizes,
+                               threshold);
                 // per-pid filter for AID_SYSTEM sources is too complex
             } else {
-                stats.sort(AID_ROOT, (pid_t)0, 2, id).findWorst(
-                    worst, worst_sizes, second_worst_sizes, threshold);
+                stats.sort(AID_ROOT, (pid_t)0, 2, id)
+                    .findWorst(worst, worst_sizes, second_worst_sizes,
+                               threshold);
 
                 if ((worst == AID_SYSTEM) && mPrune.worstPidOfSystemEnabled()) {
-                    stats.sortPids(worst, (pid_t)0, 2, id).findWorst(
-                        worstPid, worst_sizes, second_worst_sizes);
+                    stats.sortPids(worst, (pid_t)0, 2, id)
+                        .findWorst(worstPid, worst_sizes, second_worst_sizes);
                 }
             }
         }
@@ -755,35 +753,34 @@
         // - check age-out of preserved logs
         bool gc = pruneRows <= 1;
         if (!gc && (worst != -1)) {
-            {   // begin scope for worst found iterator
-                LogBufferIteratorMap::iterator found = mLastWorst[id].find(worst);
-                if ((found != mLastWorst[id].end())
-                        && (found->second != mLogElements.end())) {
+            {  // begin scope for worst found iterator
+                LogBufferIteratorMap::iterator found =
+                    mLastWorst[id].find(worst);
+                if ((found != mLastWorst[id].end()) &&
+                    (found->second != mLogElements.end())) {
                     leading = false;
                     it = found->second;
                 }
             }
-            if (worstPid) { // begin scope for pid worst found iterator
+            if (worstPid) {  // begin scope for pid worst found iterator
                 // FYI: worstPid only set if !LOG_ID_EVENTS and
                 //      !LOG_ID_SECURITY, not going to make that assumption ...
-                LogBufferPidIteratorMap::iterator found
-                    = mLastWorstPidOfSystem[id].find(worstPid);
-                if ((found != mLastWorstPidOfSystem[id].end())
-                        && (found->second != mLogElements.end())) {
+                LogBufferPidIteratorMap::iterator found =
+                    mLastWorstPidOfSystem[id].find(worstPid);
+                if ((found != mLastWorstPidOfSystem[id].end()) &&
+                    (found->second != mLogElements.end())) {
                     leading = false;
                     it = found->second;
                 }
             }
         }
-        static const timespec too_old = {
-            EXPIRE_HOUR_THRESHOLD * 60 * 60, 0
-        };
+        static const timespec too_old = { EXPIRE_HOUR_THRESHOLD * 60 * 60, 0 };
         LogBufferElementCollection::iterator lastt;
         lastt = mLogElements.end();
         --lastt;
         LogBufferElementLast last;
         while (it != mLogElements.end()) {
-            LogBufferElement *element = *it;
+            LogBufferElement* element = *it;
 
             if (oldest && (oldest->mStart <= element->getSequence())) {
                 busy = true;
@@ -817,9 +814,9 @@
                 continue;
             }
 
-            int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY)) ?
-                    element->getTag() :
-                    element->getUid();
+            int key = ((id == LOG_ID_EVENTS) || (id == LOG_ID_SECURITY))
+                          ? element->getTag()
+                          : element->getUid();
 
             if (hasBlacklist && mPrune.naughty(element)) {
                 last.clear(element);
@@ -843,32 +840,32 @@
                 continue;
             }
 
-            if ((element->getRealTime() < ((*lastt)->getRealTime() - too_old))
-                    || (element->getRealTime() > (*lastt)->getRealTime())) {
+            if ((element->getRealTime() < ((*lastt)->getRealTime() - too_old)) ||
+                (element->getRealTime() > (*lastt)->getRealTime())) {
                 break;
             }
 
             if (dropped) {
                 last.add(element);
-                if (worstPid
-                        && ((!gc && (element->getPid() == worstPid))
-                           || (mLastWorstPidOfSystem[id].find(element->getPid())
-                                == mLastWorstPidOfSystem[id].end()))) {
+                if (worstPid &&
+                    ((!gc && (element->getPid() == worstPid)) ||
+                     (mLastWorstPidOfSystem[id].find(element->getPid()) ==
+                      mLastWorstPidOfSystem[id].end()))) {
                     // element->getUid() may not be AID_SYSTEM, next best
                     // watermark if current one empty. id is not LOG_ID_EVENTS
                     // or LOG_ID_SECURITY because of worstPid check.
                     mLastWorstPidOfSystem[id][element->getPid()] = it;
                 }
-                if ((!gc && !worstPid && (key == worst))
-                        || (mLastWorst[id].find(key) == mLastWorst[id].end())) {
+                if ((!gc && !worstPid && (key == worst)) ||
+                    (mLastWorst[id].find(key) == mLastWorst[id].end())) {
                     mLastWorst[id][key] = it;
                 }
                 ++it;
                 continue;
             }
 
-            if ((key != worst)
-                    || (worstPid && (element->getPid() != worstPid))) {
+            if ((key != worst) ||
+                (worstPid && (element->getPid() != worstPid))) {
                 leading = false;
                 last.clear(element);
                 ++it;
@@ -896,16 +893,16 @@
                     it = erase(it, true);
                 } else {
                     last.add(element);
-                    if (worstPid && (!gc
-                                || (mLastWorstPidOfSystem[id].find(worstPid)
-                                    == mLastWorstPidOfSystem[id].end()))) {
+                    if (worstPid &&
+                        (!gc || (mLastWorstPidOfSystem[id].find(worstPid) ==
+                                 mLastWorstPidOfSystem[id].end()))) {
                         // element->getUid() may not be AID_SYSTEM, next best
                         // watermark if current one empty. id is not
                         // LOG_ID_EVENTS or LOG_ID_SECURITY because of worstPid.
                         mLastWorstPidOfSystem[id][worstPid] = it;
                     }
                     if ((!gc && !worstPid) ||
-                         (mLastWorst[id].find(worst) == mLastWorst[id].end())) {
+                        (mLastWorst[id].find(worst) == mLastWorst[id].end())) {
                         mLastWorst[id][worst] = it;
                     }
                     ++it;
@@ -919,15 +916,15 @@
         last.clear();
 
         if (!kick || !mPrune.worstUidEnabled()) {
-            break; // the following loop will ask bad clients to skip/drop
+            break;  // the following loop will ask bad clients to skip/drop
         }
     }
 
     bool whitelist = false;
     bool hasWhitelist = (id != LOG_ID_SECURITY) && mPrune.nice() && !clearAll;
     it = mLastSet[id] ? mLast[id] : mLogElements.begin();
-    while((pruneRows > 0) && (it != mLogElements.end())) {
-        LogBufferElement *element = *it;
+    while ((pruneRows > 0) && (it != mLogElements.end())) {
+        LogBufferElement* element = *it;
 
         if (element->getLogId() != id) {
             it++;
@@ -970,8 +967,8 @@
     // Do not save the whitelist if we are reader range limited
     if (whitelist && (pruneRows > 0)) {
         it = mLastSet[id] ? mLast[id] : mLogElements.begin();
-        while((it != mLogElements.end()) && (pruneRows > 0)) {
-            LogBufferElement *element = *it;
+        while ((it != mLogElements.end()) && (pruneRows > 0)) {
+            LogBufferElement* element = *it;
 
             if (element->getLogId() != id) {
                 ++it;
@@ -1011,7 +1008,7 @@
     bool busy = true;
     // If it takes more than 4 tries (seconds) to clear, then kill reader(s)
     for (int retry = 4;;) {
-        if (retry == 1) { // last pass
+        if (retry == 1) {  // last pass
             // Check if it is still busy after the sleep, we say prune
             // one entry, not another clear run, so we are looking for
             // the quick side effect of the return value to tell us if
@@ -1027,7 +1024,7 @@
                 LogTimeEntry::lock();
                 LastLogTimes::iterator times = mTimes.begin();
                 while (times != mTimes.end()) {
-                    LogTimeEntry *entry = (*times);
+                    LogTimeEntry* entry = (*times);
                     // Killer punch
                     if (entry->owned_Locked() && entry->isWatching(id)) {
                         entry->release_Locked();
@@ -1043,7 +1040,7 @@
         if (!busy || !--retry) {
             break;
         }
-        sleep (1); // Let reader(s) catch up after notification
+        sleep(1);  // Let reader(s) catch up after notification
     }
     return busy;
 }
@@ -1077,9 +1074,8 @@
 }
 
 uint64_t LogBuffer::flushTo(
-        SocketClient *reader, const uint64_t start,
-        bool privileged, bool security,
-        int (*filter)(const LogBufferElement *element, void *arg), void *arg) {
+    SocketClient* reader, const uint64_t start, bool privileged, bool security,
+    int (*filter)(const LogBufferElement* element, void* arg), void* arg) {
     LogBufferElementCollection::iterator it;
     uint64_t max = start;
     uid_t uid = reader->getUid();
@@ -1092,9 +1088,10 @@
     } else {
         // Client wants to start from some specified time. Chances are
         // we are better off starting from the end of the time sorted list.
-        for (it = mLogElements.end(); it != mLogElements.begin(); /* do nothing */) {
+        for (it = mLogElements.end(); it != mLogElements.begin();
+             /* do nothing */) {
             --it;
-            LogBufferElement *element = *it;
+            LogBufferElement* element = *it;
             if (element->getSequence() <= start) {
                 it++;
                 break;
@@ -1107,7 +1104,7 @@
     pid_t lastTid[LOG_ID_MAX] = { 0 };
 
     for (; it != mLogElements.end(); ++it) {
-        LogBufferElement *element = *it;
+        LogBufferElement* element = *it;
 
         if (!privileged && (element->getUid() != uid)) {
             continue;
@@ -1138,8 +1135,8 @@
         // multiple identical squash.  chatty that differs source
         // is due to spam filter.  chatty to chatty of different
         // source is also due to spam filter.
-        lastTid[element->getLogId()] = (element->getDropped() && !sameTid) ?
-                0 : element->getTid();
+        lastTid[element->getLogId()] =
+            (element->getDropped() && !sameTid) ? 0 : element->getTid();
 
         pthread_mutex_unlock(&mLogElementsLock);
 
diff --git a/logd/LogBuffer.h b/logd/LogBuffer.h
index 9feef32..92b0297 100644
--- a/logd/LogBuffer.h
+++ b/logd/LogBuffer.h
@@ -27,9 +27,9 @@
 #include <sysutils/SocketClient.h>
 
 #include "LogBufferElement.h"
+#include "LogStatistics.h"
 #include "LogTags.h"
 #include "LogTimes.h"
-#include "LogStatistics.h"
 #include "LogWhiteBlackList.h"
 
 //
@@ -41,7 +41,7 @@
 //
 namespace android {
 
-static bool isMonotonic(const log_time &mono) {
+static bool isMonotonic(const log_time& mono) {
     static const uint32_t EPOCH_PLUS_2_YEARS = 2 * 24 * 60 * 60 * 1461 / 4;
     static const uint32_t EPOCH_PLUS_MINUTE = 60;
 
@@ -70,10 +70,9 @@
     /* dividing line half way between monotonic and realtime */
     return mono.tv_sec < ((cpu.tv_sec + now.tv_sec) / 2);
 }
-
 }
 
-typedef std::list<LogBufferElement *> LogBufferElementCollection;
+typedef std::list<LogBufferElement*> LogBufferElementCollection;
 
 class LogBuffer {
     LogBufferElementCollection mLogElements;
@@ -86,14 +85,12 @@
     LogBufferElementCollection::iterator mLast[LOG_ID_MAX];
     bool mLastSet[LOG_ID_MAX];
     // watermark of any worst/chatty uid processing
-    typedef std::unordered_map<uid_t,
-                               LogBufferElementCollection::iterator>
-                LogBufferIteratorMap;
+    typedef std::unordered_map<uid_t, LogBufferElementCollection::iterator>
+        LogBufferIteratorMap;
     LogBufferIteratorMap mLastWorst[LOG_ID_MAX];
     // watermark of any worst/chatty pid of system processing
-    typedef std::unordered_map<pid_t,
-                               LogBufferElementCollection::iterator>
-                LogBufferPidIteratorMap;
+    typedef std::unordered_map<pid_t, LogBufferElementCollection::iterator>
+        LogBufferPidIteratorMap;
     LogBufferPidIteratorMap mLastWorstPidOfSystem[LOG_ID_MAX];
 
     unsigned long mMaxSize[LOG_ID_MAX];
@@ -106,21 +103,23 @@
     LogBufferElement* droppedElements[LOG_ID_MAX];
     void log(LogBufferElement* elem);
 
-public:
-    LastLogTimes &mTimes;
+   public:
+    LastLogTimes& mTimes;
 
-    explicit LogBuffer(LastLogTimes *times);
+    explicit LogBuffer(LastLogTimes* times);
     ~LogBuffer();
     void init();
-    bool isMonotonic() { return monotonic; }
+    bool isMonotonic() {
+        return monotonic;
+    }
 
-    int log(log_id_t log_id, log_time realtime,
-            uid_t uid, pid_t pid, pid_t tid,
-            const char *msg, unsigned short len);
-    uint64_t flushTo(SocketClient *writer, const uint64_t start,
+    int log(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid, pid_t tid,
+            const char* msg, unsigned short len);
+    uint64_t flushTo(SocketClient* writer, const uint64_t start,
                      bool privileged, bool security,
-                     int (*filter)(const LogBufferElement *element, void *arg) = NULL,
-                     void *arg = NULL);
+                     int (*filter)(const LogBufferElement* element,
+                                   void* arg) = NULL,
+                     void* arg = NULL);
 
     bool clear(log_id_t id, uid_t uid = AID_ROOT);
     unsigned long getSize(log_id_t id);
@@ -133,27 +132,42 @@
         stats.enableStatistics();
     }
 
-    int initPrune(const char *cp) { return mPrune.init(cp); }
-    std::string formatPrune() { return mPrune.format(); }
+    int initPrune(const char* cp) {
+        return mPrune.init(cp);
+    }
+    std::string formatPrune() {
+        return mPrune.format();
+    }
 
-    std::string formatGetEventTag(uid_t uid,
-                                  const char *name, const char *format) {
+    std::string formatGetEventTag(uid_t uid, const char* name,
+                                  const char* format) {
         return tags.formatGetEventTag(uid, name, format);
     }
     std::string formatEntry(uint32_t tag, uid_t uid) {
         return tags.formatEntry(tag, uid);
     }
-    const char *tagToName(uint32_t tag) { return tags.tagToName(tag); }
+    const char* tagToName(uint32_t tag) {
+        return tags.tagToName(tag);
+    }
 
     // helper must be protected directly or implicitly by lock()/unlock()
-    const char *pidToName(pid_t pid) { return stats.pidToName(pid); }
-    uid_t pidToUid(pid_t pid) { return stats.pidToUid(pid); }
-    const char *uidToName(uid_t uid) { return stats.uidToName(uid); }
-    void lock() { pthread_mutex_lock(&mLogElementsLock); }
-    void unlock() { pthread_mutex_unlock(&mLogElementsLock); }
+    const char* pidToName(pid_t pid) {
+        return stats.pidToName(pid);
+    }
+    uid_t pidToUid(pid_t pid) {
+        return stats.pidToUid(pid);
+    }
+    const char* uidToName(uid_t uid) {
+        return stats.uidToName(uid);
+    }
+    void lock() {
+        pthread_mutex_lock(&mLogElementsLock);
+    }
+    void unlock() {
+        pthread_mutex_unlock(&mLogElementsLock);
+    }
 
-private:
-
+   private:
     static constexpr size_t minPrune = 4;
     static constexpr size_t maxPrune = 256;
 
@@ -163,4 +177,4 @@
         LogBufferElementCollection::iterator it, bool coalesce = false);
 };
 
-#endif // _LOGD_LOG_BUFFER_H__
+#endif  // _LOGD_LOG_BUFFER_H__
diff --git a/logd/LogBufferElement.cpp b/logd/LogBufferElement.cpp
index a651fd4..5ba3a15 100644
--- a/logd/LogBufferElement.cpp
+++ b/logd/LogBufferElement.cpp
@@ -35,41 +35,41 @@
 
 LogBufferElement::LogBufferElement(log_id_t log_id, log_time realtime,
                                    uid_t uid, pid_t pid, pid_t tid,
-                                   const char *msg, unsigned short len) :
-        mUid(uid),
-        mPid(pid),
-        mTid(tid),
-        mSequence(sequence.fetch_add(1, memory_order_relaxed)),
-        mRealTime(realtime),
-        mMsgLen(len),
-        mLogId(log_id) {
+                                   const char* msg, unsigned short len)
+    : mUid(uid),
+      mPid(pid),
+      mTid(tid),
+      mSequence(sequence.fetch_add(1, memory_order_relaxed)),
+      mRealTime(realtime),
+      mMsgLen(len),
+      mLogId(log_id) {
     mMsg = new char[len];
     memcpy(mMsg, msg, len);
-    mTag = (isBinary() && (mMsgLen >= sizeof(uint32_t))) ?
-        le32toh(reinterpret_cast<android_event_header_t *>(mMsg)->tag) :
-        0;
+    mTag = (isBinary() && (mMsgLen >= sizeof(uint32_t)))
+               ? le32toh(reinterpret_cast<android_event_header_t*>(mMsg)->tag)
+               : 0;
 }
 
-LogBufferElement::LogBufferElement(const LogBufferElement &elem) :
-        mTag(elem.mTag),
-        mUid(elem.mUid),
-        mPid(elem.mPid),
-        mTid(elem.mTid),
-        mSequence(elem.mSequence),
-        mRealTime(elem.mRealTime),
-        mMsgLen(elem.mMsgLen),
-        mLogId(elem.mLogId) {
+LogBufferElement::LogBufferElement(const LogBufferElement& elem)
+    : mTag(elem.mTag),
+      mUid(elem.mUid),
+      mPid(elem.mPid),
+      mTid(elem.mTid),
+      mSequence(elem.mSequence),
+      mRealTime(elem.mRealTime),
+      mMsgLen(elem.mMsgLen),
+      mLogId(elem.mLogId) {
     mMsg = new char[mMsgLen];
     memcpy(mMsg, elem.mMsg, mMsgLen);
 }
 
 LogBufferElement::~LogBufferElement() {
-    delete [] mMsg;
+    delete[] mMsg;
 }
 
 // caller must own and free character string
-char *android::tidToName(pid_t tid) {
-    char *retval = NULL;
+char* android::tidToName(pid_t tid) {
+    char* retval = NULL;
     char buffer[256];
     snprintf(buffer, sizeof(buffer), "/proc/%u/comm", tid);
     int fd = open(buffer, O_RDONLY);
@@ -89,7 +89,7 @@
     }
 
     // if nothing for comm, check out cmdline
-    char *name = android::pidToName(tid);
+    char* name = android::pidToName(tid);
     if (!retval) {
         retval = name;
         name = NULL;
@@ -101,8 +101,8 @@
         size_t retval_len = strlen(retval);
         size_t name_len = strlen(name);
         // KISS: ToDo: Only checks prefix truncated, not suffix, or both
-        if ((retval_len < name_len)
-                && !fastcmp<strcmp>(retval, name + name_len - retval_len)) {
+        if ((retval_len < name_len) &&
+            !fastcmp<strcmp>(retval, name + name_len - retval_len)) {
             free(retval);
             retval = name;
         } else {
@@ -113,21 +113,20 @@
 }
 
 // assumption: mMsg == NULL
-size_t LogBufferElement::populateDroppedMessage(char*& buffer,
-        LogBuffer* parent, bool lastSame) {
+size_t LogBufferElement::populateDroppedMessage(char*& buffer, LogBuffer* parent,
+                                                bool lastSame) {
     static const char tag[] = "chatty";
 
-    if (!__android_log_is_loggable_len(ANDROID_LOG_INFO,
-                                       tag, strlen(tag),
+    if (!__android_log_is_loggable_len(ANDROID_LOG_INFO, tag, strlen(tag),
                                        ANDROID_LOG_VERBOSE)) {
         return 0;
     }
 
     static const char format_uid[] = "uid=%u%s%s %s %u line%s";
     parent->lock();
-    const char *name = parent->uidToName(mUid);
+    const char* name = parent->uidToName(mUid);
     parent->unlock();
-    const char *commName = android::tidToName(mTid);
+    const char* commName = android::tidToName(mTid);
     if (!commName && (mTid != mPid)) {
         commName = android::tidToName(mPid);
     }
@@ -140,35 +139,35 @@
         size_t len = strlen(name + 1);
         if (!strncmp(name + 1, commName + 1, len)) {
             if (commName[len + 1] == '\0') {
-                free(const_cast<char *>(commName));
+                free(const_cast<char*>(commName));
                 commName = NULL;
             } else {
-                free(const_cast<char *>(name));
+                free(const_cast<char*>(name));
                 name = NULL;
             }
         }
     }
     if (name) {
-        char *buf = NULL;
+        char* buf = NULL;
         asprintf(&buf, "(%s)", name);
         if (buf) {
-            free(const_cast<char *>(name));
+            free(const_cast<char*>(name));
             name = buf;
         }
     }
     if (commName) {
-        char *buf = NULL;
+        char* buf = NULL;
         asprintf(&buf, " %s", commName);
         if (buf) {
-            free(const_cast<char *>(commName));
+            free(const_cast<char*>(commName));
             commName = buf;
         }
     }
     // identical to below to calculate the buffer size required
     const char* type = lastSame ? "identical" : "expire";
     size_t len = snprintf(NULL, 0, format_uid, mUid, name ? name : "",
-                          commName ? commName : "", type,
-                          mDropped, (mDropped > 1) ? "s" : "");
+                          commName ? commName : "", type, mDropped,
+                          (mDropped > 1) ? "s" : "");
 
     size_t hdrLen;
     if (isBinary()) {
@@ -177,17 +176,17 @@
         hdrLen = 1 + sizeof(tag);
     }
 
-    buffer = static_cast<char *>(calloc(1, hdrLen + len + 1));
+    buffer = static_cast<char*>(calloc(1, hdrLen + len + 1));
     if (!buffer) {
-        free(const_cast<char *>(name));
-        free(const_cast<char *>(commName));
+        free(const_cast<char*>(name));
+        free(const_cast<char*>(commName));
         return 0;
     }
 
     size_t retval = hdrLen + len;
     if (isBinary()) {
-        android_log_event_string_t *event =
-            reinterpret_cast<android_log_event_string_t *>(buffer);
+        android_log_event_string_t* event =
+            reinterpret_cast<android_log_event_string_t*>(buffer);
 
         event->header.tag = htole32(CHATTY_LOG_TAG);
         event->type = EVENT_TYPE_STRING;
@@ -199,10 +198,10 @@
     }
 
     snprintf(buffer + hdrLen, len + 1, format_uid, mUid, name ? name : "",
-             commName ? commName : "", type,
-             mDropped, (mDropped > 1) ? "s" : "");
-    free(const_cast<char *>(name));
-    free(const_cast<char *>(commName));
+             commName ? commName : "", type, mDropped,
+             (mDropped > 1) ? "s" : "");
+    free(const_cast<char*>(name));
+    free(const_cast<char*>(commName));
 
     return retval;
 }
@@ -213,9 +212,8 @@
 
     memset(&entry, 0, sizeof(struct logger_entry_v4));
 
-    entry.hdr_size = privileged ?
-                         sizeof(struct logger_entry_v4) :
-                         sizeof(struct logger_entry_v3);
+    entry.hdr_size = privileged ? sizeof(struct logger_entry_v4)
+                                : sizeof(struct logger_entry_v3);
     entry.lid = mLogId;
     entry.pid = mPid;
     entry.tid = mTid;
@@ -227,13 +225,11 @@
     iovec[0].iov_base = &entry;
     iovec[0].iov_len = entry.hdr_size;
 
-    char *buffer = NULL;
+    char* buffer = NULL;
 
     if (!mMsg) {
         entry.len = populateDroppedMessage(buffer, parent, lastSame);
-        if (!entry.len) {
-            return mSequence;
-        }
+        if (!entry.len) return mSequence;
         iovec[1].iov_base = buffer;
     } else {
         entry.len = mMsgLen;
@@ -243,9 +239,7 @@
 
     uint64_t retval = reader->sendDatav(iovec, 2) ? FLUSH_ERROR : mSequence;
 
-    if (buffer) {
-        free(buffer);
-    }
+    if (buffer) free(buffer);
 
     return retval;
 }
diff --git a/logd/LogBufferElement.h b/logd/LogBufferElement.h
index bd98b9c..43990e8 100644
--- a/logd/LogBufferElement.h
+++ b/logd/LogBufferElement.h
@@ -26,69 +26,89 @@
 
 class LogBuffer;
 
-#define EXPIRE_HOUR_THRESHOLD 24 // Only expire chatty UID logs to preserve
-                                 // non-chatty UIDs less than this age in hours
-#define EXPIRE_THRESHOLD 10      // A smaller expire count is considered too
-                                 // chatty for the temporal expire messages
-#define EXPIRE_RATELIMIT 10      // maximum rate in seconds to report expiration
+#define EXPIRE_HOUR_THRESHOLD 24  // Only expire chatty UID logs to preserve
+                                  // non-chatty UIDs less than this age in hours
+#define EXPIRE_THRESHOLD 10       // A smaller expire count is considered too
+                                  // chatty for the temporal expire messages
+#define EXPIRE_RATELIMIT 10  // maximum rate in seconds to report expiration
 
 class LogBufferElement {
-
     friend LogBuffer;
 
     // sized to match reality of incoming log packets
-    uint32_t mTag; // only valid for isBinary()
+    uint32_t mTag;  // only valid for isBinary()
     const uint32_t mUid;
     const uint32_t mPid;
     const uint32_t mTid;
     const uint64_t mSequence;
     log_time mRealTime;
-    char *mMsg;
+    char* mMsg;
     union {
-        const uint16_t mMsgLen; // mMSg != NULL
-        uint16_t mDropped;      // mMsg == NULL
+        const uint16_t mMsgLen;  // mMSg != NULL
+        uint16_t mDropped;       // mMsg == NULL
     };
     const uint8_t mLogId;
 
     static atomic_int_fast64_t sequence;
 
     // assumption: mMsg == NULL
-    size_t populateDroppedMessage(char*& buffer,
-                                  LogBuffer* parent,
+    size_t populateDroppedMessage(char*& buffer, LogBuffer* parent,
                                   bool lastSame);
-public:
-    LogBufferElement(log_id_t log_id, log_time realtime,
-                     uid_t uid, pid_t pid, pid_t tid,
-                     const char *msg, unsigned short len);
-    LogBufferElement(const LogBufferElement &elem);
+
+   public:
+    LogBufferElement(log_id_t log_id, log_time realtime, uid_t uid, pid_t pid,
+                     pid_t tid, const char* msg, unsigned short len);
+    LogBufferElement(const LogBufferElement& elem);
     virtual ~LogBufferElement();
 
     bool isBinary(void) const {
         return (mLogId == LOG_ID_EVENTS) || (mLogId == LOG_ID_SECURITY);
     }
 
-    log_id_t getLogId() const { return static_cast<log_id_t>(mLogId); }
-    uid_t getUid(void) const { return mUid; }
-    pid_t getPid(void) const { return mPid; }
-    pid_t getTid(void) const { return mTid; }
-    uint32_t getTag() const { return mTag; }
-    unsigned short getDropped(void) const { return mMsg ? 0 : mDropped; }
+    log_id_t getLogId() const {
+        return static_cast<log_id_t>(mLogId);
+    }
+    uid_t getUid(void) const {
+        return mUid;
+    }
+    pid_t getPid(void) const {
+        return mPid;
+    }
+    pid_t getTid(void) const {
+        return mTid;
+    }
+    uint32_t getTag() const {
+        return mTag;
+    }
+    unsigned short getDropped(void) const {
+        return mMsg ? 0 : mDropped;
+    }
     unsigned short setDropped(unsigned short value) {
         if (mMsg) {
-            delete [] mMsg;
+            delete[] mMsg;
             mMsg = NULL;
         }
         return mDropped = value;
     }
-    unsigned short getMsgLen() const { return mMsg ? mMsgLen : 0; }
-    const char* getMsg() const { return mMsg; }
-    uint64_t getSequence(void) const { return mSequence; }
-    static uint64_t getCurrentSequence(void) { return sequence.load(memory_order_relaxed); }
-    log_time getRealTime(void) const { return mRealTime; }
+    unsigned short getMsgLen() const {
+        return mMsg ? mMsgLen : 0;
+    }
+    const char* getMsg() const {
+        return mMsg;
+    }
+    uint64_t getSequence(void) const {
+        return mSequence;
+    }
+    static uint64_t getCurrentSequence(void) {
+        return sequence.load(memory_order_relaxed);
+    }
+    log_time getRealTime(void) const {
+        return mRealTime;
+    }
 
     static const uint64_t FLUSH_ERROR;
-    uint64_t flushTo(SocketClient* writer, LogBuffer* parent,
-                     bool privileged, bool lastSame);
+    uint64_t flushTo(SocketClient* writer, LogBuffer* parent, bool privileged,
+                     bool lastSame);
 };
 
 #endif
diff --git a/logd/LogCommand.cpp b/logd/LogCommand.cpp
index 3b17576..6d7c0a5 100644
--- a/logd/LogCommand.cpp
+++ b/logd/LogCommand.cpp
@@ -24,7 +24,7 @@
 #include "LogCommand.h"
 #include "LogUtils.h"
 
-LogCommand::LogCommand(const char *cmd) : FrameworkCommand(cmd) {
+LogCommand::LogCommand(const char* cmd) : FrameworkCommand(cmd) {
 }
 
 // gets a list of supplementary group IDs associated with
@@ -40,8 +40,8 @@
 // has open permissions, and one that has restricted
 // permissions.
 
-static bool groupIsLog(char *buf) {
-    char *ptr;
+static bool groupIsLog(char* buf) {
+    char* ptr;
     static const char ws[] = " \n";
 
     for (buf = strtok_r(buf, ws, &ptr); buf; buf = strtok_r(NULL, ws, &ptr)) {
@@ -91,15 +91,14 @@
     // doubt, but we expect the falses  should be reduced significantly as
     // three times is a charm.
     //
-    for (int retry = 3;
-            !(ret = foundGid && foundUid && foundLog) && retry;
-            --retry) {
-        FILE *file = fopen(filename, "r");
+    for (int retry = 3; !(ret = foundGid && foundUid && foundLog) && retry;
+         --retry) {
+        FILE* file = fopen(filename, "r");
         if (!file) {
             continue;
         }
 
-        char *line = NULL;
+        char* line = NULL;
         size_t len = 0;
         while (getline(&line, &len, file) > 0) {
             static const char groups_string[] = "Groups:\t";
@@ -111,29 +110,25 @@
                     foundLog = true;
                 }
             } else if (strncmp(uid_string, line, sizeof(uid_string) - 1) == 0) {
-                uid_t u[4] = { (uid_t) -1, (uid_t) -1, (uid_t) -1, (uid_t) -1};
+                uid_t u[4] = { (uid_t)-1, (uid_t)-1, (uid_t)-1, (uid_t)-1 };
 
-                sscanf(line + sizeof(uid_string) - 1, "%u\t%u\t%u\t%u",
-                       &u[0], &u[1], &u[2], &u[3]);
+                sscanf(line + sizeof(uid_string) - 1, "%u\t%u\t%u\t%u", &u[0],
+                       &u[1], &u[2], &u[3]);
 
                 // Protect against PID reuse by checking that UID is the same
-                if ((uid == u[0])
-                        && (uid == u[1])
-                        && (uid == u[2])
-                        && (uid == u[3])) {
+                if ((uid == u[0]) && (uid == u[1]) && (uid == u[2]) &&
+                    (uid == u[3])) {
                     foundUid = true;
                 }
             } else if (strncmp(gid_string, line, sizeof(gid_string) - 1) == 0) {
-                gid_t g[4] = { (gid_t) -1, (gid_t) -1, (gid_t) -1, (gid_t) -1};
+                gid_t g[4] = { (gid_t)-1, (gid_t)-1, (gid_t)-1, (gid_t)-1 };
 
-                sscanf(line + sizeof(gid_string) - 1, "%u\t%u\t%u\t%u",
-                       &g[0], &g[1], &g[2], &g[3]);
+                sscanf(line + sizeof(gid_string) - 1, "%u\t%u\t%u\t%u", &g[0],
+                       &g[1], &g[2], &g[3]);
 
                 // Protect against PID reuse by checking that GID is the same
-                if ((gid == g[0])
-                        && (gid == g[1])
-                        && (gid == g[2])
-                        && (gid == g[3])) {
+                if ((gid == g[0]) && (gid == g[1]) && (gid == g[2]) &&
+                    (gid == g[3])) {
                     foundGid = true;
                 }
             }
@@ -145,6 +140,6 @@
     return ret;
 }
 
-bool clientHasLogCredentials(SocketClient *cli) {
+bool clientHasLogCredentials(SocketClient* cli) {
     return clientHasLogCredentials(cli->getUid(), cli->getGid(), cli->getPid());
 }
diff --git a/logd/LogCommand.h b/logd/LogCommand.h
index 0adc2a1..e10ffa0 100644
--- a/logd/LogCommand.h
+++ b/logd/LogCommand.h
@@ -17,13 +17,14 @@
 #ifndef _LOGD_COMMAND_H
 #define _LOGD_COMMAND_H
 
-#include <sysutils/SocketClient.h>
 #include <sysutils/FrameworkCommand.h>
+#include <sysutils/SocketClient.h>
 
 class LogCommand : public FrameworkCommand {
-public:
-    explicit LogCommand(const char *cmd);
-    virtual ~LogCommand() {}
+   public:
+    explicit LogCommand(const char* cmd);
+    virtual ~LogCommand() {
+    }
 };
 
 #endif
diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp
index f224079..9ae95f9 100644
--- a/logd/LogKlog.cpp
+++ b/logd/LogKlog.cpp
@@ -25,25 +25,22 @@
 #include <sys/uio.h>
 #include <syslog.h>
 
-#include <private/android_logger.h>
 #include <private/android_filesystem_config.h>
+#include <private/android_logger.h>
 
 #include "LogBuffer.h"
 #include "LogKlog.h"
 #include "LogReader.h"
 
-#define KMSG_PRIORITY(PRI)           \
-    '<',                             \
-    '0' + (LOG_SYSLOG | (PRI)) / 10, \
-    '0' + (LOG_SYSLOG | (PRI)) % 10, \
-    '>'
+#define KMSG_PRIORITY(PRI) \
+    '<', '0' + (LOG_SYSLOG | (PRI)) / 10, '0' + (LOG_SYSLOG | (PRI)) % 10, '>'
 
 static const char priority_message[] = { KMSG_PRIORITY(LOG_INFO), '\0' };
 
 // Parsing is hard
 
 // called if we see a '<', s is the next character, returns pointer after '>'
-static char *is_prio(char *s, size_t len) {
+static char* is_prio(char* s, size_t len) {
     if (!len || !isdigit(*s++)) {
         return NULL;
     }
@@ -60,7 +57,7 @@
 }
 
 // called if we see a '[', s is the next character, returns pointer after ']'
-static char *is_timestamp(char *s, size_t len) {
+static char* is_timestamp(char* s, size_t len) {
     while (len && (*s == ' ')) {
         ++s;
         --len;
@@ -83,19 +80,20 @@
 }
 
 // Like strtok_r with "\r\n" except that we look for log signatures (regex)
-//  \(\(<[0-9]\{1,4\}>\)\([[] *[0-9]+[.][0-9]+[]] \)\{0,1\}\|[[] *[0-9]+[.][0-9]+[]] \)
+//  \(\(<[0-9]\{1,4\}>\)\([[] *[0-9]+[.][0-9]+[]] \)\{0,1\}\|[[]
+//  *[0-9]+[.][0-9]+[]] \)
 // and split if we see a second one without a newline.
 // We allow nuls in content, monitoring the overall length and sub-length of
 // the discovered tokens.
 
-#define SIGNATURE_MASK     0xF0
+#define SIGNATURE_MASK 0xF0
 // <digit> following ('0' to '9' masked with ~SIGNATURE_MASK) added to signature
-#define LESS_THAN_SIG      SIGNATURE_MASK
-#define OPEN_BRACKET_SIG   ((SIGNATURE_MASK << 1) & SIGNATURE_MASK)
+#define LESS_THAN_SIG SIGNATURE_MASK
+#define OPEN_BRACKET_SIG ((SIGNATURE_MASK << 1) & SIGNATURE_MASK)
 // space is one more than <digit> of 9
 #define OPEN_BRACKET_SPACE ((char)(OPEN_BRACKET_SIG | 10))
 
-char *log_strntok_r(char *s, size_t *len, char **last, size_t *sublen) {
+char* log_strntok_r(char* s, size_t* len, char** last, size_t* sublen) {
     *sublen = 0;
     if (!*len) {
         return NULL;
@@ -144,32 +142,24 @@
         --*len;
         size_t adjust;
         switch (c) {
-        case '\r':
-        case '\n':
-            s[-1] = '\0';
-            *last = s;
-            return tok;
-
-        case '<':
-            peek = is_prio(s, *len);
-            if (!peek) {
-                break;
-            }
-            if (s != (tok + 1)) { // not first?
+            case '\r':
+            case '\n':
                 s[-1] = '\0';
-                *s &= ~SIGNATURE_MASK;
-                *s |= LESS_THAN_SIG; // signature for '<'
                 *last = s;
                 return tok;
-            }
-            adjust = peek - s;
-            if (adjust > *len) {
-                adjust = *len;
-            }
-            *sublen += adjust;
-            *len -= adjust;
-            s = peek;
-            if ((*s == '[') && ((peek = is_timestamp(s + 1, *len - 1)))) {
+
+            case '<':
+                peek = is_prio(s, *len);
+                if (!peek) {
+                    break;
+                }
+                if (s != (tok + 1)) {  // not first?
+                    s[-1] = '\0';
+                    *s &= ~SIGNATURE_MASK;
+                    *s |= LESS_THAN_SIG;  // signature for '<'
+                    *last = s;
+                    return tok;
+                }
                 adjust = peek - s;
                 if (adjust > *len) {
                     adjust = *len;
@@ -177,33 +167,41 @@
                 *sublen += adjust;
                 *len -= adjust;
                 s = peek;
-            }
-            break;
-
-        case '[':
-            peek = is_timestamp(s, *len);
-            if (!peek) {
-                break;
-            }
-            if (s != (tok + 1)) { // not first?
-                s[-1] = '\0';
-                if (*s == ' ') {
-                    *s = OPEN_BRACKET_SPACE;
-                } else {
-                    *s &= ~SIGNATURE_MASK;
-                    *s |= OPEN_BRACKET_SIG; // signature for '['
+                if ((*s == '[') && ((peek = is_timestamp(s + 1, *len - 1)))) {
+                    adjust = peek - s;
+                    if (adjust > *len) {
+                        adjust = *len;
+                    }
+                    *sublen += adjust;
+                    *len -= adjust;
+                    s = peek;
                 }
-                *last = s;
-                return tok;
-            }
-            adjust = peek - s;
-            if (adjust > *len) {
-                adjust = *len;
-            }
-            *sublen += adjust;
-            *len -= adjust;
-            s = peek;
-            break;
+                break;
+
+            case '[':
+                peek = is_timestamp(s, *len);
+                if (!peek) {
+                    break;
+                }
+                if (s != (tok + 1)) {  // not first?
+                    s[-1] = '\0';
+                    if (*s == ' ') {
+                        *s = OPEN_BRACKET_SPACE;
+                    } else {
+                        *s &= ~SIGNATURE_MASK;
+                        *s |= OPEN_BRACKET_SIG;  // signature for '['
+                    }
+                    *last = s;
+                    return tok;
+                }
+                adjust = peek - s;
+                if (adjust > *len) {
+                    adjust = *len;
+                }
+                *sublen += adjust;
+                *len -= adjust;
+                s = peek;
+                break;
         }
         ++*sublen;
     }
@@ -215,22 +213,23 @@
         ? log_time::EPOCH
         : (log_time(CLOCK_REALTIME) - log_time(CLOCK_MONOTONIC));
 
-LogKlog::LogKlog(LogBuffer *buf, LogReader *reader, int fdWrite, int fdRead, bool auditd) :
-        SocketListener(fdRead, false),
-        logbuf(buf),
-        reader(reader),
-        signature(CLOCK_MONOTONIC),
-        initialized(false),
-        enableLogging(true),
-        auditd(auditd) {
+LogKlog::LogKlog(LogBuffer* buf, LogReader* reader, int fdWrite, int fdRead,
+                 bool auditd)
+    : SocketListener(fdRead, false),
+      logbuf(buf),
+      reader(reader),
+      signature(CLOCK_MONOTONIC),
+      initialized(false),
+      enableLogging(true),
+      auditd(auditd) {
     static const char klogd_message[] = "%slogd.klogd: %" PRIu64 "\n";
     char buffer[sizeof(priority_message) + sizeof(klogd_message) + 20 - 4];
     snprintf(buffer, sizeof(buffer), klogd_message, priority_message,
-        signature.nsec());
+             signature.nsec());
     write(fdWrite, buffer, strlen(buffer));
 }
 
-bool LogKlog::onDataAvailable(SocketClient *cli) {
+bool LogKlog::onDataAvailable(SocketClient* cli) {
     if (!initialized) {
         prctl(PR_SET_NAME, "logd.klogd");
         initialized = true;
@@ -240,10 +239,11 @@
     char buffer[LOGGER_ENTRY_MAX_PAYLOAD];
     size_t len = 0;
 
-    for(;;) {
+    for (;;) {
         ssize_t retval = 0;
         if ((sizeof(buffer) - 1 - len) > 0) {
-            retval = read(cli->getSocket(), buffer + len, sizeof(buffer) - 1 - len);
+            retval =
+                read(cli->getSocket(), buffer + len, sizeof(buffer) - 1 - len);
         }
         if ((retval == 0) && (len == 0)) {
             break;
@@ -253,12 +253,11 @@
         }
         len += retval;
         bool full = len == (sizeof(buffer) - 1);
-        char *ep = buffer + len;
+        char* ep = buffer + len;
         *ep = '\0';
         size_t sublen;
-        for(char *ptr = NULL, *tok = buffer;
-                ((tok = log_strntok_r(tok, &len, &ptr, &sublen)));
-                tok = NULL) {
+        for (char *ptr = NULL, *tok = buffer;
+             ((tok = log_strntok_r(tok, &len, &ptr, &sublen))); tok = NULL) {
             if (((tok + sublen) >= ep) && (retval != 0) && full) {
                 memmove(buffer, tok, sublen);
                 len = sublen;
@@ -273,12 +272,10 @@
     return true;
 }
 
-
-void LogKlog::calculateCorrection(const log_time &monotonic,
-                                  const char *real_string,
-                                  size_t len) {
+void LogKlog::calculateCorrection(const log_time& monotonic,
+                                  const char* real_string, size_t len) {
     log_time real;
-    const char *ep = real.strptime(real_string, "%Y-%m-%d %H:%M:%S.%09q UTC");
+    const char* ep = real.strptime(real_string, "%Y-%m-%d %H:%M:%S.%09q UTC");
     if (!ep || (ep > &real_string[len]) || (real > log_time(CLOCK_REALTIME))) {
         return;
     }
@@ -323,10 +320,9 @@
     return s;
 }
 
-void LogKlog::sniffTime(log_time &now,
-                        const char **buf, size_t len,
+void LogKlog::sniffTime(log_time& now, const char** buf, size_t len,
                         bool reverse) {
-    const char *cp = now.strptime(*buf, "[ %s.%q]");
+    const char* cp = now.strptime(*buf, "[ %s.%q]");
     if (cp && (cp >= &(*buf)[len])) {
         cp = NULL;
     }
@@ -346,28 +342,28 @@
         }
 
         const char* b;
-        if (((b = android::strnstr(cp, len, suspendStr)))
-                && ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
+        if (((b = android::strnstr(cp, len, suspendStr))) &&
+            ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
             len -= b - cp;
             calculateCorrection(now, b, len);
-        } else if (((b = android::strnstr(cp, len, resumeStr)))
-                && ((size_t)((b += sizeof(resumeStr) - 1) - cp) < len)) {
+        } else if (((b = android::strnstr(cp, len, resumeStr))) &&
+                   ((size_t)((b += sizeof(resumeStr) - 1) - cp) < len)) {
             len -= b - cp;
             calculateCorrection(now, b, len);
-        } else if (((b = android::strnstr(cp, len, healthd)))
-                && ((size_t)((b += sizeof(healthd) - 1) - cp) < len)
-                && ((b = android::strnstr(b, len -= b - cp, battery)))
-                && ((size_t)((b += sizeof(battery) - 1) - cp) < len)) {
+        } else if (((b = android::strnstr(cp, len, healthd))) &&
+                   ((size_t)((b += sizeof(healthd) - 1) - cp) < len) &&
+                   ((b = android::strnstr(b, len -= b - cp, battery))) &&
+                   ((size_t)((b += sizeof(battery) - 1) - cp) < len)) {
             // NB: healthd is roughly 150us late, so we use it instead to
             //     trigger a check for ntp-induced or hardware clock drift.
             log_time real(CLOCK_REALTIME);
             log_time mono(CLOCK_MONOTONIC);
             correction = (real < mono) ? log_time::EPOCH : (real - mono);
-        } else if (((b = android::strnstr(cp, len, suspendedStr)))
-                && ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
+        } else if (((b = android::strnstr(cp, len, suspendedStr))) &&
+                   ((size_t)((b += sizeof(suspendStr) - 1) - cp) < len)) {
             len -= b - cp;
             log_time real;
-            char *endp;
+            char* endp;
             real.tv_sec = strtol(b, &endp, 10);
             if ((*endp == '.') && ((size_t)(endp - b) < len)) {
                 unsigned long multiplier = NS_PER_SEC;
@@ -398,14 +394,11 @@
     }
 }
 
-pid_t LogKlog::sniffPid(const char **buf, size_t len) {
-    const char *cp = *buf;
+pid_t LogKlog::sniffPid(const char** buf, size_t len) {
+    const char* cp = *buf;
     // HTC kernels with modified printk "c0   1648 "
-    if ((len > 9) &&
-            (cp[0] == 'c') &&
-            isdigit(cp[1]) &&
-            (isdigit(cp[2]) || (cp[2] == ' ')) &&
-            (cp[3] == ' ')) {
+    if ((len > 9) && (cp[0] == 'c') && isdigit(cp[1]) &&
+        (isdigit(cp[2]) || (cp[2] == ' ')) && (cp[3] == ' ')) {
         bool gotDigit = false;
         int i;
         for (i = 4; i < 9; ++i) {
@@ -419,7 +412,7 @@
             int pid = 0;
             char dummy;
             if (sscanf(cp + 4, "%d%c", &pid, &dummy) == 2) {
-                *buf = cp + 10; // skip-it-all
+                *buf = cp + 10;  // skip-it-all
                 return pid;
             }
         }
@@ -432,7 +425,7 @@
             if (sscanf(cp, "[%d:%*[a-z_./0-9:A-Z]]%c", &pid, &dummy) == 2) {
                 return pid;
             }
-            break; // Only the first one
+            break;  // Only the first one
         }
         ++cp;
         --len;
@@ -441,12 +434,12 @@
 }
 
 // kernel log prefix, convert to a kernel log priority number
-static int parseKernelPrio(const char **buf, size_t len) {
+static int parseKernelPrio(const char** buf, size_t len) {
     int pri = LOG_USER | LOG_INFO;
-    const char *cp = *buf;
+    const char* cp = *buf;
     if (len && (*cp == '<')) {
         pri = 0;
-        while(--len && isdigit(*++cp)) {
+        while (--len && isdigit(*++cp)) {
             pri = (pri * 10) + *cp - '0';
         }
         if (len && (*cp == '>')) {
@@ -502,42 +495,42 @@
 
 // Convert kernel log priority number into an Android Logger priority number
 static int convertKernelPrioToAndroidPrio(int pri) {
-    switch(pri & LOG_PRIMASK) {
-    case LOG_EMERG:
+    switch (pri & LOG_PRIMASK) {
+        case LOG_EMERG:
         // FALLTHRU
-    case LOG_ALERT:
+        case LOG_ALERT:
         // FALLTHRU
-    case LOG_CRIT:
-        return ANDROID_LOG_FATAL;
+        case LOG_CRIT:
+            return ANDROID_LOG_FATAL;
 
-    case LOG_ERR:
-        return ANDROID_LOG_ERROR;
+        case LOG_ERR:
+            return ANDROID_LOG_ERROR;
 
-    case LOG_WARNING:
-        return ANDROID_LOG_WARN;
+        case LOG_WARNING:
+            return ANDROID_LOG_WARN;
 
-    default:
+        default:
         // FALLTHRU
-    case LOG_NOTICE:
+        case LOG_NOTICE:
         // FALLTHRU
-    case LOG_INFO:
-        break;
+        case LOG_INFO:
+            break;
 
-    case LOG_DEBUG:
-        return ANDROID_LOG_DEBUG;
+        case LOG_DEBUG:
+            return ANDROID_LOG_DEBUG;
     }
 
     return ANDROID_LOG_INFO;
 }
 
-static const char *strnrchr(const char *s, size_t len, char c) {
-  const char *save = NULL;
-  for (;len; ++s, len--) {
-    if (*s == c) {
-      save = s;
+static const char* strnrchr(const char* s, size_t len, char c) {
+    const char* save = NULL;
+    for (; len; ++s, len--) {
+        if (*s == c) {
+            save = s;
+        }
     }
-  }
-  return save;
+    return save;
 }
 
 //
@@ -621,38 +614,41 @@
     while ((p < &buf[len]) && (isspace(*p) || !*p)) {
         ++p;
     }
-    if (p >= &buf[len]) { // timestamp, no content
+    if (p >= &buf[len]) {  // timestamp, no content
         return 0;
     }
     start = p;
-    const char *tag = "";
-    const char *etag = tag;
+    const char* tag = "";
+    const char* etag = tag;
     size_t taglen = len - (p - buf);
-    const char *bt = p;
+    const char* bt = p;
 
     static const char infoBrace[] = "[INFO]";
     static const size_t infoBraceLen = strlen(infoBrace);
-    if ((taglen >= infoBraceLen) && !fastcmp<strncmp>(p, infoBrace, infoBraceLen)) {
+    if ((taglen >= infoBraceLen) &&
+        !fastcmp<strncmp>(p, infoBrace, infoBraceLen)) {
         // <PRI>[<TIME>] "[INFO]"<tag> ":" message
         bt = p + infoBraceLen;
         taglen -= infoBraceLen;
     }
 
-    const char *et;
-    for (et = bt; taglen && *et && (*et != ':') && !isspace(*et); ++et, --taglen) {
-       // skip ':' within [ ... ]
-       if (*et == '[') {
-           while (taglen && *et && *et != ']') {
-               ++et;
-               --taglen;
-           }
-           if (!taglen) {
-               break;
-           }
-       }
+    const char* et;
+    for (et = bt; taglen && *et && (*et != ':') && !isspace(*et);
+         ++et, --taglen) {
+        // skip ':' within [ ... ]
+        if (*et == '[') {
+            while (taglen && *et && *et != ']') {
+                ++et;
+                --taglen;
+            }
+            if (!taglen) {
+                break;
+            }
+        }
     }
-    const char *cp;
-    for (cp = et; taglen && isspace(*cp); ++cp, --taglen);
+    const char* cp;
+    for (cp = et; taglen && isspace(*cp); ++cp, --taglen) {
+    }
 
     // Validate tag
     size_t size = et - bt;
@@ -667,18 +663,20 @@
             p = cp + 1;
         } else if ((taglen > size) && (tolower(*bt) == tolower(*cp))) {
             // clean up any tag stutter
-            if (!fastcmp<strncasecmp>(bt + 1, cp + 1, size - 1)) { // no match
+            if (!fastcmp<strncasecmp>(bt + 1, cp + 1, size - 1)) {  // no match
                 // <PRI>[<TIME>] <tag> <tag> : message
                 // <PRI>[<TIME>] <tag> <tag>: message
                 // <PRI>[<TIME>] <tag> '<tag>.<num>' : message
                 // <PRI>[<TIME>] <tag> '<tag><num>' : message
                 // <PRI>[<TIME>] <tag> '<tag><stuff>' : message
-                const char *b = cp;
+                const char* b = cp;
                 cp += size;
                 taglen -= size;
-                while (--taglen && !isspace(*++cp) && (*cp != ':'));
-                const char *e;
-                for (e = cp; taglen && isspace(*cp); ++cp, --taglen);
+                while (--taglen && !isspace(*++cp) && (*cp != ':')) {
+                }
+                const char* e;
+                for (e = cp; taglen && isspace(*cp); ++cp, --taglen) {
+                }
                 if (taglen && (*cp == ':')) {
                     tag = b;
                     etag = e;
@@ -689,15 +687,17 @@
                 static const char host[] = "_host";
                 static const size_t hostlen = strlen(host);
                 if ((size > hostlen) &&
-                        !fastcmp<strncmp>(bt + size - hostlen, host, hostlen) &&
-                        !fastcmp<strncmp>(bt + 1, cp + 1, size - hostlen - 1)) {
-                    const char *b = cp;
+                    !fastcmp<strncmp>(bt + size - hostlen, host, hostlen) &&
+                    !fastcmp<strncmp>(bt + 1, cp + 1, size - hostlen - 1)) {
+                    const char* b = cp;
                     cp += size - hostlen;
                     taglen -= size - hostlen;
                     if (*cp == '.') {
-                        while (--taglen && !isspace(*++cp) && (*cp != ':'));
-                        const char *e;
-                        for (e = cp; taglen && isspace(*cp); ++cp, --taglen);
+                        while (--taglen && !isspace(*++cp) && (*cp != ':')) {
+                        }
+                        const char* e;
+                        for (e = cp; taglen && isspace(*cp); ++cp, --taglen) {
+                        }
                         if (taglen && (*cp == ':')) {
                             tag = b;
                             etag = e;
@@ -709,10 +709,13 @@
                 }
             }
         } else {
-            // <PRI>[<TIME>] <tag> <stuff>' : message
-twoWord:    while (--taglen && !isspace(*++cp) && (*cp != ':'));
-            const char *e;
-            for (e = cp; taglen && isspace(*cp); ++cp, --taglen);
+        // <PRI>[<TIME>] <tag> <stuff>' : message
+        twoWord:
+            while (--taglen && !isspace(*++cp) && (*cp != ':')) {
+            }
+            const char* e;
+            for (e = cp; taglen && isspace(*cp); ++cp, --taglen) {
+            }
             // Two words
             if (taglen && (*cp == ':')) {
                 tag = bt;
@@ -720,7 +723,7 @@
                 p = cp + 1;
             }
         }
-    } // else no tag
+    }  // else no tag
 
     static const char cpu[] = "CPU";
     static const size_t cpuLen = strlen(cpu);
@@ -732,16 +735,17 @@
     static const size_t infoLen = strlen(info);
 
     size = etag - tag;
-    if ((size <= 1)
+    if ((size <= 1) ||
         // register names like x9
-            || ((size == 2) && (isdigit(tag[0]) || isdigit(tag[1])))
+        ((size == 2) && (isdigit(tag[0]) || isdigit(tag[1]))) ||
         // register names like x18 but not driver names like en0
-            || ((size == 3) && (isdigit(tag[1]) && isdigit(tag[2])))
+        ((size == 3) && (isdigit(tag[1]) && isdigit(tag[2]))) ||
         // blacklist
-            || ((size == cpuLen) && !fastcmp<strncmp>(tag, cpu, cpuLen))
-            || ((size == warningLen) && !fastcmp<strncasecmp>(tag, warning, warningLen))
-            || ((size == errorLen) && !fastcmp<strncasecmp>(tag, error, errorLen))
-            || ((size == infoLen) && !fastcmp<strncasecmp>(tag, info, infoLen))) {
+        ((size == cpuLen) && !fastcmp<strncmp>(tag, cpu, cpuLen)) ||
+        ((size == warningLen) &&
+         !fastcmp<strncasecmp>(tag, warning, warningLen)) ||
+        ((size == errorLen) && !fastcmp<strncasecmp>(tag, error, errorLen)) ||
+        ((size == infoLen) && !fastcmp<strncasecmp>(tag, info, infoLen))) {
         p = start;
         etag = tag = "";
     }
@@ -750,7 +754,7 @@
     //   eg: [143:healthd]healthd -> [143:healthd]
     taglen = etag - tag;
     // Mediatek-special printk induced stutter
-    const char *mp = strnrchr(tag, ']', taglen);
+    const char* mp = strnrchr(tag, ']', taglen);
     if (mp && (++mp < etag)) {
         size_t s = etag - mp;
         if (((s + s) < taglen) && !fastcmp<memcmp>(mp, mp - 1 - s, s)) {
@@ -767,7 +771,7 @@
     }
     // truncate trailing space or nuls
     size_t b = len - (p - buf);
-    while (b && (isspace(p[b-1]) || !p[b-1])) {
+    while (b && (isspace(p[b - 1]) || !p[b - 1])) {
         --b;
     }
     // trick ... allow tag with empty content to be logged. log() drops empty
@@ -796,7 +800,7 @@
     // truncating length argument to logbuf->log() below. Gain is protection
     // of stack sanity and speedup, loss is truncated long-line content.
     char newstr[n];
-    char *np = newstr;
+    char* np = newstr;
 
     // Convert priority into single-byte Android logger priority
     *np = convertKernelPrioToAndroidPrio(pri);
@@ -828,10 +832,10 @@
             unsigned abs0 = (diff0 < 0) ? -diff0 : diff0;
             int diff1 = (vote_time[1] - vote_time[2]) / near_seconds;
             unsigned abs1 = (diff1 < 0) ? -diff1 : diff1;
-            if ((abs1 <= 1) && // last two were in agreement on timezone
-                    ((abs0 + 1) % (timezones_seconds / near_seconds)) <= 2) {
+            if ((abs1 <= 1) &&  // last two were in agreement on timezone
+                ((abs0 + 1) % (timezones_seconds / near_seconds)) <= 2) {
                 abs0 = (abs0 + 1) / (timezones_seconds / near_seconds) *
-                                     timezones_seconds;
+                       timezones_seconds;
                 now.tv_sec -= (diff0 < 0) ? -abs0 : abs0;
             }
         }
@@ -839,7 +843,7 @@
 
     // Log message
     int rc = logbuf->log(LOG_ID_KERNEL, now, uid, pid, tid, newstr,
-                         (unsigned short) n);
+                         (unsigned short)n);
 
     // notify readers
     if (!rc) {
diff --git a/logd/LogKlog.h b/logd/LogKlog.h
index 11d88af..976afc8 100644
--- a/logd/LogKlog.h
+++ b/logd/LogKlog.h
@@ -20,14 +20,14 @@
 #include <private/android_logger.h>
 #include <sysutils/SocketListener.h>
 
-char *log_strntok_r(char *s, size_t *len, char **saveptr, size_t *sublen);
+char* log_strntok_r(char* s, size_t* len, char** saveptr, size_t* sublen);
 
 class LogBuffer;
 class LogReader;
 
 class LogKlog : public SocketListener {
-    LogBuffer *logbuf;
-    LogReader *reader;
+    LogBuffer* logbuf;
+    LogReader* reader;
     const log_time signature;
     // Set once thread is started, separates KLOG_ACTION_READ_ALL
     // and KLOG_ACTION_READ phases.
@@ -40,22 +40,28 @@
 
     static log_time correction;
 
-public:
-    LogKlog(LogBuffer *buf, LogReader *reader, int fdWrite, int fdRead, bool auditd);
-    int log(const char *buf, size_t len);
-    void synchronize(const char *buf, size_t len);
+   public:
+    LogKlog(LogBuffer* buf, LogReader* reader, int fdWrite, int fdRead,
+            bool auditd);
+    int log(const char* buf, size_t len);
+    void synchronize(const char* buf, size_t len);
 
-    bool isMonotonic() { return logbuf->isMonotonic(); }
-    static void convertMonotonicToReal(log_time &real) { real += correction; }
-    static void convertRealToMonotonic(log_time &real) { real -= correction; }
+    bool isMonotonic() {
+        return logbuf->isMonotonic();
+    }
+    static void convertMonotonicToReal(log_time& real) {
+        real += correction;
+    }
+    static void convertRealToMonotonic(log_time& real) {
+        real -= correction;
+    }
 
-protected:
-    void sniffTime(log_time &now, const char **buf, size_t len, bool reverse);
-    pid_t sniffPid(const char **buf, size_t len);
-    void calculateCorrection(const log_time &monotonic,
-                             const char *real_string, size_t len);
-    virtual bool onDataAvailable(SocketClient *cli);
-
+   protected:
+    void sniffTime(log_time& now, const char** buf, size_t len, bool reverse);
+    pid_t sniffPid(const char** buf, size_t len);
+    void calculateCorrection(const log_time& monotonic, const char* real_string,
+                             size_t len);
+    virtual bool onDataAvailable(SocketClient* cli);
 };
 
 #endif
diff --git a/logd/LogListener.cpp b/logd/LogListener.cpp
index 4a30e6d..dadc75f 100644
--- a/logd/LogListener.cpp
+++ b/logd/LogListener.cpp
@@ -30,32 +30,24 @@
 #include "LogListener.h"
 #include "LogUtils.h"
 
-LogListener::LogListener(LogBuffer *buf, LogReader *reader) :
-        SocketListener(getLogSocket(), false),
-        logbuf(buf),
-        reader(reader) {
+LogListener::LogListener(LogBuffer* buf, LogReader* reader)
+    : SocketListener(getLogSocket(), false), logbuf(buf), reader(reader) {
 }
 
-bool LogListener::onDataAvailable(SocketClient *cli) {
+bool LogListener::onDataAvailable(SocketClient* cli) {
     static bool name_set;
     if (!name_set) {
         prctl(PR_SET_NAME, "logd.writer");
         name_set = true;
     }
 
-    char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time)
-        + LOGGER_ENTRY_MAX_PAYLOAD];
+    char buffer[sizeof_log_id_t + sizeof(uint16_t) + sizeof(log_time) +
+                LOGGER_ENTRY_MAX_PAYLOAD];
     struct iovec iov = { buffer, sizeof(buffer) };
 
     alignas(4) char control[CMSG_SPACE(sizeof(struct ucred))];
     struct msghdr hdr = {
-        NULL,
-        0,
-        &iov,
-        1,
-        control,
-        sizeof(control),
-        0,
+        NULL, 0, &iov, 1, control, sizeof(control), 0,
     };
 
     int socket = cli->getSocket();
@@ -68,13 +60,13 @@
         return false;
     }
 
-    struct ucred *cred = NULL;
+    struct ucred* cred = NULL;
 
-    struct cmsghdr *cmsg = CMSG_FIRSTHDR(&hdr);
+    struct cmsghdr* cmsg = CMSG_FIRSTHDR(&hdr);
     while (cmsg != NULL) {
-        if (cmsg->cmsg_level == SOL_SOCKET
-                && cmsg->cmsg_type  == SCM_CREDENTIALS) {
-            cred = (struct ucred *)CMSG_DATA(cmsg);
+        if (cmsg->cmsg_level == SOL_SOCKET &&
+            cmsg->cmsg_type == SCM_CREDENTIALS) {
+            cred = (struct ucred*)CMSG_DATA(cmsg);
             break;
         }
         cmsg = CMSG_NXTHDR(&hdr, cmsg);
@@ -91,26 +83,29 @@
         return false;
     }
 
-    android_log_header_t *header = reinterpret_cast<android_log_header_t *>(buffer);
-    if (/* header->id < LOG_ID_MIN || */ header->id >= LOG_ID_MAX || header->id == LOG_ID_KERNEL) {
+    android_log_header_t* header =
+        reinterpret_cast<android_log_header_t*>(buffer);
+    if (/* header->id < LOG_ID_MIN || */ header->id >= LOG_ID_MAX ||
+        header->id == LOG_ID_KERNEL) {
         return false;
     }
 
     if ((header->id == LOG_ID_SECURITY) &&
-            (!__android_log_security() ||
-             !clientHasLogCredentials(cred->uid, cred->gid, cred->pid))) {
+        (!__android_log_security() ||
+         !clientHasLogCredentials(cred->uid, cred->gid, cred->pid))) {
         return false;
     }
 
-    char *msg = ((char *)buffer) + sizeof(android_log_header_t);
+    char* msg = ((char*)buffer) + sizeof(android_log_header_t);
     n -= sizeof(android_log_header_t);
 
     // NB: hdr.msg_flags & MSG_TRUNC is not tested, silently passing a
     // truncated message to the logs.
 
-    if (logbuf->log((log_id_t)header->id, header->realtime,
-            cred->uid, cred->pid, header->tid, msg,
-            ((size_t) n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX) >= 0) {
+    if (logbuf->log((log_id_t)header->id, header->realtime, cred->uid,
+                    cred->pid, header->tid, msg,
+                    ((size_t)n <= USHRT_MAX) ? (unsigned short)n : USHRT_MAX) >=
+        0) {
         reader->notifyNewLog();
     }
 
@@ -122,9 +117,8 @@
     int sock = android_get_control_socket(socketName);
 
     if (sock < 0) {
-        sock = socket_local_server(socketName,
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_DGRAM);
+        sock = socket_local_server(
+            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_DGRAM);
     }
 
     int on = 1;
diff --git a/logd/LogListener.h b/logd/LogListener.h
index 7099e13..2973b8b 100644
--- a/logd/LogListener.h
+++ b/logd/LogListener.h
@@ -21,16 +21,16 @@
 #include "LogReader.h"
 
 class LogListener : public SocketListener {
-    LogBuffer *logbuf;
-    LogReader *reader;
+    LogBuffer* logbuf;
+    LogReader* reader;
 
-public:
-    LogListener(LogBuffer *buf, LogReader *reader);
+   public:
+    LogListener(LogBuffer* buf, LogReader* reader);
 
-protected:
-    virtual bool onDataAvailable(SocketClient *cli);
+   protected:
+    virtual bool onDataAvailable(SocketClient* cli);
 
-private:
+   private:
     static int getLogSocket();
 };
 
diff --git a/logd/LogReader.cpp b/logd/LogReader.cpp
index 1b50b4e..76f5798 100644
--- a/logd/LogReader.cpp
+++ b/logd/LogReader.cpp
@@ -29,9 +29,8 @@
 #include "LogReader.h"
 #include "LogUtils.h"
 
-LogReader::LogReader(LogBuffer *logbuf) :
-        SocketListener(getLogSocket(), true),
-        mLogbuf(*logbuf) {
+LogReader::LogReader(LogBuffer* logbuf)
+    : SocketListener(getLogSocket(), true), mLogbuf(*logbuf) {
 }
 
 // When we are notified a new log entry is available, inform
@@ -41,7 +40,7 @@
     runOnEachSocket(&command);
 }
 
-bool LogReader::onDataAvailable(SocketClient *cli) {
+bool LogReader::onDataAvailable(SocketClient* cli) {
     static bool name_set;
     if (!name_set) {
         prctl(PR_SET_NAME, "logd.reader");
@@ -59,7 +58,7 @@
 
     unsigned long tail = 0;
     static const char _tail[] = " tail=";
-    char *cp = strstr(buffer, _tail);
+    char* cp = strstr(buffer, _tail);
     if (cp) {
         tail = atol(cp + sizeof(_tail) - 1);
     }
@@ -124,32 +123,33 @@
             const pid_t mPid;
             const unsigned mLogMask;
             bool startTimeSet;
-            log_time &start;
-            uint64_t &sequence;
+            log_time& start;
+            uint64_t& sequence;
             uint64_t last;
             bool isMonotonic;
 
-        public:
-            LogFindStart(unsigned logMask, pid_t pid, log_time &start, uint64_t &sequence, bool isMonotonic) :
-                    mPid(pid),
-                    mLogMask(logMask),
-                    startTimeSet(false),
-                    start(start),
-                    sequence(sequence),
-                    last(sequence),
-                    isMonotonic(isMonotonic) {
+           public:
+            LogFindStart(unsigned logMask, pid_t pid, log_time& start,
+                         uint64_t& sequence, bool isMonotonic)
+                : mPid(pid),
+                  mLogMask(logMask),
+                  startTimeSet(false),
+                  start(start),
+                  sequence(sequence),
+                  last(sequence),
+                  isMonotonic(isMonotonic) {
             }
 
-            static int callback(const LogBufferElement *element, void *obj) {
-                LogFindStart *me = reinterpret_cast<LogFindStart *>(obj);
-                if ((!me->mPid || (me->mPid == element->getPid()))
-                        && (me->mLogMask & (1 << element->getLogId()))) {
+            static int callback(const LogBufferElement* element, void* obj) {
+                LogFindStart* me = reinterpret_cast<LogFindStart*>(obj);
+                if ((!me->mPid || (me->mPid == element->getPid())) &&
+                    (me->mLogMask & (1 << element->getLogId()))) {
                     if (me->start == element->getRealTime()) {
                         me->sequence = element->getSequence();
                         me->startTimeSet = true;
                         return -1;
                     } else if (!me->isMonotonic ||
-                            android::isMonotonic(element->getRealTime())) {
+                               android::isMonotonic(element->getRealTime())) {
                         if (me->start < element->getRealTime()) {
                             me->sequence = me->last;
                             me->startTimeSet = true;
@@ -163,7 +163,9 @@
                 return false;
             }
 
-            bool found() { return startTimeSet; }
+            bool found() {
+                return startTimeSet;
+            }
         } logFindStart(logMask, pid, start, sequence,
                        logbuf().isMonotonic() && android::isMonotonic(start));
 
@@ -184,18 +186,19 @@
 
     // Set acceptable upper limit to wait for slow reader processing b/27242723
     struct timeval t = { LOGD_SNDTIMEO, 0 };
-    setsockopt(cli->getSocket(), SOL_SOCKET, SO_SNDTIMEO, (const char *)&t, sizeof(t));
+    setsockopt(cli->getSocket(), SOL_SOCKET, SO_SNDTIMEO, (const char*)&t,
+               sizeof(t));
 
     command.runSocketCommand(cli);
     return true;
 }
 
-void LogReader::doSocketDelete(SocketClient *cli) {
-    LastLogTimes &times = mLogbuf.mTimes;
+void LogReader::doSocketDelete(SocketClient* cli) {
+    LastLogTimes& times = mLogbuf.mTimes;
     LogTimeEntry::lock();
     LastLogTimes::iterator it = times.begin();
-    while(it != times.end()) {
-        LogTimeEntry *entry = (*it);
+    while (it != times.end()) {
+        LogTimeEntry* entry = (*it);
         if (entry->mClient == cli) {
             times.erase(it);
             entry->release_Locked();
@@ -211,9 +214,8 @@
     int sock = android_get_control_socket(socketName);
 
     if (sock < 0) {
-        sock = socket_local_server(socketName,
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_SEQPACKET);
+        sock = socket_local_server(
+            socketName, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET);
     }
 
     return sock;
diff --git a/logd/LogReader.h b/logd/LogReader.h
index fdcedf1..271e08c 100644
--- a/logd/LogReader.h
+++ b/logd/LogReader.h
@@ -24,22 +24,23 @@
 class LogBuffer;
 
 class LogReader : public SocketListener {
-    LogBuffer &mLogbuf;
+    LogBuffer& mLogbuf;
 
-public:
-    explicit LogReader(LogBuffer *logbuf);
+   public:
+    explicit LogReader(LogBuffer* logbuf);
     void notifyNewLog();
 
-    LogBuffer &logbuf(void) const { return mLogbuf; }
+    LogBuffer& logbuf(void) const {
+        return mLogbuf;
+    }
 
-protected:
-    virtual bool onDataAvailable(SocketClient *cli);
+   protected:
+    virtual bool onDataAvailable(SocketClient* cli);
 
-private:
+   private:
     static int getLogSocket();
 
-    void doSocketDelete(SocketClient *cli);
-
+    void doSocketDelete(SocketClient* cli);
 };
 
 #endif
diff --git a/logd/LogStatistics.cpp b/logd/LogStatistics.cpp
index 7e0a6b7..cc30f77 100644
--- a/logd/LogStatistics.cpp
+++ b/logd/LogStatistics.cpp
@@ -41,12 +41,14 @@
 
 namespace android {
 
-size_t sizesTotal() { return LogStatistics::sizesTotal(); }
+size_t sizesTotal() {
+    return LogStatistics::sizesTotal();
+}
 
 // caller must own and free character string
-char *pidToName(pid_t pid) {
-    char *retval = NULL;
-    if (pid == 0) { // special case from auditd/klogd for kernel
+char* pidToName(pid_t pid) {
+    char* retval = NULL;
+    if (pid == 0) {  // special case from auditd/klogd for kernel
         retval = strdup("logd");
     } else {
         char buffer[512];
@@ -55,7 +57,7 @@
         if (fd >= 0) {
             ssize_t ret = read(fd, buffer, sizeof(buffer));
             if (ret > 0) {
-                buffer[sizeof(buffer)-1] = '\0';
+                buffer[sizeof(buffer) - 1] = '\0';
                 // frameworks intermediate state
                 if (fastcmp<strcmp>(buffer, "<pre-initialized>")) {
                     retval = strdup(buffer);
@@ -66,10 +68,9 @@
     }
     return retval;
 }
-
 }
 
-void LogStatistics::add(LogBufferElement *element) {
+void LogStatistics::add(LogBufferElement* element) {
     log_id_t log_id = element->getLogId();
     unsigned short size = element->getMsgLen();
     mSizes[log_id] += size;
@@ -114,7 +115,7 @@
     }
 }
 
-void LogStatistics::subtract(LogBufferElement *element) {
+void LogStatistics::subtract(LogBufferElement* element) {
     log_id_t log_id = element->getLogId();
     unsigned short size = element->getMsgLen();
     mSizes[log_id] -= size;
@@ -151,7 +152,7 @@
 
 // Atomically set an entry to drop
 // entry->setDropped(1) must follow this call, caller should do this explicitly.
-void LogStatistics::drop(LogBufferElement *element) {
+void LogStatistics::drop(LogBufferElement* element) {
     log_id_t log_id = element->getLogId();
     unsigned short size = element->getMsgLen();
     mSizes[log_id] -= size;
@@ -180,7 +181,7 @@
 }
 
 // caller must own and free character string
-const char *LogStatistics::uidToName(uid_t uid) const {
+const char* LogStatistics::uidToName(uid_t uid) const {
     // Local hard coded favourites
     if (uid == AID_LOGD) {
         return strdup("auditd");
@@ -189,7 +190,7 @@
     // Android system
     if (uid < AID_APP) {
         // in bionic, thread safe as long as we copy the results
-        struct passwd *pwd = getpwuid(uid);
+        struct passwd* pwd = getpwuid(uid);
         if (pwd) {
             return strdup(pwd->pw_name);
         }
@@ -197,7 +198,7 @@
 
     // Parse /data/system/packages.list
     uid_t userId = uid % AID_USER_OFFSET;
-    const char *name = android::uidToName(userId);
+    const char* name = android::uidToName(userId);
     if (!name && (userId > (AID_SHARED_GID_START - AID_APP))) {
         name = android::uidToName(userId - (AID_SHARED_GID_START - AID_APP));
     }
@@ -207,24 +208,25 @@
 
     // Android application
     if (uid >= AID_APP) {
-        struct passwd *pwd = getpwuid(uid);
+        struct passwd* pwd = getpwuid(uid);
         if (pwd) {
             return strdup(pwd->pw_name);
         }
     }
 
     // report uid -> pid(s) -> pidToName if unique
-    for(pidTable_t::const_iterator it = pidTable.begin(); it != pidTable.end(); ++it) {
-        const PidEntry &entry = it->second;
+    for (pidTable_t::const_iterator it = pidTable.begin(); it != pidTable.end();
+         ++it) {
+        const PidEntry& entry = it->second;
 
         if (entry.getUid() == uid) {
-            const char *nameTmp = entry.getName();
+            const char* nameTmp = entry.getName();
 
             if (nameTmp) {
                 if (!name) {
                     name = strdup(nameTmp);
                 } else if (fastcmp<strcmp>(name, nameTmp)) {
-                    free(const_cast<char *>(name));
+                    free(const_cast<char*>(name));
                     name = NULL;
                     break;
                 }
@@ -236,26 +238,24 @@
     return name;
 }
 
-std::string UidEntry::formatHeader(const std::string &name, log_id_t id) const {
+std::string UidEntry::formatHeader(const std::string& name, log_id_t id) const {
     bool isprune = worstUidEnabledForLogid(id);
-    return formatLine(android::base::StringPrintf(
-                          name.c_str(), android_log_id_to_name(id)),
+    return formatLine(android::base::StringPrintf(name.c_str(),
+                                                  android_log_id_to_name(id)),
                       std::string("Size"),
-                      std::string(isprune ? "+/-  Pruned" : ""))
-         + formatLine(std::string("UID   PACKAGE"),
-                      std::string("BYTES"),
+                      std::string(isprune ? "+/-  Pruned" : "")) +
+           formatLine(std::string("UID   PACKAGE"), std::string("BYTES"),
                       std::string(isprune ? "NUM" : ""));
 }
 
-std::string UidEntry::format(const LogStatistics &stat, log_id_t id) const {
+std::string UidEntry::format(const LogStatistics& stat, log_id_t id) const {
     uid_t uid = getUid();
     std::string name = android::base::StringPrintf("%u", uid);
-    const char *nameTmp = stat.uidToName(uid);
+    const char* nameTmp = stat.uidToName(uid);
     if (nameTmp) {
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(6 - name.length(), (size_t)1),
-            "", nameTmp);
-        free(const_cast<char *>(nameTmp));
+            "%*s%s", (int)std::max(6 - name.length(), (size_t)1), "", nameTmp);
+        free(const_cast<char*>(nameTmp));
     }
 
     std::string size = android::base::StringPrintf("%zu", getSizes());
@@ -263,15 +263,16 @@
     std::string pruned = "";
     if (worstUidEnabledForLogid(id)) {
         size_t totalDropped = 0;
-        for (LogStatistics::uidTable_t::const_iterator it = stat.uidTable[id].begin();
-                it != stat.uidTable[id].end(); ++it) {
+        for (LogStatistics::uidTable_t::const_iterator it =
+                 stat.uidTable[id].begin();
+             it != stat.uidTable[id].end(); ++it) {
             totalDropped += it->second.getDropped();
         }
         size_t sizes = stat.sizes(id);
         size_t totalSize = stat.sizesTotal(id);
         size_t totalElements = stat.elementsTotal(id);
-        float totalVirtualSize = (float)sizes + (float)totalDropped * totalSize
-                                / totalElements;
+        float totalVirtualSize =
+            (float)sizes + (float)totalDropped * totalSize / totalElements;
         size_t entrySize = getSizes();
         float virtualEntrySize = entrySize;
         int realPermille = virtualEntrySize * 1000.0 / sizes;
@@ -281,31 +282,29 @@
             virtualEntrySize += (float)dropped * totalSize / totalElements;
         }
         int virtualPermille = virtualEntrySize * 1000.0 / totalVirtualSize;
-        int permille = (realPermille - virtualPermille) * 1000L
-                     / (virtualPermille ?: 1);
+        int permille =
+            (realPermille - virtualPermille) * 1000L / (virtualPermille ?: 1);
         if ((permille < -1) || (1 < permille)) {
             std::string change;
-            const char *units = "%";
-            const char *prefix = (permille > 0) ? "+" : "";
+            const char* units = "%";
+            const char* prefix = (permille > 0) ? "+" : "";
 
             if (permille > 999) {
-                permille = (permille + 1000) / 100; // Now tenths fold
+                permille = (permille + 1000) / 100;  // Now tenths fold
                 units = "X";
                 prefix = "";
             }
             if ((-99 < permille) && (permille < 99)) {
-                change = android::base::StringPrintf("%s%d.%u%s",
-                    prefix,
-                    permille / 10,
+                change = android::base::StringPrintf(
+                    "%s%d.%u%s", prefix, permille / 10,
                     ((permille < 0) ? (-permille % 10) : (permille % 10)),
                     units);
             } else {
-                change = android::base::StringPrintf("%s%d%s",
-                    prefix,
-                    (permille + 5) / 10, units);
+                change = android::base::StringPrintf(
+                    "%s%d%s", prefix, (permille + 5) / 10, units);
             }
-            ssize_t spaces = EntryBaseConstants::pruned_len
-                           - 2 - pruned.length() - change.length();
+            ssize_t spaces = EntryBaseConstants::pruned_len - 2 -
+                             pruned.length() - change.length();
             if ((spaces <= 0) && pruned.length()) {
                 spaces = 1;
             }
@@ -323,8 +322,8 @@
     }
 
     static const size_t maximum_sorted_entries = 32;
-    std::unique_ptr<const PidEntry *[]> sorted
-        = stat.pidSystemTable[id].sort(uid, (pid_t)0, maximum_sorted_entries);
+    std::unique_ptr<const PidEntry* []> sorted =
+        stat.pidSystemTable[id].sort(uid, (pid_t)0, maximum_sorted_entries);
 
     if (!sorted.get()) {
         return output;
@@ -333,7 +332,7 @@
     size_t index;
     bool hasDropped = false;
     for (index = 0; index < maximum_sorted_entries; ++index) {
-        const PidEntry *entry = sorted[index];
+        const PidEntry* entry = sorted[index];
         if (!entry) {
             break;
         }
@@ -345,43 +344,39 @@
         }
         byPid += entry->format(stat, id);
     }
-    if (index > 1) { // print this only if interesting
+    if (index > 1) {  // print this only if interesting
         std::string ditto("\" ");
-        output += formatLine(std::string("  PID/UID   COMMAND LINE"),
-                             ditto, hasDropped ? ditto : std::string(""));
+        output += formatLine(std::string("  PID/UID   COMMAND LINE"), ditto,
+                             hasDropped ? ditto : std::string(""));
         output += byPid;
     }
 
     return output;
 }
 
-std::string PidEntry::formatHeader(const std::string &name, log_id_t /* id */) const {
-    return formatLine(name,
-                      std::string("Size"),
-                      std::string("Pruned"))
-         + formatLine(std::string("  PID/UID   COMMAND LINE"),
-                      std::string("BYTES"),
-                      std::string("NUM"));
+std::string PidEntry::formatHeader(const std::string& name,
+                                   log_id_t /* id */) const {
+    return formatLine(name, std::string("Size"), std::string("Pruned")) +
+           formatLine(std::string("  PID/UID   COMMAND LINE"),
+                      std::string("BYTES"), std::string("NUM"));
 }
 
-std::string PidEntry::format(const LogStatistics &stat, log_id_t /* id */) const {
+std::string PidEntry::format(const LogStatistics& stat,
+                             log_id_t /* id */) const {
     uid_t uid = getUid();
     pid_t pid = getPid();
     std::string name = android::base::StringPrintf("%5u/%u", pid, uid);
-    const char *nameTmp = getName();
+    const char* nameTmp = getName();
     if (nameTmp) {
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(12 - name.length(), (size_t)1),
-            "", nameTmp);
+            "%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", nameTmp);
     } else if ((nameTmp = stat.uidToName(uid))) {
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(12 - name.length(), (size_t)1),
-            "", nameTmp);
-        free(const_cast<char *>(nameTmp));
+            "%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", nameTmp);
+        free(const_cast<char*>(nameTmp));
     }
 
-    std::string size = android::base::StringPrintf("%zu",
-                                                   getSizes());
+    std::string size = android::base::StringPrintf("%zu", getSizes());
 
     std::string pruned = "";
     size_t dropped = getDropped();
@@ -392,36 +387,31 @@
     return formatLine(name, size, pruned);
 }
 
-std::string TidEntry::formatHeader(const std::string &name, log_id_t /* id */) const {
-    return formatLine(name,
-                      std::string("Size"),
-                      std::string("Pruned"))
-         + formatLine(std::string("  TID/UID   COMM"),
-                      std::string("BYTES"),
+std::string TidEntry::formatHeader(const std::string& name,
+                                   log_id_t /* id */) const {
+    return formatLine(name, std::string("Size"), std::string("Pruned")) +
+           formatLine(std::string("  TID/UID   COMM"), std::string("BYTES"),
                       std::string("NUM"));
 }
 
-std::string TidEntry::format(const LogStatistics &stat, log_id_t /* id */) const {
+std::string TidEntry::format(const LogStatistics& stat,
+                             log_id_t /* id */) const {
     uid_t uid = getUid();
-    std::string name = android::base::StringPrintf("%5u/%u",
-                                                   getTid(), uid);
-    const char *nameTmp = getName();
+    std::string name = android::base::StringPrintf("%5u/%u", getTid(), uid);
+    const char* nameTmp = getName();
     if (nameTmp) {
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(12 - name.length(), (size_t)1),
-            "", nameTmp);
+            "%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", nameTmp);
     } else if ((nameTmp = stat.uidToName(uid))) {
         // if we do not have a PID name, lets punt to try UID name?
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(12 - name.length(), (size_t)1),
-            "", nameTmp);
-        free(const_cast<char *>(nameTmp));
+            "%*s%s", (int)std::max(12 - name.length(), (size_t)1), "", nameTmp);
+        free(const_cast<char*>(nameTmp));
         // We tried, better to not have a name at all, we still
         // have TID/UID by number to report in any case.
     }
 
-    std::string size = android::base::StringPrintf("%zu",
-                                                   getSizes());
+    std::string size = android::base::StringPrintf("%zu", getSizes());
 
     std::string pruned = "";
     size_t dropped = getDropped();
@@ -432,35 +422,30 @@
     return formatLine(name, size, pruned);
 }
 
-std::string TagEntry::formatHeader(const std::string &name, log_id_t id) const {
+std::string TagEntry::formatHeader(const std::string& name, log_id_t id) const {
     bool isprune = worstUidEnabledForLogid(id);
-    return formatLine(name,
-                      std::string("Size"),
-                      std::string(isprune ? "Prune" : ""))
-         + formatLine(std::string("    TAG/UID   TAGNAME"),
-                      std::string("BYTES"),
-                      std::string(isprune ? "NUM" : ""));
+    return formatLine(name, std::string("Size"),
+                      std::string(isprune ? "Prune" : "")) +
+           formatLine(std::string("    TAG/UID   TAGNAME"),
+                      std::string("BYTES"), std::string(isprune ? "NUM" : ""));
 }
 
-std::string TagEntry::format(const LogStatistics & /* stat */, log_id_t /* id */) const {
+std::string TagEntry::format(const LogStatistics& /* stat */,
+                             log_id_t /* id */) const {
     std::string name;
     uid_t uid = getUid();
     if (uid == (uid_t)-1) {
-        name = android::base::StringPrintf("%7u",
-                                           getKey());
+        name = android::base::StringPrintf("%7u", getKey());
     } else {
-        name = android::base::StringPrintf("%7u/%u",
-                                           getKey(), uid);
+        name = android::base::StringPrintf("%7u/%u", getKey(), uid);
     }
-    const char *nameTmp = getName();
+    const char* nameTmp = getName();
     if (nameTmp) {
         name += android::base::StringPrintf(
-            "%*s%s", (int)std::max(14 - name.length(), (size_t)1),
-            "", nameTmp);
+            "%*s%s", (int)std::max(14 - name.length(), (size_t)1), "", nameTmp);
     }
 
-    std::string size = android::base::StringPrintf("%zu",
-                                                   getSizes());
+    std::string size = android::base::StringPrintf("%zu", getSizes());
 
     std::string pruned = "";
     size_t dropped = getDropped();
@@ -506,11 +491,13 @@
         totalSize += szs;
         size_t els = elementsTotal(id);
         totalEls += els;
-        output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
+        output +=
+            android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
         spaces += spaces_total + oldLength - output.length();
     }
     if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize, totalEls);
+    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize,
+                                          totalEls);
 
     static const char NowStr[] = "\nNow";
     spaces = 10 - strlen(NowStr);
@@ -528,13 +515,15 @@
             size_t szs = sizes(id);
             totalSize += szs;
             totalEls += els;
-            output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
+            output +=
+                android::base::StringPrintf("%*s%zu/%zu", spaces, "", szs, els);
             spaces -= output.length() - oldLength;
         }
         spaces += spaces_total;
     }
     if (spaces < 0) spaces = 0;
-    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize, totalEls);
+    output += android::base::StringPrintf("%*s%zu/%zu", spaces, "", totalSize,
+                                          totalEls);
 
     static const char OverheadStr[] = "\nOverhead";
     spaces = 10 - strlen(OverheadStr);
@@ -551,7 +540,7 @@
             // estimate the std::list overhead.
             static const size_t overhead =
                 ((sizeof(LogBufferElement) + sizeof(uint64_t) - 1) &
-                    -sizeof(uint64_t)) +
+                 -sizeof(uint64_t)) +
                 sizeof(std::list<LogBufferElement*>);
             size_t szs = sizes(id) + els * overhead;
             totalSize += szs;
@@ -572,16 +561,14 @@
     log_id_for_each(id) {
         if (!(logMask & (1 << id))) continue;
 
-        name = (uid == AID_ROOT)
-            ? "Chattiest UIDs in %s log buffer:"
-            : "Logging for your UID in %s log buffer:";
+        name = (uid == AID_ROOT) ? "Chattiest UIDs in %s log buffer:"
+                                 : "Logging for your UID in %s log buffer:";
         output += uidTable[id].format(*this, uid, pid, name, id);
     }
 
     if (enable) {
-        name = ((uid == AID_ROOT) && !pid)
-            ? "Chattiest PIDs:"
-            : "Logging for this PID:";
+        name = ((uid == AID_ROOT) && !pid) ? "Chattiest PIDs:"
+                                           : "Logging for this PID:";
         output += pidTable.format(*this, uid, pid, name);
         name = "Chattiest TIDs";
         if (pid) name += android::base::StringPrintf(" for PID %d", pid);
@@ -600,7 +587,8 @@
         name = "Chattiest security log buffer TAGs";
         if (pid) name += android::base::StringPrintf(" for PID %d", pid);
         name += ":";
-        output += securityTagTable.format(*this, uid, pid, name, LOG_ID_SECURITY);
+        output +=
+            securityTagTable.format(*this, uid, pid, name, LOG_ID_SECURITY);
     }
 
     return output;
@@ -611,7 +599,7 @@
 uid_t pidToUid(pid_t pid) {
     char buffer[512];
     snprintf(buffer, sizeof(buffer), "/proc/%u/status", pid);
-    FILE *fp = fopen(buffer, "r");
+    FILE* fp = fopen(buffer, "r");
     if (fp) {
         while (fgets(buffer, sizeof(buffer), fp)) {
             int uid;
@@ -622,9 +610,8 @@
         }
         fclose(fp);
     }
-    return AID_LOGD; // associate this with the logger
+    return AID_LOGD;  // associate this with the logger
 }
-
 }
 
 uid_t LogStatistics::pidToUid(pid_t pid) {
@@ -632,10 +619,10 @@
 }
 
 // caller must free character string
-const char *LogStatistics::pidToName(pid_t pid) const {
+const char* LogStatistics::pidToName(pid_t pid) const {
     // An inconvenient truth ... getName() can alter the object
-    pidTable_t &writablePidTable = const_cast<pidTable_t &>(pidTable);
-    const char *name = writablePidTable.add(pid)->second.getName();
+    pidTable_t& writablePidTable = const_cast<pidTable_t&>(pidTable);
+    const char* name = writablePidTable.add(pid)->second.getName();
     if (!name) {
         return NULL;
     }
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index 777dc33..066b7de 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -21,26 +21,25 @@
 #include <stdlib.h>
 #include <sys/types.h>
 
-#include <algorithm> // std::max
+#include <algorithm>  // std::max
 #include <memory>
-#include <string>    // std::string
+#include <string>  // std::string
 #include <unordered_map>
 
-#include <android/log.h>
 #include <android-base/stringprintf.h>
+#include <android/log.h>
 #include <private/android_filesystem_config.h>
 
 #include "LogBufferElement.h"
 #include "LogUtils.h"
 
 #define log_id_for_each(i) \
-    for (log_id_t i = LOG_ID_MIN; (i) < LOG_ID_MAX; (i) = (log_id_t) ((i) + 1))
+    for (log_id_t i = LOG_ID_MIN; (i) < LOG_ID_MAX; (i) = (log_id_t)((i) + 1))
 
 class LogStatistics;
 
 template <typename TKey, typename TEntry>
 class LogHashtable {
-
     std::unordered_map<TKey, TEntry> map;
 
     size_t bucket_size() const {
@@ -58,9 +57,10 @@
     static const size_t unordered_map_per_entry_overhead = sizeof(void*);
     static const size_t unordered_map_bucket_overhead = sizeof(void*);
 
-public:
-
-    size_t size() const { return map.size(); }
+   public:
+    size_t size() const {
+        return map.size();
+    }
 
     // Estimate unordered_map memory usage.
     size_t sizeOf() const {
@@ -70,20 +70,21 @@
     }
 
     typedef typename std::unordered_map<TKey, TEntry>::iterator iterator;
-    typedef typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator;
+    typedef
+        typename std::unordered_map<TKey, TEntry>::const_iterator const_iterator;
 
-    std::unique_ptr<const TEntry *[]> sort(uid_t uid, pid_t pid,
+    std::unique_ptr<const TEntry* []> sort(uid_t uid, pid_t pid,
                                            size_t len) const {
         if (!len) {
-            std::unique_ptr<const TEntry *[]> sorted(NULL);
+            std::unique_ptr<const TEntry* []> sorted(NULL);
             return sorted;
         }
 
-        const TEntry **retval = new const TEntry* [len];
+        const TEntry** retval = new const TEntry*[len];
         memset(retval, 0, sizeof(*retval) * len);
 
-        for(const_iterator it = map.begin(); it != map.end(); ++it) {
-            const TEntry &entry = it->second;
+        for (const_iterator it = map.begin(); it != map.end(); ++it) {
+            const TEntry& entry = it->second;
 
             if ((uid != AID_ROOT) && (uid != entry.getUid())) {
                 continue;
@@ -94,8 +95,8 @@
 
             size_t sizes = entry.getSizes();
             ssize_t index = len - 1;
-            while ((!retval[index] || (sizes > retval[index]->getSizes()))
-                    && (--index >= 0))
+            while ((!retval[index] || (sizes > retval[index]->getSizes())) &&
+                   (--index >= 0))
                 ;
             if (++index < (ssize_t)len) {
                 size_t num = len - index - 1;
@@ -106,11 +107,11 @@
                 retval[index] = &entry;
             }
         }
-        std::unique_ptr<const TEntry *[]> sorted(retval);
+        std::unique_ptr<const TEntry* []> sorted(retval);
         return sorted;
     }
 
-    inline iterator add(TKey key, LogBufferElement *element) {
+    inline iterator add(TKey key, LogBufferElement* element) {
         iterator it = map.find(key);
         if (it == map.end()) {
             it = map.insert(std::make_pair(key, TEntry(element))).first;
@@ -130,41 +131,46 @@
         return it;
     }
 
-    void subtract(TKey key, LogBufferElement *element) {
+    void subtract(TKey key, LogBufferElement* element) {
         iterator it = map.find(key);
         if ((it != map.end()) && it->second.subtract(element)) {
             map.erase(it);
         }
     }
 
-    inline void drop(TKey key, LogBufferElement *element) {
+    inline void drop(TKey key, LogBufferElement* element) {
         iterator it = map.find(key);
         if (it != map.end()) {
             it->second.drop(element);
         }
     }
 
-    inline iterator begin() { return map.begin(); }
-    inline const_iterator begin() const { return map.begin(); }
-    inline iterator end() { return map.end(); }
-    inline const_iterator end() const { return map.end(); }
+    inline iterator begin() {
+        return map.begin();
+    }
+    inline const_iterator begin() const {
+        return map.begin();
+    }
+    inline iterator end() {
+        return map.end();
+    }
+    inline const_iterator end() const {
+        return map.end();
+    }
 
-    std::string format(
-            const LogStatistics &stat,
-            uid_t uid,
-            pid_t pid,
-            const std::string &name = std::string(""),
-            log_id_t id = LOG_ID_MAX) const {
+    std::string format(const LogStatistics& stat, uid_t uid, pid_t pid,
+                       const std::string& name = std::string(""),
+                       log_id_t id = LOG_ID_MAX) const {
         static const size_t maximum_sorted_entries = 32;
         std::string output;
-        std::unique_ptr<const TEntry *[]> sorted = sort(uid, pid,
-                                                        maximum_sorted_entries);
+        std::unique_ptr<const TEntry* []> sorted =
+            sort(uid, pid, maximum_sorted_entries);
         if (!sorted.get()) {
             return output;
         }
         bool headerPrinted = false;
         for (size_t index = 0; index < maximum_sorted_entries; ++index) {
-            const TEntry *entry = sorted[index];
+            const TEntry* entry = sorted[index];
             if (!entry) {
                 break;
             }
@@ -180,42 +186,45 @@
         }
         return output;
     }
-
 };
 
 namespace EntryBaseConstants {
-    static constexpr size_t pruned_len = 14;
-    static constexpr size_t total_len = 80;
+static constexpr size_t pruned_len = 14;
+static constexpr size_t total_len = 80;
 }
 
 struct EntryBase {
     size_t size;
 
-    EntryBase():size(0) { }
-    explicit EntryBase(LogBufferElement *element):size(element->getMsgLen()) { }
+    EntryBase() : size(0) {
+    }
+    explicit EntryBase(LogBufferElement* element) : size(element->getMsgLen()) {
+    }
 
-    size_t getSizes() const { return size; }
+    size_t getSizes() const {
+        return size;
+    }
 
-    inline void add(LogBufferElement *element) { size += element->getMsgLen(); }
-    inline bool subtract(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
+        size += element->getMsgLen();
+    }
+    inline bool subtract(LogBufferElement* element) {
         size -= element->getMsgLen();
         return !size;
     }
 
-    static std::string formatLine(
-            const std::string &name,
-            const std::string &size,
-            const std::string &pruned) {
-        ssize_t drop_len = std::max(pruned.length() + 1,
-                                    EntryBaseConstants::pruned_len);
-        ssize_t size_len = std::max(size.length() + 1,
-                                    EntryBaseConstants::total_len
-                                        - name.length() - drop_len - 1);
+    static std::string formatLine(const std::string& name,
+                                  const std::string& size,
+                                  const std::string& pruned) {
+        ssize_t drop_len =
+            std::max(pruned.length() + 1, EntryBaseConstants::pruned_len);
+        ssize_t size_len =
+            std::max(size.length() + 1, EntryBaseConstants::total_len -
+                                            name.length() - drop_len - 1);
 
-        std::string ret = android::base::StringPrintf("%s%*s%*s",
-                                                      name.c_str(),
-                                                      (int)size_len, size.c_str(),
-                                                      (int)drop_len, pruned.c_str());
+        std::string ret = android::base::StringPrintf(
+            "%s%*s%*s", name.c_str(), (int)size_len, size.c_str(),
+            (int)drop_len, pruned.c_str());
         // remove any trailing spaces
         size_t pos = ret.size();
         size_t len = 0;
@@ -228,23 +237,25 @@
 struct EntryBaseDropped : public EntryBase {
     size_t dropped;
 
-    EntryBaseDropped():dropped(0) { }
-    explicit EntryBaseDropped(LogBufferElement *element):
-            EntryBase(element),
-            dropped(element->getDropped()) {
+    EntryBaseDropped() : dropped(0) {
+    }
+    explicit EntryBaseDropped(LogBufferElement* element)
+        : EntryBase(element), dropped(element->getDropped()) {
     }
 
-    size_t getDropped() const { return dropped; }
+    size_t getDropped() const {
+        return dropped;
+    }
 
-    inline void add(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
         dropped += element->getDropped();
         EntryBase::add(element);
     }
-    inline bool subtract(LogBufferElement *element) {
+    inline bool subtract(LogBufferElement* element) {
         dropped -= element->getDropped();
         return EntryBase::subtract(element) && !dropped;
     }
-    inline void drop(LogBufferElement *element) {
+    inline void drop(LogBufferElement* element) {
         dropped += 1;
         EntryBase::subtract(element);
     }
@@ -254,25 +265,31 @@
     const uid_t uid;
     pid_t pid;
 
-    explicit UidEntry(LogBufferElement *element):
-            EntryBaseDropped(element),
-            uid(element->getUid()),
-            pid(element->getPid()) {
+    explicit UidEntry(LogBufferElement* element)
+        : EntryBaseDropped(element),
+          uid(element->getUid()),
+          pid(element->getPid()) {
     }
 
-    inline const uid_t&getKey() const { return uid; }
-    inline const uid_t&getUid() const { return getKey(); }
-    inline const pid_t&getPid() const { return pid; }
+    inline const uid_t& getKey() const {
+        return uid;
+    }
+    inline const uid_t& getUid() const {
+        return getKey();
+    }
+    inline const pid_t& getPid() const {
+        return pid;
+    }
 
-    inline void add(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
         if (pid != element->getPid()) {
             pid = -1;
         }
         EntryBaseDropped::add(element);
     }
 
-    std::string formatHeader(const std::string &name, log_id_t id) const;
-    std::string format(const LogStatistics &stat, log_id_t id) const;
+    std::string formatHeader(const std::string& name, log_id_t id) const;
+    std::string format(const LogStatistics& stat, log_id_t id) const;
 };
 
 namespace android {
@@ -282,32 +299,42 @@
 struct PidEntry : public EntryBaseDropped {
     const pid_t pid;
     uid_t uid;
-    char *name;
+    char* name;
 
-    explicit PidEntry(pid_t pid):
-            EntryBaseDropped(),
-            pid(pid),
-            uid(android::pidToUid(pid)),
-            name(android::pidToName(pid)) {
+    explicit PidEntry(pid_t pid)
+        : EntryBaseDropped(),
+          pid(pid),
+          uid(android::pidToUid(pid)),
+          name(android::pidToName(pid)) {
     }
-    explicit PidEntry(LogBufferElement *element):
-            EntryBaseDropped(element),
-            pid(element->getPid()),
-            uid(element->getUid()),
-            name(android::pidToName(pid)) {
+    explicit PidEntry(LogBufferElement* element)
+        : EntryBaseDropped(element),
+          pid(element->getPid()),
+          uid(element->getUid()),
+          name(android::pidToName(pid)) {
     }
-    PidEntry(const PidEntry &element):
-            EntryBaseDropped(element),
-            pid(element.pid),
-            uid(element.uid),
-            name(element.name ? strdup(element.name) : NULL) {
+    PidEntry(const PidEntry& element)
+        : EntryBaseDropped(element),
+          pid(element.pid),
+          uid(element.uid),
+          name(element.name ? strdup(element.name) : NULL) {
     }
-    ~PidEntry() { free(name); }
+    ~PidEntry() {
+        free(name);
+    }
 
-    const pid_t&getKey() const { return pid; }
-    const pid_t&getPid() const { return getKey(); }
-    const uid_t&getUid() const { return uid; }
-    const char*getName() const { return name; }
+    const pid_t& getKey() const {
+        return pid;
+    }
+    const pid_t& getPid() const {
+        return getKey();
+    }
+    const uid_t& getUid() const {
+        return uid;
+    }
+    const char* getName() const {
+        return name;
+    }
 
     inline void add(pid_t newPid) {
         if (name && !fastcmp<strncmp>(name, "zygote", 6)) {
@@ -319,7 +346,7 @@
         }
     }
 
-    inline void add(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
         uid_t incomingUid = element->getUid();
         if (getUid() != incomingUid) {
             uid = incomingUid;
@@ -331,44 +358,56 @@
         EntryBaseDropped::add(element);
     }
 
-    std::string formatHeader(const std::string &name, log_id_t id) const;
-    std::string format(const LogStatistics &stat, log_id_t id) const;
+    std::string formatHeader(const std::string& name, log_id_t id) const;
+    std::string format(const LogStatistics& stat, log_id_t id) const;
 };
 
 struct TidEntry : public EntryBaseDropped {
     const pid_t tid;
     pid_t pid;
     uid_t uid;
-    char *name;
+    char* name;
 
-    TidEntry(pid_t tid, pid_t pid):
-            EntryBaseDropped(),
-            tid(tid),
-            pid(pid),
-            uid(android::pidToUid(tid)),
-            name(android::tidToName(tid)) {
+    TidEntry(pid_t tid, pid_t pid)
+        : EntryBaseDropped(),
+          tid(tid),
+          pid(pid),
+          uid(android::pidToUid(tid)),
+          name(android::tidToName(tid)) {
     }
-    explicit TidEntry(LogBufferElement *element):
-            EntryBaseDropped(element),
-            tid(element->getTid()),
-            pid(element->getPid()),
-            uid(element->getUid()),
-            name(android::tidToName(tid)) {
+    explicit TidEntry(LogBufferElement* element)
+        : EntryBaseDropped(element),
+          tid(element->getTid()),
+          pid(element->getPid()),
+          uid(element->getUid()),
+          name(android::tidToName(tid)) {
     }
-    TidEntry(const TidEntry &element):
-            EntryBaseDropped(element),
-            tid(element.tid),
-            pid(element.pid),
-            uid(element.uid),
-            name(element.name ? strdup(element.name) : NULL) {
+    TidEntry(const TidEntry& element)
+        : EntryBaseDropped(element),
+          tid(element.tid),
+          pid(element.pid),
+          uid(element.uid),
+          name(element.name ? strdup(element.name) : NULL) {
     }
-    ~TidEntry() { free(name); }
+    ~TidEntry() {
+        free(name);
+    }
 
-    const pid_t&getKey() const { return tid; }
-    const pid_t&getTid() const { return getKey(); }
-    const pid_t&getPid() const { return pid; }
-    const uid_t&getUid() const { return uid; }
-    const char*getName() const { return name; }
+    const pid_t& getKey() const {
+        return tid;
+    }
+    const pid_t& getTid() const {
+        return getKey();
+    }
+    const pid_t& getPid() const {
+        return pid;
+    }
+    const uid_t& getUid() const {
+        return uid;
+    }
+    const char* getName() const {
+        return name;
+    }
 
     inline void add(pid_t incomingTid) {
         if (name && !fastcmp<strncmp>(name, "zygote", 6)) {
@@ -380,7 +419,7 @@
         }
     }
 
-    inline void add(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
         uid_t incomingUid = element->getUid();
         pid_t incomingPid = element->getPid();
         if ((getUid() != incomingUid) || (getPid() != incomingPid)) {
@@ -394,8 +433,8 @@
         EntryBaseDropped::add(element);
     }
 
-    std::string formatHeader(const std::string &name, log_id_t id) const;
-    std::string format(const LogStatistics &stat, log_id_t id) const;
+    std::string formatHeader(const std::string& name, log_id_t id) const;
+    std::string format(const LogStatistics& stat, log_id_t id) const;
 };
 
 struct TagEntry : public EntryBaseDropped {
@@ -403,19 +442,27 @@
     pid_t pid;
     uid_t uid;
 
-    explicit TagEntry(LogBufferElement *element):
-            EntryBaseDropped(element),
-            tag(element->getTag()),
-            pid(element->getPid()),
-            uid(element->getUid()) {
+    explicit TagEntry(LogBufferElement* element)
+        : EntryBaseDropped(element),
+          tag(element->getTag()),
+          pid(element->getPid()),
+          uid(element->getUid()) {
     }
 
-    const uint32_t&getKey() const { return tag; }
-    const pid_t&getPid() const { return pid; }
-    const uid_t&getUid() const { return uid; }
-    const char*getName() const { return android::tagToName(tag); }
+    const uint32_t& getKey() const {
+        return tag;
+    }
+    const pid_t& getPid() const {
+        return pid;
+    }
+    const uid_t& getUid() const {
+        return uid;
+    }
+    const char* getName() const {
+        return android::tagToName(tag);
+    }
 
-    inline void add(LogBufferElement *element) {
+    inline void add(LogBufferElement* element) {
         if (uid != element->getUid()) {
             uid = -1;
         }
@@ -425,27 +472,27 @@
         EntryBaseDropped::add(element);
     }
 
-    std::string formatHeader(const std::string &name, log_id_t id) const;
-    std::string format(const LogStatistics &stat, log_id_t id) const;
+    std::string formatHeader(const std::string& name, log_id_t id) const;
+    std::string format(const LogStatistics& stat, log_id_t id) const;
 };
 
 template <typename TEntry>
 class LogFindWorst {
-    std::unique_ptr<const TEntry *[]> sorted;
+    std::unique_ptr<const TEntry* []> sorted;
 
-public:
+   public:
+    explicit LogFindWorst(std::unique_ptr<const TEntry* []>&& sorted)
+        : sorted(std::move(sorted)) {
+    }
 
-    explicit LogFindWorst(std::unique_ptr<const TEntry *[]> &&sorted) : sorted(std::move(sorted)) { }
-
-    void findWorst(int &worst,
-                    size_t &worst_sizes, size_t &second_worst_sizes,
-                    size_t threshold) {
+    void findWorst(int& worst, size_t& worst_sizes, size_t& second_worst_sizes,
+                   size_t threshold) {
         if (sorted.get() && sorted[0] && sorted[1]) {
             worst_sizes = sorted[0]->getSizes();
             if ((worst_sizes > threshold)
                 // Allow time horizon to extend roughly tenfold, assume
                 // average entry length is 100 characters.
-                    && (worst_sizes > (10 * sorted[0]->getDropped()))) {
+                && (worst_sizes > (10 * sorted[0]->getDropped()))) {
                 worst = sorted[0]->getKey();
                 second_worst_sizes = sorted[1]->getSizes();
                 if (second_worst_sizes < threshold) {
@@ -455,13 +502,11 @@
         }
     }
 
-    void findWorst(int &worst,
-                    size_t worst_sizes, size_t &second_worst_sizes) {
+    void findWorst(int& worst, size_t worst_sizes, size_t& second_worst_sizes) {
         if (sorted.get() && sorted[0] && sorted[1]) {
             worst = sorted[0]->getKey();
-            second_worst_sizes = worst_sizes
-                               - sorted[0]->getSizes()
-                               + sorted[1]->getSizes();
+            second_worst_sizes =
+                worst_sizes - sorted[0]->getSizes() + sorted[1]->getSizes();
         }
     }
 };
@@ -506,11 +551,11 @@
                       tagTable.sizeOf() + securityTagTable.sizeOf() +
                       (pidTable.size() * sizeof(pidTable_t::iterator)) +
                       (tagTable.size() * sizeof(tagTable_t::iterator));
-        for(auto it : pidTable) {
+        for (auto it : pidTable) {
             const char* name = it.second.getName();
             if (name) size += strlen(name) + 1;
         }
-        for(auto it : tidTable) {
+        for (auto it : tidTable) {
             const char* name = it.second.getName();
             if (name) size += strlen(name) + 1;
         }
@@ -518,23 +563,25 @@
             size += uidTable[id].sizeOf();
             size += uidTable[id].size() * sizeof(uidTable_t::iterator);
             size += pidSystemTable[id].sizeOf();
-            size += pidSystemTable[id].size() * sizeof(pidSystemTable_t::iterator);
+            size +=
+                pidSystemTable[id].size() * sizeof(pidSystemTable_t::iterator);
         }
         return size;
     }
 
-public:
-
+   public:
     LogStatistics();
 
-    void enableStatistics() { enable = true; }
+    void enableStatistics() {
+        enable = true;
+    }
 
-    void add(LogBufferElement *entry);
-    void subtract(LogBufferElement *entry);
+    void add(LogBufferElement* entry);
+    void subtract(LogBufferElement* entry);
     // entry->setDropped(1) must follow this call
-    void drop(LogBufferElement *entry);
+    void drop(LogBufferElement* entry);
     // Correct for coalescing two entries referencing dropped content
-    void erase(LogBufferElement *element) {
+    void erase(LogBufferElement* element) {
         log_id_t log_id = element->getLogId();
         --mElements[log_id];
         --mDroppedElements[log_id];
@@ -543,7 +590,8 @@
     LogFindWorst<UidEntry> sort(uid_t uid, pid_t pid, size_t len, log_id id) {
         return LogFindWorst<UidEntry>(uidTable[id].sort(uid, pid, len));
     }
-    LogFindWorst<PidEntry> sortPids(uid_t uid, pid_t pid, size_t len, log_id id) {
+    LogFindWorst<PidEntry> sortPids(uid_t uid, pid_t pid, size_t len,
+                                    log_id id) {
         return LogFindWorst<PidEntry>(pidSystemTable[id].sort(uid, pid, len));
     }
     LogFindWorst<TagEntry> sortTags(uid_t uid, pid_t pid, size_t len, log_id) {
@@ -551,21 +599,31 @@
     }
 
     // fast track current value by id only
-    size_t sizes(log_id_t id) const { return mSizes[id]; }
-    size_t elements(log_id_t id) const { return mElements[id]; }
+    size_t sizes(log_id_t id) const {
+        return mSizes[id];
+    }
+    size_t elements(log_id_t id) const {
+        return mElements[id];
+    }
     size_t realElements(log_id_t id) const {
         return mElements[id] - mDroppedElements[id];
     }
-    size_t sizesTotal(log_id_t id) const { return mSizesTotal[id]; }
-    size_t elementsTotal(log_id_t id) const { return mElementsTotal[id]; }
-    static size_t sizesTotal() { return SizesTotal; }
+    size_t sizesTotal(log_id_t id) const {
+        return mSizesTotal[id];
+    }
+    size_t elementsTotal(log_id_t id) const {
+        return mElementsTotal[id];
+    }
+    static size_t sizesTotal() {
+        return SizesTotal;
+    }
 
     std::string format(uid_t uid, pid_t pid, unsigned int logMask) const;
 
     // helper (must be locked directly or implicitly by mLogElementsLock)
-    const char *pidToName(pid_t pid) const;
+    const char* pidToName(pid_t pid) const;
     uid_t pidToUid(pid_t pid);
-    const char *uidToName(uid_t uid) const;
+    const char* uidToName(uid_t uid) const;
 };
 
-#endif // _LOGD_LOG_STATISTICS_H__
+#endif  // _LOGD_LOG_STATISTICS_H__
diff --git a/logd/LogTags.cpp b/logd/LogTags.cpp
index 64aa219..67649b1 100644
--- a/logd/LogTags.cpp
+++ b/logd/LogTags.cpp
@@ -50,11 +50,13 @@
     if (!comment) return AID_ROOT;
 
     if (*comment == '#') ++comment;
-    while ((comment < endp) && (*comment != '\n') && isspace(*comment)) ++comment;
+    while ((comment < endp) && (*comment != '\n') && isspace(*comment))
+        ++comment;
     static const char uid_str[] = "uid=";
     if (((comment + strlen(uid_str)) >= endp) ||
-            fastcmp<strncmp>(comment, uid_str, strlen(uid_str)) ||
-            !isdigit(comment[strlen(uid_str)])) return AID_ROOT;
+        fastcmp<strncmp>(comment, uid_str, strlen(uid_str)) ||
+        !isdigit(comment[strlen(uid_str)]))
+        return AID_ROOT;
     char* cp;
     unsigned long Uid = strtoul(comment + 4, &cp, 10);
     if ((cp > endp) || (Uid >= INT_MAX)) return AID_ROOT;
@@ -86,34 +88,32 @@
         }
 
         // dump what we already know back into the file?
-        fd = TEMP_FAILURE_RETRY(open(filename,
-                                     O_WRONLY | O_TRUNC | O_CLOEXEC |
-                                     O_NOFOLLOW | O_BINARY));
+        fd = TEMP_FAILURE_RETRY(open(
+            filename, O_WRONLY | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY));
         if (fd >= 0) {
             time_t now = time(NULL);
             struct tm tm;
             localtime_r(&now, &tm);
             char timebuf[20];
-            size_t len = strftime(timebuf, sizeof(timebuf),
-                                  "%Y-%m-%d %H:%M:%S", &tm);
+            size_t len =
+                strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", &tm);
             android::base::WriteStringToFd(
                 android::base::StringPrintf(
                     "# Rebuilt %.20s, content owned by logd\n", timebuf),
                 fd);
             for (const auto& it : tag2total) {
-                android::base::WriteStringToFd(formatEntry_locked(it.first,
-                                                                  AID_ROOT),
-                                               fd);
+                android::base::WriteStringToFd(
+                    formatEntry_locked(it.first, AID_ROOT), fd);
             }
             TEMP_FAILURE_RETRY(close(fd));
         }
     }
 
     if (warn) {
-        android::prdebug(((fd < 0) ?
-                              "%s failed to rebuild" :
-                              "%s missing, damaged or truncated; rebuilt"),
-                         filename);
+        android::prdebug(
+            ((fd < 0) ? "%s failed to rebuild"
+                      : "%s missing, damaged or truncated; rebuilt"),
+            filename);
     }
 
     if (fd >= 0) {
@@ -126,10 +126,9 @@
     return true;
 }
 
-void LogTags::AddEventLogTags(uint32_t tag, uid_t uid,
-                              const std::string& Name,
-                              const std::string& Format,
-                              const char* source, bool warn) {
+void LogTags::AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
+                              const std::string& Format, const char* source,
+                              bool warn) {
     std::string Key = Name;
     if (Format.length()) Key += "+" + Format;
 
@@ -178,8 +177,8 @@
         WritePersistEventLogTags(tag, uid, source);
     } else if (warn && !newOne && source) {
         // For the files, we want to report dupes.
-        android::prdebug("Multiple tag %" PRIu32 " %s %s %s", tag,
-            Name.c_str(), Format.c_str(), source);
+        android::prdebug("Multiple tag %" PRIu32 " %s %s %s", tag, Name.c_str(),
+                         Format.c_str(), source);
     }
 }
 
@@ -193,7 +192,7 @@
     }
     std::string content;
     if (android::base::ReadFileToString(filename, &content)) {
-        char* cp = (char*) content.c_str();
+        char* cp = (char*)content.c_str();
         char* endp = cp + content.length();
 
         {
@@ -228,16 +227,19 @@
                     std::string Name(name, cp - name);
 #ifdef ALLOW_NOISY_LOGGING_OF_PROBLEM_WITH_LOTS_OF_TECHNICAL_DEBT
                     static const size_t maximum_official_tag_name_size = 24;
-                    if (warn && (Name.length() > maximum_official_tag_name_size)) {
-                       android::prdebug("tag name too long %s", Name.c_str());
+                    if (warn &&
+                        (Name.length() > maximum_official_tag_name_size)) {
+                        android::prdebug("tag name too long %s", Name.c_str());
                     }
 #endif
-                    if (hasAlpha && ((cp >= endp) || (*cp == '#') || isspace(*cp))) {
+                    if (hasAlpha &&
+                        ((cp >= endp) || (*cp == '#') || isspace(*cp))) {
                         if (Tag > emptyTag) {
                             if (*cp != '\n') lineStart = NULL;
                             continue;
                         }
-                        while ((cp < endp) && (*cp != '\n') && isspace(*cp)) ++cp;
+                        while ((cp < endp) && (*cp != '\n') && isspace(*cp))
+                            ++cp;
                         const char* format = cp;
                         uid_t uid = AID_ROOT;
                         while ((cp < endp) && (*cp != '\n')) {
@@ -263,7 +265,9 @@
                         }
                         lineStart = NULL;
                     }
-                } else if (!isspace(*cp)) break;
+                } else if (!isspace(*cp)) {
+                    break;
+                }
             }
             cp++;
         }
@@ -273,8 +277,7 @@
 }
 
 // Extract a 4-byte value from a byte stream.
-static inline uint32_t get4LE(const char* msg)
-{
+static inline uint32_t get4LE(const char* msg) {
     const uint8_t* src = reinterpret_cast<const uint8_t*>(msg);
     return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
@@ -284,8 +287,8 @@
 // database with any found.
 void LogTags::ReadPersistEventLogTags() {
     struct logger_list* logger_list = android_logger_list_alloc(
-        ANDROID_LOG_RDONLY | ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK,
-        0, (pid_t)0);
+        ANDROID_LOG_RDONLY | ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK, 0,
+        (pid_t)0);
     if (!logger_list) return;
 
     struct logger* e = android_logger_open(logger_list, LOG_ID_EVENTS);
@@ -305,8 +308,9 @@
         if (log_msg.entry.len <= sizeof(uint32_t)) continue;
         uint32_t Tag = get4LE(msg);
         if (Tag != TAG_DEF_LOG_TAG) continue;
-        uid_t uid = (log_msg.entry.hdr_size >= sizeof(logger_entry_v4)) ?
-            log_msg.entry.uid : AID_ROOT;
+        uid_t uid = (log_msg.entry.hdr_size >= sizeof(logger_entry_v4))
+                        ? log_msg.entry.uid
+                        : AID_ROOT;
 
         std::string Name;
         std::string Format;
@@ -433,8 +437,7 @@
 // writer lock.  We use this call to invent a new deterministically
 // random tag, unique is cleared if no conflicts.  If format is NULL,
 // we are in readonly mode.
-uint32_t LogTags::nameToTag_locked(const std::string& name,
-                                   const char* format,
+uint32_t LogTags::nameToTag_locked(const std::string& name, const char* format,
                                    bool& unique) {
     key2tag_const_iterator ik;
 
@@ -462,7 +465,7 @@
     size_t Hash = key2tag.hash_function()(Key);
     uint32_t Tag = Hash;
     // This sets an upper limit on the conflics we are allowed to deal with.
-    for (unsigned i = 0; i < 256; ) {
+    for (unsigned i = 0; i < 256;) {
         tag2name_const_iterator it = tag2name.find(Tag);
         if (it == tag2name.end()) return Tag;
         std::string localKey(it->second);
@@ -471,15 +474,14 @@
             localKey += "+" + iform->second;
         }
         unique = !!it->second.compare(localKey);
-        if (!unique) return Tag; // unlikely except in a race
+        if (!unique) return Tag;  // unlikely except in a race
 
         ++i;
         // Algorithm to convert hash to next tag
         if (i < 32) {
             Tag = (Hash >> i);
             // size_t is 32 bits, or upper word zero, rotate
-            if ((sizeof(Hash) <= 4) ||
-                    ((Hash & (uint64_t(-1LL) << 32)) == 0)) {
+            if ((sizeof(Hash) <= 4) || ((Hash & (uint64_t(-1LL) << 32)) == 0)) {
                 Tag |= Hash << (32 - i);
             }
         } else {
@@ -501,7 +503,7 @@
     android::RWLock::AutoRLock readLock(rwlock);
 
     tag2total_const_iterator itot = tag2total.find(tag);
-    if (itot == tag2total.end()) return; // source is a static entry
+    if (itot == tag2total.end()) return;  // source is a static entry
 
     size_t lastTotal = itot->second;
 
@@ -525,7 +527,7 @@
     __android_log_event_list ctx(TAG_DEF_LOG_TAG);
     ctx << tag << Name << Format;
     std::string buffer(ctx);
-    if (buffer.length() <= 0) return; // unlikely
+    if (buffer.length() <= 0) return;  // unlikely
 
     /*
      *  struct {
@@ -562,18 +564,17 @@
 
     android_pmsg_log_header_t pmsgHeader = {
         .magic = LOGGER_MAGIC,
-        .len = (uint16_t)(sizeof(pmsgHeader) + sizeof(header) +
-                          sizeof(outTag) + buffer.length()),
+        .len = (uint16_t)(sizeof(pmsgHeader) + sizeof(header) + sizeof(outTag) +
+                          buffer.length()),
         .uid = (uint16_t)AID_ROOT,
         .pid = (uint16_t)getpid(),
     };
 
-    struct iovec Vec[] = {
-        { (unsigned char*)&pmsgHeader, sizeof(pmsgHeader) },
-        { (unsigned char*)&header, sizeof(header) },
-        { (unsigned char*)&outTag, sizeof(outTag) },
-        { (unsigned char*)const_cast<char*>(buffer.data()), buffer.length() }
-    };
+    struct iovec Vec[] = { { (unsigned char*)&pmsgHeader, sizeof(pmsgHeader) },
+                           { (unsigned char*)&header, sizeof(header) },
+                           { (unsigned char*)&outTag, sizeof(outTag) },
+                           { (unsigned char*)const_cast<char*>(buffer.data()),
+                             buffer.length() } };
 
     tag2uid_const_iterator ut = tag2uid.find(tag);
     if (ut == tag2uid.end()) {
@@ -582,7 +583,7 @@
         pmsgHeader.uid = (uint16_t)uid;
         TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
     } else {
-        for (auto &it : ut->second) {
+        for (auto& it : ut->second) {
             pmsgHeader.uid = (uint16_t)it;
             TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
         }
@@ -590,8 +591,8 @@
 }
 
 void LogTags::WriteDynamicEventLogTags(uint32_t tag, uid_t uid) {
-    static const int mode = O_WRONLY | O_APPEND |
-                            O_CLOEXEC | O_NOFOLLOW | O_BINARY;
+    static const int mode =
+        O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
 
     int fd = openFile(dynamic_event_log_tags, mode, true);
     if (fd < 0) return;
@@ -612,8 +613,8 @@
 }
 
 void LogTags::WriteDebugEventLogTags(uint32_t tag, uid_t uid) {
-    static const int mode = O_WRONLY | O_APPEND |
-                            O_CLOEXEC | O_NOFOLLOW | O_BINARY;
+    static const int mode =
+        O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
 
     static bool one = true;
     int fd = openFile(debug_event_log_tags, mode, one);
@@ -636,16 +637,14 @@
 }
 
 // How we maintain some runtime or reboot stickiness
-void LogTags::WritePersistEventLogTags(uint32_t tag,
-                                       uid_t uid, const char* source) {
+void LogTags::WritePersistEventLogTags(uint32_t tag, uid_t uid,
+                                       const char* source) {
     // very unlikely
     bool etc = source && !strcmp(source, system_event_log_tags);
     if (etc) return;
 
     bool dynamic = source && !strcmp(source, dynamic_event_log_tags);
-    bool debug = (!dynamic &&
-                  source &&
-                  !strcmp(source, debug_event_log_tags)) ||
+    bool debug = (!dynamic && source && !strcmp(source, debug_event_log_tags)) ||
                  !__android_log_is_debuggable();
 
     WritePmsgEventLogTags(tag, uid);
@@ -658,7 +657,7 @@
         if (itot != tag2total.end()) lastTotal = itot->second;
     }
 
-    if (lastTotal == 0) { // denotes first time for this one
+    if (lastTotal == 0) {  // denotes first time for this one
         if (!dynamic || !RebuildFileEventLogTags(dynamic_event_log_tags)) {
             WriteDynamicEventLogTags(tag, uid);
         }
@@ -694,9 +693,9 @@
             tag2uid_const_iterator ut = tag2uid.find(Tag);
             if (updateUid) {
                 if ((ut != tag2uid.end()) &&
-                        (ut->second.find(uid) == ut->second.end())) {
-                    unique = write; // write passthrough to update uid counts
-                    if (!write) Tag = emptyTag; // deny read access
+                    (ut->second.find(uid) == ut->second.end())) {
+                    unique = write;  // write passthrough to update uid counts
+                    if (!write) Tag = emptyTag;  // deny read access
                 }
             } else {
                 unique = write && (ut != tag2uid.end());
@@ -705,7 +704,7 @@
     }
 
     if (Tag == emptyTag) return Tag;
-    WritePmsgEventLogTags(Tag, uid); // record references periodically
+    WritePmsgEventLogTags(Tag, uid);  // record references periodically
     if (!unique) return Tag;
 
     bool updateWrite = false;
@@ -728,7 +727,9 @@
                 if (updateUid) {
                     // Add it to the uid list
                     if ((ut == tag2uid.end()) ||
-                        (ut->second.find(uid) != ut->second.end())) return Tag;
+                        (ut->second.find(uid) != ut->second.end())) {
+                        return Tag;
+                    }
                     const_cast<uid_list&>(ut->second).emplace(uid);
                     updateWrite = true;
                 } else {
@@ -791,8 +792,7 @@
     return Tag;
 }
 
-std::string LogTags::formatEntry(uint32_t tag, uid_t uid,
-                                 const char* name,
+std::string LogTags::formatEntry(uint32_t tag, uid_t uid, const char* name,
                                  const char* format) {
     if (!format || !format[0]) {
         return android::base::StringPrintf("%" PRIu32 "\t%s\n", tag, name);
@@ -802,9 +802,8 @@
     if (len > strlen(tabs)) len = strlen(tabs);
     std::string Uid;
     if (uid != AID_ROOT) Uid = android::base::StringPrintf(" # uid=%u", uid);
-    return android::base::StringPrintf("%" PRIu32 "\t%s%s\t%s%s\n",
-                                       tag, name, &tabs[len], format,
-                                       Uid.c_str());
+    return android::base::StringPrintf("%" PRIu32 "\t%s%s\t%s%s\n", tag, name,
+                                       &tabs[len], format, Uid.c_str());
 }
 
 std::string LogTags::formatEntry_locked(uint32_t tag, uid_t uid,
@@ -830,7 +829,7 @@
 
     // Show all, one for each registered uid (we are group root)
     std::string ret;
-    for (auto &it : ut->second) {
+    for (auto& it : ut->second) {
         ret += formatEntry(tag, it, name, format);
     }
     return ret;
@@ -841,8 +840,8 @@
     return formatEntry_locked(tag, uid);
 }
 
-std::string LogTags::formatGetEventTag(uid_t uid,
-                                       const char* name, const char* format) {
+std::string LogTags::formatGetEventTag(uid_t uid, const char* name,
+                                       const char* format) {
     bool all = name && (name[0] == '*') && !name[1];
     bool list = !name || all;
     std::string ret;
@@ -864,7 +863,7 @@
             // first uid in list so as to manufacture an accurate reference
             tag2uid_const_iterator ut = tag2uid.find(tag);
             if ((ut != tag2uid.end()) &&
-                 (ut->second.begin() != ut->second.end())) {
+                (ut->second.begin() != ut->second.end())) {
                 uid = *(ut->second.begin());
             }
         }
diff --git a/logd/LogTags.h b/logd/LogTags.h
index 4457c46..203318d 100644
--- a/logd/LogTags.h
+++ b/logd/LogTags.h
@@ -17,9 +17,9 @@
 #ifndef _LOGD_LOG_TAGS_H__
 #define _LOGD_LOG_TAGS_H__
 
+#include <string>
 #include <unordered_map>
 #include <unordered_set>
-#include <string>
 
 #include <utils/RWLock.h>
 
@@ -35,64 +35,70 @@
 
     // key is Name + "+" + Format
     std::unordered_map<std::string, uint32_t> key2tag;
-    typedef std::unordered_map<std::string, uint32_t>::const_iterator key2tag_const_iterator;
+    typedef std::unordered_map<std::string, uint32_t>::const_iterator
+        key2tag_const_iterator;
 
     // Allows us to manage access permissions based on uid registrants
     // Global entries are specifically erased.
     typedef std::unordered_set<uid_t> uid_list;
     std::unordered_map<uint32_t, uid_list> tag2uid;
-    typedef std::unordered_map<uint32_t, uid_list>::const_iterator tag2uid_const_iterator;
+    typedef std::unordered_map<uint32_t, uid_list>::const_iterator
+        tag2uid_const_iterator;
 
     std::unordered_map<uint32_t, std::string> tag2name;
-    typedef std::unordered_map<uint32_t, std::string>::const_iterator tag2name_const_iterator;
+    typedef std::unordered_map<uint32_t, std::string>::const_iterator
+        tag2name_const_iterator;
 
     std::unordered_map<uint32_t, std::string> tag2format;
-    typedef std::unordered_map<uint32_t, std::string>::const_iterator tag2format_const_iterator;
+    typedef std::unordered_map<uint32_t, std::string>::const_iterator
+        tag2format_const_iterator;
 
-    static const size_t max_per_uid = 256; // Put a cap on the tags per uid
+    static const size_t max_per_uid = 256;  // Put a cap on the tags per uid
     std::unordered_map<uid_t, size_t> uid2count;
-    typedef std::unordered_map<uid_t, size_t>::const_iterator uid2count_const_iterator;
+    typedef std::unordered_map<uid_t, size_t>::const_iterator
+        uid2count_const_iterator;
 
     // Dynamic entries are assigned
     std::unordered_map<uint32_t, size_t> tag2total;
-    typedef std::unordered_map<uint32_t, size_t>::const_iterator tag2total_const_iterator;
+    typedef std::unordered_map<uint32_t, size_t>::const_iterator
+        tag2total_const_iterator;
 
     // emplace unique tag
     uint32_t nameToTag(uid_t uid, const char* name, const char* format);
     // find unique or associated tag
-    uint32_t nameToTag_locked(const std::string& name, const char* format, bool &unique);
+    uint32_t nameToTag_locked(const std::string& name, const char* format,
+                              bool& unique);
 
     // Record expected file watermarks to detect corruption.
     std::unordered_map<std::string, size_t> file2watermark;
-    typedef std::unordered_map<std::string, size_t>::const_iterator file2watermark_const_iterator;
+    typedef std::unordered_map<std::string, size_t>::const_iterator
+        file2watermark_const_iterator;
 
     void ReadPersistEventLogTags();
 
     // format helpers
     // format a single entry, does not need object data
-    static std::string formatEntry(uint32_t tag, uid_t uid,
-                                   const char* name, const char* format);
+    static std::string formatEntry(uint32_t tag, uid_t uid, const char* name,
+                                   const char* format);
     // caller locks, database lookup, authenticate against uid
     std::string formatEntry_locked(uint32_t tag, uid_t uid,
                                    bool authenticate = true);
 
     bool RebuildFileEventLogTags(const char* filename, bool warn = true);
 
-    void AddEventLogTags(uint32_t tag, uid_t uid,
-                         const std::string& Name, const std::string& Format,
-                         const char* source = NULL, bool warn = false);
+    void AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
+                         const std::string& Format, const char* source = NULL,
+                         bool warn = false);
 
     void WriteDynamicEventLogTags(uint32_t tag, uid_t uid);
     void WriteDebugEventLogTags(uint32_t tag, uid_t uid);
     // push tag details to persistent storage
-    void WritePersistEventLogTags(uint32_t tag,
-                                  uid_t uid = AID_ROOT,
+    void WritePersistEventLogTags(uint32_t tag, uid_t uid = AID_ROOT,
                                   const char* source = NULL);
 
     static const uint32_t emptyTag = uint32_t(-1);
 
-public:
-
+   public:
     static const char system_event_log_tags[];
     static const char dynamic_event_log_tags[];
     // Only for userdebug and eng
@@ -111,9 +117,8 @@
     uint32_t nameToTag(const char* name) const;
 
     // emplace tag if necessary, provide event-log-tag formated output in string
-    std::string formatGetEventTag(uid_t uid,
-                                  const char* name,
+    std::string formatGetEventTag(uid_t uid, const char* name,
                                   const char* format);
 };
 
-#endif // _LOGD_LOG_TAGS_H__
+#endif  // _LOGD_LOG_TAGS_H__
diff --git a/logd/LogTimes.cpp b/logd/LogTimes.cpp
index 2a04880..bdaeb75 100644
--- a/logd/LogTimes.cpp
+++ b/logd/LogTimes.cpp
@@ -19,30 +19,30 @@
 
 #include "FlushCommand.h"
 #include "LogBuffer.h"
-#include "LogTimes.h"
 #include "LogReader.h"
+#include "LogTimes.h"
 
 pthread_mutex_t LogTimeEntry::timesLock = PTHREAD_MUTEX_INITIALIZER;
 
-LogTimeEntry::LogTimeEntry(LogReader &reader, SocketClient *client,
+LogTimeEntry::LogTimeEntry(LogReader& reader, SocketClient* client,
                            bool nonBlock, unsigned long tail,
-                           unsigned int logMask, pid_t pid,
-                           uint64_t start, uint64_t timeout) :
-        mRefCount(1),
-        mRelease(false),
-        mError(false),
-        threadRunning(false),
-        leadingDropped(false),
-        mReader(reader),
-        mLogMask(logMask),
-        mPid(pid),
-        mCount(0),
-        mTail(tail),
-        mIndex(0),
-        mClient(client),
-        mStart(start),
-        mNonBlock(nonBlock),
-        mEnd(LogBufferElement::getCurrentSequence()) {
+                           unsigned int logMask, pid_t pid, uint64_t start,
+                           uint64_t timeout)
+    : mRefCount(1),
+      mRelease(false),
+      mError(false),
+      threadRunning(false),
+      leadingDropped(false),
+      mReader(reader),
+      mLogMask(logMask),
+      mPid(pid),
+      mCount(0),
+      mTail(tail),
+      mIndex(0),
+      mClient(client),
+      mStart(start),
+      mNonBlock(nonBlock),
+      mEnd(LogBufferElement::getCurrentSequence()) {
     mTimeout.tv_sec = timeout / NS_PER_SEC;
     mTimeout.tv_nsec = timeout % NS_PER_SEC;
     pthread_cond_init(&threadTriggeredCondition, NULL);
@@ -56,8 +56,8 @@
 
     if (!pthread_attr_init(&attr)) {
         if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
-            if (!pthread_create(&mThread, &attr,
-                                LogTimeEntry::threadStart, this)) {
+            if (!pthread_create(&mThread, &attr, LogTimeEntry::threadStart,
+                                this)) {
                 pthread_attr_destroy(&attr);
                 return;
             }
@@ -71,8 +71,8 @@
     decRef_Locked();
 }
 
-void LogTimeEntry::threadStop(void *obj) {
-    LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj);
+void LogTimeEntry::threadStop(void* obj) {
+    LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
 
     lock();
 
@@ -80,14 +80,14 @@
         me->error_Locked();
     }
 
-    SocketClient *client = me->mClient;
+    SocketClient* client = me->mClient;
 
     if (me->isError_Locked()) {
-        LogReader &reader = me->mReader;
-        LastLogTimes &times = reader.logbuf().mTimes;
+        LogReader& reader = me->mReader;
+        LastLogTimes& times = reader.logbuf().mTimes;
 
         LastLogTimes::iterator it = times.begin();
-        while(it != times.end()) {
+        while (it != times.end()) {
             if (*it == me) {
                 times.erase(it);
                 me->release_nodelete_Locked();
@@ -110,20 +110,20 @@
     unlock();
 }
 
-void *LogTimeEntry::threadStart(void *obj) {
+void* LogTimeEntry::threadStart(void* obj) {
     prctl(PR_SET_NAME, "logd.reader.per");
 
-    LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj);
+    LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
 
     pthread_cleanup_push(threadStop, obj);
 
-    SocketClient *client = me->mClient;
+    SocketClient* client = me->mClient;
     if (!client) {
         me->error();
         return NULL;
     }
 
-    LogBuffer &logbuf = me->mReader.logbuf();
+    LogBuffer& logbuf = me->mReader.logbuf();
 
     bool privileged = FlushCommand::hasReadLogs(client);
     bool security = FlushCommand::hasSecurityLogs(client);
@@ -135,11 +135,9 @@
     uint64_t start = me->mStart;
 
     while (me->threadRunning && !me->isError_Locked()) {
-
         if (me->mTimeout.tv_sec || me->mTimeout.tv_nsec) {
             if (pthread_cond_timedwait(&me->threadTriggeredCondition,
-                                       &timesLock,
-                                       &me->mTimeout) == ETIMEDOUT) {
+                                       &timesLock, &me->mTimeout) == ETIMEDOUT) {
                 me->mTimeout.tv_sec = 0;
                 me->mTimeout.tv_nsec = 0;
             }
@@ -151,10 +149,12 @@
         unlock();
 
         if (me->mTail) {
-            logbuf.flushTo(client, start, privileged, security, FilterFirstPass, me);
+            logbuf.flushTo(client, start, privileged, security, FilterFirstPass,
+                           me);
             me->leadingDropped = true;
         }
-        start = logbuf.flushTo(client, start, privileged, security, FilterSecondPass, me);
+        start = logbuf.flushTo(client, start, privileged, security,
+                               FilterSecondPass, me);
 
         lock();
 
@@ -184,8 +184,8 @@
 }
 
 // A first pass to count the number of elements
-int LogTimeEntry::FilterFirstPass(const LogBufferElement *element, void *obj) {
-    LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj);
+int LogTimeEntry::FilterFirstPass(const LogBufferElement* element, void* obj) {
+    LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
 
     LogTimeEntry::lock();
 
@@ -201,8 +201,8 @@
         me->mStart = element->getSequence();
     }
 
-    if ((!me->mPid || (me->mPid == element->getPid()))
-            && (me->isWatching(element->getLogId()))) {
+    if ((!me->mPid || (me->mPid == element->getPid())) &&
+        (me->isWatching(element->getLogId()))) {
         ++me->mCount;
     }
 
@@ -212,8 +212,8 @@
 }
 
 // A second pass to send the selected elements
-int LogTimeEntry::FilterSecondPass(const LogBufferElement *element, void *obj) {
-    LogTimeEntry *me = reinterpret_cast<LogTimeEntry *>(obj);
+int LogTimeEntry::FilterSecondPass(const LogBufferElement* element, void* obj) {
+    LogTimeEntry* me = reinterpret_cast<LogTimeEntry*>(obj);
 
     LogTimeEntry::lock();
 
@@ -267,7 +267,7 @@
         LogTimeEntry::unlock();
         return true;
     }
-    // FALLTHRU
+// FALLTHRU
 
 skip:
     LogTimeEntry::unlock();
@@ -279,7 +279,7 @@
 }
 
 void LogTimeEntry::cleanSkip_Locked(void) {
-    for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t) (i + 1)) {
+    for (log_id_t i = LOG_ID_MIN; i < LOG_ID_MAX; i = (log_id_t)(i + 1)) {
         skipAhead[i] = 0;
     }
 }
diff --git a/logd/LogTimes.h b/logd/LogTimes.h
index 12df994..23fdf4e 100644
--- a/logd/LogTimes.h
+++ b/logd/LogTimes.h
@@ -18,8 +18,8 @@
 #define _LOGD_LOG_TIMES_H__
 
 #include <pthread.h>
-#include <time.h>
 #include <sys/types.h>
+#include <time.h>
 
 #include <list>
 
@@ -38,9 +38,9 @@
     bool leadingDropped;
     pthread_cond_t threadTriggeredCondition;
     pthread_t mThread;
-    LogReader &mReader;
-    static void *threadStart(void *me);
-    static void threadStop(void *me);
+    LogReader& mReader;
+    static void* threadStart(void* me);
+    static void threadStop(void* me);
     const unsigned int mLogMask;
     const pid_t mPid;
     unsigned int skipAhead[LOG_ID_MAX];
@@ -48,20 +48,24 @@
     unsigned long mTail;
     unsigned long mIndex;
 
-public:
-    LogTimeEntry(LogReader &reader, SocketClient *client, bool nonBlock,
+   public:
+    LogTimeEntry(LogReader& reader, SocketClient* client, bool nonBlock,
                  unsigned long tail, unsigned int logMask, pid_t pid,
                  uint64_t start, uint64_t timeout);
 
-    SocketClient *mClient;
+    SocketClient* mClient;
     uint64_t mStart;
     struct timespec mTimeout;
     const bool mNonBlock;
-    const uint64_t mEnd; // only relevant if mNonBlock
+    const uint64_t mEnd;  // only relevant if mNonBlock
 
     // Protect List manipulations
-    static void lock(void) { pthread_mutex_lock(&timesLock); }
-    static void unlock(void) { pthread_mutex_unlock(&timesLock); }
+    static void lock(void) {
+        pthread_mutex_lock(&timesLock);
+    }
+    static void unlock(void) {
+        pthread_mutex_unlock(&timesLock);
+    }
 
     void startReader_Locked(void);
 
@@ -72,7 +76,9 @@
         pthread_cond_signal(&threadTriggeredCondition);
     }
 
-    void triggerSkip_Locked(log_id_t id, unsigned int skip) { skipAhead[id] = skip; }
+    void triggerSkip_Locked(log_id_t id, unsigned int skip) {
+        skipAhead[id] = skip;
+    }
     void cleanSkip_Locked(void);
 
     // These called after LogTimeEntry removed from list, lock implicitly held
@@ -93,16 +99,28 @@
     }
 
     // Called to mark socket in jeopardy
-    void error_Locked(void) { mError = true; }
-    void error(void) { lock(); error_Locked(); unlock(); }
+    void error_Locked(void) {
+        mError = true;
+    }
+    void error(void) {
+        lock();
+        error_Locked();
+        unlock();
+    }
 
-    bool isError_Locked(void) const { return mRelease || mError; }
+    bool isError_Locked(void) const {
+        return mRelease || mError;
+    }
 
     // Mark Used
     //  Locking implied, grabbed when protection around loop iteration
-    void incRef_Locked(void) { ++mRefCount; }
+    void incRef_Locked(void) {
+        ++mRefCount;
+    }
 
-    bool owned_Locked(void) const { return mRefCount != 0; }
+    bool owned_Locked(void) const {
+        return mRefCount != 0;
+    }
 
     void decRef_Locked(void) {
         if ((mRefCount && --mRefCount) || !mRelease || threadRunning) {
@@ -111,12 +129,14 @@
         // No one else is holding a reference to this
         delete this;
     }
-    bool isWatching(log_id_t id) { return (mLogMask & (1<<id)) != 0; }
+    bool isWatching(log_id_t id) {
+        return (mLogMask & (1 << id)) != 0;
+    }
     // flushTo filter callbacks
-    static int FilterFirstPass(const LogBufferElement *element, void *me);
-    static int FilterSecondPass(const LogBufferElement *element, void *me);
+    static int FilterFirstPass(const LogBufferElement* element, void* me);
+    static int FilterSecondPass(const LogBufferElement* element, void* me);
 };
 
-typedef std::list<LogTimeEntry *> LastLogTimes;
+typedef std::list<LogTimeEntry*> LastLogTimes;
 
-#endif // _LOGD_LOG_TIMES_H__
+#endif  // _LOGD_LOG_TIMES_H__
diff --git a/logd/LogUtils.h b/logd/LogUtils.h
index f044b27..93d2a79 100644
--- a/logd/LogUtils.h
+++ b/logd/LogUtils.h
@@ -20,9 +20,9 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 
-#include <utils/FastStrcmp.h>
 #include <private/android_logger.h>
 #include <sysutils/SocketClient.h>
+#include <utils/FastStrcmp.h>
 
 // Hijack this header as a common include file used by most all sources
 // to report some utilities defined here and there.
@@ -30,31 +30,30 @@
 namespace android {
 
 // Furnished in main.cpp. Caller must own and free returned value
-char *uidToName(uid_t uid);
-void prdebug(const char *fmt, ...) __printflike(1, 2);
+char* uidToName(uid_t uid);
+void prdebug(const char* fmt, ...) __printflike(1, 2);
 
 // Furnished in LogStatistics.cpp.
 size_t sizesTotal();
 // Caller must own and free returned value
-char *pidToName(pid_t pid);
-char *tidToName(pid_t tid);
+char* pidToName(pid_t pid);
+char* tidToName(pid_t tid);
 
 // Furnished in LogTags.cpp. Thread safe.
-const char *tagToName(uint32_t tag);
+const char* tagToName(uint32_t tag);
 void ReReadEventLogTags();
 
 // Furnished by LogKlog.cpp.
 const char* strnstr(const char* s, size_t len, const char* needle);
-
 }
 
 // Furnished in LogCommand.cpp
 bool clientHasLogCredentials(uid_t uid, gid_t gid, pid_t pid);
-bool clientHasLogCredentials(SocketClient *cli);
+bool clientHasLogCredentials(SocketClient* cli);
 
 static inline bool worstUidEnabledForLogid(log_id_t id) {
     return (id == LOG_ID_MAIN) || (id == LOG_ID_SYSTEM) ||
-            (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS);
+           (id == LOG_ID_RADIO) || (id == LOG_ID_EVENTS);
 }
 
-#endif // _LOGD_LOG_UTILS_H__
+#endif  // _LOGD_LOG_UTILS_H__
diff --git a/logd/LogWhiteBlackList.cpp b/logd/LogWhiteBlackList.cpp
index ae933b5..4b8b080 100644
--- a/logd/LogWhiteBlackList.cpp
+++ b/logd/LogWhiteBlackList.cpp
@@ -64,7 +64,7 @@
     }
 }
 
-int PruneList::init(const char *str) {
+int PruneList::init(const char* str) {
     mWorstUidEnabled = true;
     mWorstPidOfSystemEnabled = true;
     PruneCollection::iterator it;
@@ -113,13 +113,13 @@
     mWorstUidEnabled = false;
     mWorstPidOfSystemEnabled = false;
 
-    for(str = filter.c_str(); *str; ++str) {
+    for (str = filter.c_str(); *str; ++str) {
         if (isspace(*str)) {
             continue;
         }
 
-        PruneCollection *list;
-        if ((*str == '~') || (*str == '!')) { // ~ supported, ! undocumented
+        PruneCollection* list;
+        if ((*str == '~') || (*str == '!')) {  // ~ supported, ! undocumented
             ++str;
             // special case, translates to worst UID at priority in blacklist
             if (*str == '!') {
@@ -184,7 +184,7 @@
         // insert sequentially into list
         PruneCollection::iterator it = list->begin();
         while (it != list->end()) {
-            Prune &p = *it;
+            Prune& p = *it;
             int m = uid - p.mUid;
             if (m == 0) {
                 if (p.mPid == p.pid_all) {
@@ -198,14 +198,14 @@
             }
             if (m <= 0) {
                 if (m < 0) {
-                    list->insert(it, Prune(uid,pid));
+                    list->insert(it, Prune(uid, pid));
                 }
                 break;
             }
             ++it;
         }
         if (it == list->end()) {
-            list->push_back(Prune(uid,pid));
+            list->push_back(Prune(uid, pid));
         }
         if (!*str) {
             break;
@@ -217,7 +217,7 @@
 
 std::string PruneList::format() {
     static const char nice_format[] = " %s";
-    const char *fmt = nice_format + 1;
+    const char* fmt = nice_format + 1;
 
     std::string string;
 
@@ -250,7 +250,7 @@
 // If there is scaling issues, resort to a better algorithm than linear
 // based on these assumptions.
 
-bool PruneList::naughty(LogBufferElement *element) {
+bool PruneList::naughty(LogBufferElement* element) {
     PruneCollection::iterator it;
     for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
         if (!(*it).cmp(element)) {
@@ -260,7 +260,7 @@
     return false;
 }
 
-bool PruneList::nice(LogBufferElement *element) {
+bool PruneList::nice(LogBufferElement* element) {
     PruneCollection::iterator it;
     for (it = mNice.begin(); it != mNice.end(); ++it) {
         if (!(*it).cmp(element)) {
diff --git a/logd/LogWhiteBlackList.h b/logd/LogWhiteBlackList.h
index 8b8e02f..6e9893b 100644
--- a/logd/LogWhiteBlackList.h
+++ b/logd/LogWhiteBlackList.h
@@ -19,8 +19,8 @@
 
 #include <sys/types.h>
 
-#include <list>
 #include <string.h>
+#include <list>
 
 #include "LogBufferElement.h"
 
@@ -33,16 +33,22 @@
     const pid_t mPid;
     int cmp(uid_t uid, pid_t pid) const;
 
-public:
-    static const uid_t uid_all = (uid_t) -1;
-    static const pid_t pid_all = (pid_t) -1;
+   public:
+    static const uid_t uid_all = (uid_t)-1;
+    static const pid_t pid_all = (pid_t)-1;
 
     Prune(uid_t uid, pid_t pid);
 
-    uid_t getUid() const { return mUid; }
-    pid_t getPid() const { return mPid; }
+    uid_t getUid() const {
+        return mUid;
+    }
+    pid_t getPid() const {
+        return mPid;
+    }
 
-    int cmp(LogBufferElement *e) const { return cmp(e->getUid(), e->getPid()); }
+    int cmp(LogBufferElement* e) const {
+        return cmp(e->getUid(), e->getPid());
+    }
 
     std::string format();
 };
@@ -55,20 +61,28 @@
     bool mWorstUidEnabled;
     bool mWorstPidOfSystemEnabled;
 
-public:
+   public:
     PruneList();
     ~PruneList();
 
-    int init(const char *str);
+    int init(const char* str);
 
-    bool naughty(LogBufferElement *element);
-    bool naughty(void) { return !mNaughty.empty(); }
-    bool nice(LogBufferElement *element);
-    bool nice(void) { return !mNice.empty(); }
-    bool worstUidEnabled() const { return mWorstUidEnabled; }
-    bool worstPidOfSystemEnabled() const { return mWorstPidOfSystemEnabled; }
+    bool naughty(LogBufferElement* element);
+    bool naughty(void) {
+        return !mNaughty.empty();
+    }
+    bool nice(LogBufferElement* element);
+    bool nice(void) {
+        return !mNice.empty();
+    }
+    bool worstUidEnabled() const {
+        return mWorstUidEnabled;
+    }
+    bool worstPidOfSystemEnabled() const {
+        return mWorstPidOfSystemEnabled;
+    }
 
     std::string format();
 };
 
-#endif // _LOGD_LOG_WHITE_BLACK_LIST_H__
+#endif  // _LOGD_LOG_WHITE_BLACK_LIST_H__
diff --git a/logd/libaudit.c b/logd/libaudit.c
index 216f1a1..dfd56f2 100644
--- a/logd/libaudit.c
+++ b/logd/libaudit.c
@@ -31,8 +31,7 @@
  * @return
  *  This function returns 0 on success, else -errno.
  */
-static int get_ack(int fd)
-{
+static int get_ack(int fd) {
     int rc;
     struct audit_message rep;
 
@@ -48,7 +47,7 @@
 
     if (rep.nlh.nlmsg_type == NLMSG_ERROR) {
         audit_get_reply(fd, &rep, GET_REPLY_BLOCKING, 0);
-        rc = ((struct nlmsgerr *)rep.data)->error;
+        rc = ((struct nlmsgerr*)rep.data)->error;
         if (rc) {
             return -rc;
         }
@@ -70,8 +69,7 @@
  * @return
  *  This function returns a positive sequence number on success, else -errno.
  */
-static int audit_send(int fd, int type, const void *data, size_t size)
-{
+static int audit_send(int fd, int type, const void* data, size_t size) {
     int rc;
     static int16_t sequence = 0;
     struct audit_message req;
@@ -123,13 +121,13 @@
     /* While failing and its due to interrupts */
 
     rc = TEMP_FAILURE_RETRY(sendto(fd, &req, req.nlh.nlmsg_len, 0,
-                                   (struct sockaddr*) &addr, sizeof(addr)));
+                                   (struct sockaddr*)&addr, sizeof(addr)));
 
     /* Not all the bytes were sent */
     if (rc < 0) {
         rc = -errno;
         goto out;
-    } else if ((uint32_t) rc != req.nlh.nlmsg_len) {
+    } else if ((uint32_t)rc != req.nlh.nlmsg_len) {
         rc = -EPROTO;
         goto out;
     }
@@ -138,7 +136,7 @@
     rc = get_ack(fd);
 
     /* If the ack failed, return the error, else return the sequence number */
-    rc = (rc == 0) ? (int) sequence : rc;
+    rc = (rc == 0) ? (int)sequence : rc;
 
 out:
     /* Don't let sequence roll to negative */
@@ -149,8 +147,7 @@
     return rc;
 }
 
-int audit_setup(int fd, pid_t pid)
-{
+int audit_setup(int fd, pid_t pid) {
     int rc;
     struct audit_message rep;
     struct audit_status status;
@@ -186,8 +183,7 @@
     return 0;
 }
 
-int audit_rate_limit(int fd, unsigned rate_limit)
-{
+int audit_rate_limit(int fd, unsigned rate_limit) {
     int rc;
     struct audit_message rep;
     struct audit_status status;
@@ -207,13 +203,11 @@
     return 0;
 }
 
-int audit_open()
-{
+int audit_open() {
     return socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_AUDIT);
 }
 
-int audit_get_reply(int fd, struct audit_message *rep, reply_t block, int peek)
-{
+int audit_get_reply(int fd, struct audit_message* rep, reply_t block, int peek) {
     ssize_t len;
     int flags;
     int rc = 0;
@@ -235,7 +229,7 @@
      * however, can be returned.
      */
     len = TEMP_FAILURE_RETRY(recvfrom(fd, rep, sizeof(*rep), flags,
-                                      (struct sockaddr*) &nladdr, &nladdrlen));
+                                      (struct sockaddr*)&nladdr, &nladdrlen));
 
     /*
      * EAGAIN should be re-tried until success or another error manifests.
@@ -266,7 +260,6 @@
     return rc;
 }
 
-void audit_close(int fd)
-{
+void audit_close(int fd) {
     close(fd);
 }
diff --git a/logd/libaudit.h b/logd/libaudit.h
index 9865d43..a2afe47 100644
--- a/logd/libaudit.h
+++ b/logd/libaudit.h
@@ -25,17 +25,14 @@
 #include <sys/socket.h>
 #include <sys/types.h>
 
-#include <linux/netlink.h>
 #include <linux/audit.h>
+#include <linux/netlink.h>
 
 __BEGIN_DECLS
 
-#define MAX_AUDIT_MESSAGE_LENGTH    8970
+#define MAX_AUDIT_MESSAGE_LENGTH 8970
 
-typedef enum {
-    GET_REPLY_BLOCKING = 0,
-    GET_REPLY_NONBLOCKING
-} reply_t;
+typedef enum { GET_REPLY_BLOCKING = 0, GET_REPLY_NONBLOCKING } reply_t;
 
 /* type == AUDIT_SIGNAL_INFO */
 struct audit_sig_info {
@@ -46,7 +43,7 @@
 
 struct audit_message {
     struct nlmsghdr nlh;
-    char   data[MAX_AUDIT_MESSAGE_LENGTH];
+    char data[MAX_AUDIT_MESSAGE_LENGTH];
 };
 
 /**
@@ -78,7 +75,7 @@
  * @return
  *  This function returns 0 on success, else -errno.
  */
-extern int audit_get_reply(int fd, struct audit_message *rep, reply_t block,
+extern int audit_get_reply(int fd, struct audit_message* rep, reply_t block,
                            int peek);
 
 /**
@@ -105,7 +102,7 @@
 /* Guidelines to follow for dynamic rate_limit */
 #define AUDIT_RATE_LIMIT_DEFAULT 20        /* acceptable burst rate      */
 #define AUDIT_RATE_LIMIT_BURST_DURATION 10 /* number of seconds of burst */
-#define AUDIT_RATE_LIMIT_MAX     5         /* acceptable sustained rate  */
+#define AUDIT_RATE_LIMIT_MAX 5             /* acceptable sustained rate  */
 
 extern int audit_rate_limit(int fd, unsigned rate_limit);
 
diff --git a/logd/main.cpp b/logd/main.cpp
index 2551f2e..3334506 100644
--- a/logd/main.cpp
+++ b/logd/main.cpp
@@ -48,17 +48,15 @@
 #include <utils/threads.h>
 
 #include "CommandListener.h"
-#include "LogBuffer.h"
-#include "LogListener.h"
 #include "LogAudit.h"
+#include "LogBuffer.h"
 #include "LogKlog.h"
+#include "LogListener.h"
 #include "LogUtils.h"
 
-#define KMSG_PRIORITY(PRI)                            \
-    '<',                                              \
-    '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) / 10, \
-    '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) % 10, \
-    '>'
+#define KMSG_PRIORITY(PRI)                                 \
+    '<', '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) / 10, \
+        '0' + LOG_MAKEPRI(LOG_DAEMON, LOG_PRI(PRI)) % 10, '>'
 
 //
 // The service is designed to be run by init, it does not respond well
@@ -92,7 +90,8 @@
 static int drop_privs(bool klogd, bool auditd) {
     // Tricky, if ro.build.type is "eng" then this is true because of the
     // side effect that ro.debuggable == 1 as well, else it is false.
-    bool eng = __android_logger_property_get_bool("ro.build.type", BOOL_DEFAULT_FALSE);
+    bool eng =
+        __android_logger_property_get_bool("ro.build.type", BOOL_DEFAULT_FALSE);
 
     struct sched_param param;
     memset(&param, 0, sizeof(param));
@@ -102,7 +101,7 @@
         if (!eng) return -1;
     }
 
-    if (sched_setscheduler((pid_t) 0, SCHED_BATCH, &param) < 0) {
+    if (sched_setscheduler((pid_t)0, SCHED_BATCH, &param) < 0) {
         android::prdebug("failed to set batch scheduler");
         if (!eng) return -1;
     }
@@ -122,21 +121,24 @@
         if (!eng) return -1;
     }
 
-    std::unique_ptr<struct _cap_struct, int(*)(void *)> caps(cap_init(), cap_free);
+    std::unique_ptr<struct _cap_struct, int (*)(void*)> caps(cap_init(),
+                                                             cap_free);
     if (cap_clear(caps.get()) < 0) return -1;
-    cap_value_t cap_value[] = {
-        CAP_SETGID, // must be first for below
-        klogd ? CAP_SYSLOG : CAP_SETGID,
-        auditd ? CAP_AUDIT_CONTROL : CAP_SETGID
-    };
-    if (cap_set_flag(caps.get(), CAP_PERMITTED,
-                     arraysize(cap_value), cap_value,
-                     CAP_SET) < 0) return -1;
-    if (cap_set_flag(caps.get(), CAP_EFFECTIVE,
-                     arraysize(cap_value), cap_value,
-                     CAP_SET) < 0) return -1;
+    cap_value_t cap_value[] = { CAP_SETGID,  // must be first for below
+                                klogd ? CAP_SYSLOG : CAP_SETGID,
+                                auditd ? CAP_AUDIT_CONTROL : CAP_SETGID };
+    if (cap_set_flag(caps.get(), CAP_PERMITTED, arraysize(cap_value), cap_value,
+                     CAP_SET) < 0) {
+        return -1;
+    }
+    if (cap_set_flag(caps.get(), CAP_EFFECTIVE, arraysize(cap_value), cap_value,
+                     CAP_SET) < 0) {
+        return -1;
+    }
     if (cap_set_proc(caps.get()) < 0) {
-        android::prdebug("failed to set CAP_SETGID, CAP_SYSLOG or CAP_AUDIT_CONTROL (%d)", errno);
+        android::prdebug(
+            "failed to set CAP_SETGID, CAP_SYSLOG or CAP_AUDIT_CONTROL (%d)",
+            errno);
         if (!eng) return -1;
     }
 
@@ -157,8 +159,12 @@
         if (!eng) return -1;
     }
 
-    if (cap_set_flag(caps.get(), CAP_PERMITTED, 1, cap_value, CAP_CLEAR) < 0) return -1;
-    if (cap_set_flag(caps.get(), CAP_EFFECTIVE, 1, cap_value, CAP_CLEAR) < 0) return -1;
+    if (cap_set_flag(caps.get(), CAP_PERMITTED, 1, cap_value, CAP_CLEAR) < 0) {
+        return -1;
+    }
+    if (cap_set_flag(caps.get(), CAP_EFFECTIVE, 1, cap_value, CAP_CLEAR) < 0) {
+        return -1;
+    }
     if (cap_set_proc(caps.get()) < 0) {
         android::prdebug("failed to clear CAP_SETGID (%d)", errno);
         if (!eng) return -1;
@@ -168,8 +174,8 @@
 }
 
 // Property helper
-static bool check_flag(const char *prop, const char *flag) {
-    const char *cp = strcasestr(prop, flag);
+static bool check_flag(const char* prop, const char* flag) {
+    const char* cp = strcasestr(prop, flag);
     if (!cp) {
         return false;
     }
@@ -183,7 +189,7 @@
 }
 
 static int fdDmesg = -1;
-void android::prdebug(const char *fmt, ...) {
+void android::prdebug(const char* fmt, ...) {
     if (fdDmesg < 0) {
         return;
     }
@@ -211,14 +217,13 @@
 
 static sem_t uidName;
 static uid_t uid;
-static char *name;
+static char* name;
 
 static sem_t reinit;
 static bool reinit_running = false;
-static LogBuffer *logBuf = NULL;
+static LogBuffer* logBuf = NULL;
 
-static bool package_list_parser_cb(pkg_info *info, void * /* userdata */) {
-
+static bool package_list_parser_cb(pkg_info* info, void* /* userdata */) {
     bool rc = true;
     if (info->uid == uid) {
         name = strdup(info->name);
@@ -230,7 +235,7 @@
     return rc;
 }
 
-static void *reinit_thread_start(void * /*obj*/) {
+static void* reinit_thread_start(void* /*obj*/) {
     prctl(PR_SET_NAME, "logd.daemon");
     set_sched_policy(0, SP_BACKGROUND);
     setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND);
@@ -243,11 +248,10 @@
     // If we are AID_ROOT, we should drop to AID_LOGD+AID_SYSTEM, if we are
     // anything else, we have even lesser privileges and accept our fate. Not
     // worth checking for error returns setting this thread's privileges.
-    (void)setgid(AID_SYSTEM); // readonly access to /data/system/packages.list
-    (void)setuid(AID_LOGD);   // access to everything logd, eg /data/misc/logd
+    (void)setgid(AID_SYSTEM);  // readonly access to /data/system/packages.list
+    (void)setuid(AID_LOGD);    // access to everything logd, eg /data/misc/logd
 
     while (reinit_running && !sem_wait(&reinit) && reinit_running) {
-
         // uidToName Privileged Worker
         if (uid) {
             name = NULL;
@@ -261,8 +265,26 @@
 
         if (fdDmesg >= 0) {
             static const char reinit_message[] = { KMSG_PRIORITY(LOG_INFO),
-                'l', 'o', 'g', 'd', '.', 'd', 'a', 'e', 'm', 'o', 'n', ':',
-                ' ', 'r', 'e', 'i', 'n', 'i', 't', '\n' };
+                                                   'l',
+                                                   'o',
+                                                   'g',
+                                                   'd',
+                                                   '.',
+                                                   'd',
+                                                   'a',
+                                                   'e',
+                                                   'm',
+                                                   'o',
+                                                   'n',
+                                                   ':',
+                                                   ' ',
+                                                   'r',
+                                                   'e',
+                                                   'i',
+                                                   'n',
+                                                   'i',
+                                                   't',
+                                                   '\n' };
             write(fdDmesg, reinit_message, sizeof(reinit_message));
         }
 
@@ -279,7 +301,7 @@
 
 static sem_t sem_name;
 
-char *android::uidToName(uid_t u) {
+char* android::uidToName(uid_t u) {
     if (!u || !reinit_running) {
         return NULL;
     }
@@ -292,7 +314,7 @@
     name = NULL;
     sem_post(&reinit);
     sem_wait(&uidName);
-    char *ret = name;
+    char* ret = name;
 
     sem_post(&sem_name);
 
@@ -305,7 +327,7 @@
     sem_post(&reinit);
 }
 
-static void readDmesg(LogAudit *al, LogKlog *kl) {
+static void readDmesg(LogAudit* al, LogKlog* kl) {
     if (!al && !kl) {
         return;
     }
@@ -315,8 +337,8 @@
         return;
     }
 
-    size_t len = rc + 1024; // Margin for additional input race or trailing nul
-    std::unique_ptr<char []> buf(new char[len]);
+    size_t len = rc + 1024;  // Margin for additional input race or trailing nul
+    std::unique_ptr<char[]> buf(new char[len]);
 
     rc = klogctl(KLOG_READ_ALL, buf.get(), len);
     if (rc <= 0) {
@@ -351,10 +373,8 @@
     (void)cap_set_proc(caps);
     (void)cap_free(caps);
 
-    int sock = TEMP_FAILURE_RETRY(
-        socket_local_client("logd",
-                            ANDROID_SOCKET_NAMESPACE_RESERVED,
-                            SOCK_STREAM));
+    int sock = TEMP_FAILURE_RETRY(socket_local_client(
+        "logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
     if (sock < 0) return -errno;
 
     static const char reinitStr[] = "reinit";
@@ -384,7 +404,7 @@
 // controlling the user space logger, and for any additional
 // logging plugins like auditd and restart control. Additional
 // transitory per-client threads are created for each reader.
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
     // issue reinit command. KISS argument parsing.
     if ((argc > 1) && argv[1] && !strcmp(argv[1], "--reinit")) {
         return issueReinit();
@@ -397,17 +417,15 @@
     }
 
     int fdPmesg = -1;
-    bool klogd = __android_logger_property_get_bool("logd.kernel",
-                                                    BOOL_DEFAULT_TRUE |
-                                                    BOOL_DEFAULT_FLAG_PERSIST |
-                                                    BOOL_DEFAULT_FLAG_ENG |
-                                                    BOOL_DEFAULT_FLAG_SVELTE);
+    bool klogd = __android_logger_property_get_bool(
+        "logd.kernel", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_PERSIST |
+                           BOOL_DEFAULT_FLAG_ENG | BOOL_DEFAULT_FLAG_SVELTE);
     if (klogd) {
         static const char proc_kmsg[] = "/proc/kmsg";
         fdPmesg = android_get_control_file(proc_kmsg);
         if (fdPmesg < 0) {
-            fdPmesg = TEMP_FAILURE_RETRY(open(proc_kmsg,
-                                              O_RDONLY | O_NDELAY | O_CLOEXEC));
+            fdPmesg = TEMP_FAILURE_RETRY(
+                open(proc_kmsg, O_RDONLY | O_NDELAY | O_CLOEXEC));
         }
         if (fdPmesg < 0) android::prdebug("Failed to open %s\n", proc_kmsg);
     }
@@ -423,8 +441,7 @@
         memset(&param, 0, sizeof(param));
         pthread_attr_setschedparam(&attr, &param);
         pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
-        if (!pthread_attr_setdetachstate(&attr,
-                                         PTHREAD_CREATE_DETACHED)) {
+        if (!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
             pthread_t thread;
             reinit_running = true;
             if (pthread_create(&thread, &attr, reinit_thread_start, NULL)) {
@@ -434,8 +451,8 @@
         pthread_attr_destroy(&attr);
     }
 
-    bool auditd = __android_logger_property_get_bool("ro.logd.auditd",
-                                                     BOOL_DEFAULT_TRUE);
+    bool auditd =
+        __android_logger_property_get_bool("ro.logd.auditd", BOOL_DEFAULT_TRUE);
     if (drop_privs(klogd, auditd) != 0) {
         return -1;
     }
@@ -444,7 +461,7 @@
     // socket connection, and as a reader lock on a range of log
     // entries.
 
-    LastLogTimes *times = new LastLogTimes();
+    LastLogTimes* times = new LastLogTimes();
 
     // LogBuffer is the object which is responsible for holding all
     // log entries.
@@ -453,18 +470,17 @@
 
     signal(SIGHUP, reinit_signal_handler);
 
-    if (__android_logger_property_get_bool("logd.statistics",
-                                           BOOL_DEFAULT_TRUE |
-                                           BOOL_DEFAULT_FLAG_PERSIST |
-                                           BOOL_DEFAULT_FLAG_ENG |
-                                           BOOL_DEFAULT_FLAG_SVELTE)) {
+    if (__android_logger_property_get_bool(
+            "logd.statistics", BOOL_DEFAULT_TRUE | BOOL_DEFAULT_FLAG_PERSIST |
+                                   BOOL_DEFAULT_FLAG_ENG |
+                                   BOOL_DEFAULT_FLAG_SVELTE)) {
         logBuf->enableStatistics();
     }
 
     // LogReader listens on /dev/socket/logdr. When a client
     // connects, log entries in the LogBuffer are written to the client.
 
-    LogReader *reader = new LogReader(logBuf);
+    LogReader* reader = new LogReader(logBuf);
     if (reader->startListener()) {
         exit(1);
     }
@@ -473,7 +489,7 @@
     // initiated log messages. New log entries are added to LogBuffer
     // and LogReader is notified to send updates to connected clients.
 
-    LogListener *swl = new LogListener(logBuf, reader);
+    LogListener* swl = new LogListener(logBuf, reader);
     // Backlog and /proc/sys/net/unix/max_dgram_qlen set to large value
     if (swl->startListener(600)) {
         exit(1);
@@ -482,7 +498,7 @@
     // Command listener listens on /dev/socket/logd for incoming logd
     // administrative commands.
 
-    CommandListener *cl = new CommandListener(logBuf, reader, swl);
+    CommandListener* cl = new CommandListener(logBuf, reader, swl);
     if (cl->startListener()) {
         exit(1);
     }
@@ -491,17 +507,16 @@
     // initiated log messages. New log entries are added to LogBuffer
     // and LogReader is notified to send updates to connected clients.
 
-    LogAudit *al = NULL;
+    LogAudit* al = NULL;
     if (auditd) {
         al = new LogAudit(logBuf, reader,
                           __android_logger_property_get_bool(
-                              "ro.logd.auditd.dmesg",
-                              BOOL_DEFAULT_TRUE)
-                                  ? fdDmesg
-                                  : -1);
+                              "ro.logd.auditd.dmesg", BOOL_DEFAULT_TRUE)
+                              ? fdDmesg
+                              : -1);
     }
 
-    LogKlog *kl = NULL;
+    LogKlog* kl = NULL;
     if (klogd) {
         kl = new LogKlog(logBuf, reader, fdDmesg, fdPmesg, al != NULL);
     }
diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp
index 8a35059..ddff393 100644
--- a/logd/tests/logd_test.cpp
+++ b/logd/tests/logd_test.cpp
@@ -20,8 +20,8 @@
 #include <signal.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 
 #include <string>
@@ -36,13 +36,11 @@
 #include <selinux/selinux.h>
 #endif
 
-#include "../libaudit.h" // pickup AUDIT_RATE_LIMIT_*
-#include "../LogReader.h" // pickup LOGD_SNDTIMEO
+#include "../LogReader.h"  // pickup LOGD_SNDTIMEO
+#include "../libaudit.h"   // pickup AUDIT_RATE_LIMIT_*
 
-static void send_to_control(char* buf, size_t len)
-{
-    int sock = socket_local_client("logd",
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
+static void send_to_control(char* buf, size_t len) {
+    int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
                                    SOCK_STREAM);
     if (sock >= 0) {
         if (write(sock, buf, strlen(buf) + 1) > 0) {
@@ -54,11 +52,7 @@
                 len -= ret;
                 buf += ret;
 
-                struct pollfd p = {
-                    .fd = sock,
-                    .events = POLLIN,
-                    .revents = 0
-                };
+                struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0 };
 
                 ret = poll(&p, 1, 20);
                 if ((ret <= 0) || !(p.revents & POLLIN)) {
@@ -73,25 +67,23 @@
 /*
  * returns statistics
  */
-static void my_android_logger_get_statistics(char *buf, size_t len)
-{
+static void my_android_logger_get_statistics(char* buf, size_t len) {
     snprintf(buf, len, "getStatistics 0 1 2 3 4");
     send_to_control(buf, len);
 }
 
-static void alloc_statistics(char **buffer, size_t *length)
-{
+static void alloc_statistics(char** buffer, size_t* length) {
     size_t len = 8192;
-    char *buf;
+    char* buf;
 
-    for(int retry = 32; (retry >= 0); delete [] buf, --retry) {
-        buf = new char [len];
+    for (int retry = 32; (retry >= 0); delete[] buf, --retry) {
+        buf = new char[len];
         my_android_logger_get_statistics(buf, len);
 
-        buf[len-1] = '\0';
+        buf[len - 1] = '\0';
         size_t ret = atol(buf) + 1;
         if (ret < 4) {
-            delete [] buf;
+            delete[] buf;
             buf = NULL;
             break;
         }
@@ -100,14 +92,13 @@
         if (check) {
             break;
         }
-        len += len / 8; // allow for some slop
+        len += len / 8;  // allow for some slop
     }
     *buffer = buf;
     *length = len;
 }
 
-static char *find_benchmark_spam(char *cp)
-{
+static char* find_benchmark_spam(char* cp) {
     // liblog_benchmarks has been run designed to SPAM.  The signature of
     // a noisiest UID statistics is:
     //
@@ -115,7 +106,7 @@
     // UID   PACKAGE                                                BYTES LINES
     // 0     root                                                  54164 147569
     //
-    char *benchmark = NULL;
+    char* benchmark = NULL;
     do {
         static const char signature[] = "\n0     root ";
 
@@ -129,7 +120,7 @@
         }
         benchmark = cp;
 #ifdef DEBUG
-        char *end = strstr(benchmark, "\n");
+        char* end = strstr(benchmark, "\n");
         if (end == NULL) {
             end = benchmark + strlen(benchmark);
         }
@@ -145,8 +136,8 @@
         }
         // optional +/- field?
         if ((*cp == '-') || (*cp == '+')) {
-            while (isdigit(*++cp) ||
-                   (*cp == '.') || (*cp == '%') || (*cp == 'X')) {
+            while (isdigit(*++cp) || (*cp == '.') || (*cp == '%') ||
+                   (*cp == 'X')) {
                 ;
             }
             while (isspace(*cp)) {
@@ -169,14 +160,14 @@
 
 TEST(logd, statistics) {
     size_t len;
-    char *buf;
+    char* buf;
 
     alloc_statistics(&buf, &len);
 
     ASSERT_TRUE(NULL != buf);
 
     // remove trailing FF
-    char *cp = buf + len - 1;
+    char* cp = buf + len - 1;
     *cp = '\0';
     bool truncated = *--cp != '\f';
     if (!truncated) {
@@ -197,105 +188,107 @@
 
     EXPECT_EQ(0, truncated);
 
-    char *main_logs = strstr(cp, "\nChattiest UIDs in main ");
+    char* main_logs = strstr(cp, "\nChattiest UIDs in main ");
     EXPECT_TRUE(NULL != main_logs);
 
-    char *radio_logs = strstr(cp, "\nChattiest UIDs in radio ");
-    if (!radio_logs) GTEST_LOG_(INFO) << "Value of: NULL != radio_logs\n"
-                                         "Actual: false\n"
-                                         "Expected: false\n";
+    char* radio_logs = strstr(cp, "\nChattiest UIDs in radio ");
+    if (!radio_logs)
+        GTEST_LOG_(INFO) << "Value of: NULL != radio_logs\n"
+                            "Actual: false\n"
+                            "Expected: false\n";
 
-    char *system_logs = strstr(cp, "\nChattiest UIDs in system ");
+    char* system_logs = strstr(cp, "\nChattiest UIDs in system ");
     EXPECT_TRUE(NULL != system_logs);
 
-    char *events_logs = strstr(cp, "\nChattiest UIDs in events ");
+    char* events_logs = strstr(cp, "\nChattiest UIDs in events ");
     EXPECT_TRUE(NULL != events_logs);
 
-    delete [] buf;
+    delete[] buf;
 }
 
-static void caught_signal(int /* signum */) { }
+static void caught_signal(int /* signum */) {
+}
 
-static void dump_log_msg(const char *prefix,
-                         log_msg *msg, unsigned int version, int lid) {
+static void dump_log_msg(const char* prefix, log_msg* msg, unsigned int version,
+                         int lid) {
     std::cout << std::flush;
     std::cerr << std::flush;
     fflush(stdout);
     fflush(stderr);
-    switch(msg->entry.hdr_size) {
-    case 0:
-        version = 1;
-        break;
+    switch (msg->entry.hdr_size) {
+        case 0:
+            version = 1;
+            break;
 
-    case sizeof(msg->entry_v2): /* PLUS case sizeof(msg->entry_v3): */
-        if (version == 0) {
-            version = (msg->entry_v3.lid < LOG_ID_MAX) ? 3 : 2;
-        }
-        break;
+        case sizeof(msg->entry_v2): /* PLUS case sizeof(msg->entry_v3): */
+            if (version == 0) {
+                version = (msg->entry_v3.lid < LOG_ID_MAX) ? 3 : 2;
+            }
+            break;
 
-    case sizeof(msg->entry_v4):
-        if (version == 0) {
-            version = 4;
-        }
-        break;
+        case sizeof(msg->entry_v4):
+            if (version == 0) {
+                version = 4;
+            }
+            break;
     }
 
     fprintf(stderr, "%s: v%u[%u] ", prefix, version, msg->len());
     if (version != 1) {
         fprintf(stderr, "hdr_size=%u ", msg->entry.hdr_size);
     }
-    fprintf(stderr, "pid=%u tid=%u %u.%09u ",
-            msg->entry.pid, msg->entry.tid, msg->entry.sec, msg->entry.nsec);
-    switch(version) {
-    case 1:
-         break;
-    case 2:
-        fprintf(stderr, "euid=%u ", msg->entry_v2.euid);
-        break;
-    case 3:
-    default:
-        lid = msg->entry.lid;
-        break;
+    fprintf(stderr, "pid=%u tid=%u %u.%09u ", msg->entry.pid, msg->entry.tid,
+            msg->entry.sec, msg->entry.nsec);
+    switch (version) {
+        case 1:
+            break;
+        case 2:
+            fprintf(stderr, "euid=%u ", msg->entry_v2.euid);
+            break;
+        case 3:
+        default:
+            lid = msg->entry.lid;
+            break;
     }
 
-    switch(lid) {
-    case 0:
-        fprintf(stderr, "lid=main ");
-        break;
-    case 1:
-        fprintf(stderr, "lid=radio ");
-        break;
-    case 2:
-        fprintf(stderr, "lid=events ");
-        break;
-    case 3:
-        fprintf(stderr, "lid=system ");
-        break;
-    case 4:
-        fprintf(stderr, "lid=crash ");
-        break;
-    case 5:
-        fprintf(stderr, "lid=security ");
-        break;
-    case 6:
-        fprintf(stderr, "lid=kernel ");
-        break;
-    default:
-        if (lid >= 0) {
-            fprintf(stderr, "lid=%d ", lid);
-        }
+    switch (lid) {
+        case 0:
+            fprintf(stderr, "lid=main ");
+            break;
+        case 1:
+            fprintf(stderr, "lid=radio ");
+            break;
+        case 2:
+            fprintf(stderr, "lid=events ");
+            break;
+        case 3:
+            fprintf(stderr, "lid=system ");
+            break;
+        case 4:
+            fprintf(stderr, "lid=crash ");
+            break;
+        case 5:
+            fprintf(stderr, "lid=security ");
+            break;
+        case 6:
+            fprintf(stderr, "lid=kernel ");
+            break;
+        default:
+            if (lid >= 0) {
+                fprintf(stderr, "lid=%d ", lid);
+            }
     }
 
     unsigned int len = msg->entry.len;
     fprintf(stderr, "msg[%u]={", len);
-    unsigned char *cp = reinterpret_cast<unsigned char *>(msg->msg());
+    unsigned char* cp = reinterpret_cast<unsigned char*>(msg->msg());
     if (!cp) {
         static const unsigned char garbage[] = "<INVALID>";
-        cp = const_cast<unsigned char *>(garbage);
-        len = strlen(reinterpret_cast<const char *>(garbage));
+        cp = const_cast<unsigned char*>(garbage);
+        len = strlen(reinterpret_cast<const char*>(garbage));
     }
-    while(len) {
-        unsigned char *p = cp;
+    while (len) {
+        unsigned char* p = cp;
         while (*p && (((' ' <= *p) && (*p < 0x7F)) || (*p == '\n'))) {
             ++p;
         }
@@ -330,8 +323,7 @@
     bool user_logger_available = false;
     bool user_logger_content = false;
 
-    int fd = socket_local_client("logdr",
-                                 ANDROID_SOCKET_NAMESPACE_RESERVED,
+    int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
                                  SOCK_SEQPACKET);
     if (fd >= 0) {
         struct sigaction ignore, old_sigaction;
@@ -360,10 +352,9 @@
     bool kernel_logger_available = false;
     bool kernel_logger_content = false;
 
-    static const char *loggers[] = {
-        "/dev/log/main",   "/dev/log_main",
-        "/dev/log/radio",  "/dev/log_radio",
-        "/dev/log/events", "/dev/log_events",
+    static const char* loggers[] = {
+        "/dev/log/main",   "/dev/log_main",   "/dev/log/radio",
+        "/dev/log_radio",  "/dev/log/events", "/dev/log_events",
         "/dev/log/system", "/dev/log_system",
     };
 
@@ -389,10 +380,9 @@
             "user    %-13s%s\n"
             "kernel  %-13s%s\n"
             " status %-11s%s\n",
-            (user_logger_available)   ? yes : no,
-            (user_logger_content)     ? yes : no,
+            (user_logger_available) ? yes : no, (user_logger_content) ? yes : no,
             (kernel_logger_available) ? yes : no,
-            (kernel_logger_content)   ? yes : no,
+            (kernel_logger_content) ? yes : no,
             (user_logger_available && kernel_logger_available) ? "ERROR" : "ok",
             (user_logger_content && kernel_logger_content) ? "ERROR" : "ok");
 
@@ -415,39 +405,37 @@
 //
 TEST(logd, benchmark) {
     size_t len;
-    char *buf;
+    char* buf;
 
     alloc_statistics(&buf, &len);
     bool benchmark_already_run = buf && find_benchmark_spam(buf);
-    delete [] buf;
+    delete[] buf;
 
     if (benchmark_already_run) {
-        fprintf(stderr, "WARNING: spam already present and too much history\n"
-                        "         false OK for prune by worst UID check\n");
+        fprintf(stderr,
+                "WARNING: spam already present and too much history\n"
+                "         false OK for prune by worst UID check\n");
     }
 
-    FILE *fp;
+    FILE* fp;
 
     // Introduce some extreme spam for the worst UID filter
-    ASSERT_TRUE(NULL != (fp = popen(
-        "/data/nativetest/liblog-benchmarks/liblog-benchmarks"
-            " BM_log_maximum_retry"
-            " BM_log_maximum"
-            " BM_clock_overhead"
-            " BM_log_overhead"
-            " BM_log_latency"
-            " BM_log_delay",
-        "r")));
+    ASSERT_TRUE(
+        NULL !=
+        (fp = popen("/data/nativetest/liblog-benchmarks/liblog-benchmarks"
+                    " BM_log_maximum_retry"
+                    " BM_log_maximum"
+                    " BM_clock_overhead"
+                    " BM_log_overhead"
+                    " BM_log_latency"
+                    " BM_log_delay",
+                    "r")));
 
     char buffer[5120];
 
-    static const char *benchmarks[] = {
-        "BM_log_maximum_retry ",
-        "BM_log_maximum ",
-        "BM_clock_overhead ",
-        "BM_log_overhead ",
-        "BM_log_latency ",
-        "BM_log_delay "
+    static const char* benchmarks[] = {
+        "BM_log_maximum_retry ", "BM_log_maximum ", "BM_clock_overhead ",
+        "BM_log_overhead ",      "BM_log_latency ", "BM_log_delay "
     };
     static const unsigned int log_maximum_retry = 0;
     static const unsigned int log_maximum = 1;
@@ -462,7 +450,7 @@
 
     while (fgets(buffer, sizeof(buffer), fp)) {
         for (unsigned i = 0; i < arraysize(ns); ++i) {
-            char *cp = strstr(buffer, benchmarks[i]);
+            char* cp = strstr(buffer, benchmarks[i]);
             if (!cp) {
                 continue;
             }
@@ -480,17 +468,18 @@
         return;
     }
 
-    EXPECT_GE(200000UL, ns[log_maximum_retry]); // 104734 user
+    EXPECT_GE(200000UL, ns[log_maximum_retry]);  // 104734 user
 
-    EXPECT_GE(90000UL, ns[log_maximum]); // 46913 user
+    EXPECT_GE(90000UL, ns[log_maximum]);  // 46913 user
 
-    EXPECT_GE(4096UL, ns[clock_overhead]); // 4095
+    EXPECT_GE(4096UL, ns[clock_overhead]);  // 4095
 
-    EXPECT_GE(250000UL, ns[log_overhead]); // 126886 user
+    EXPECT_GE(250000UL, ns[log_overhead]);  // 126886 user
 
-    EXPECT_GE(10000000UL, ns[log_latency]); // 1453559 user space (background cgroup)
+    EXPECT_GE(10000000UL,
+              ns[log_latency]);  // 1453559 user space (background cgroup)
 
-    EXPECT_GE(20000000UL, ns[log_delay]); // 10500289 user
+    EXPECT_GE(20000000UL, ns[log_delay]);  // 10500289 user
 
     for (unsigned i = 0; i < arraysize(ns); ++i) {
         EXPECT_NE(0UL, ns[i]);
@@ -503,7 +492,7 @@
 
     ASSERT_TRUE(NULL != buf);
 
-    char *benchmark_statistics_found = find_benchmark_spam(buf);
+    char* benchmark_statistics_found = find_benchmark_spam(buf);
     ASSERT_TRUE(benchmark_statistics_found != NULL);
 
     // Check how effective the SPAM filter is, parse out Now size.
@@ -512,13 +501,12 @@
 
     unsigned long nowSpamSize = atol(benchmark_statistics_found);
 
-    delete [] buf;
+    delete[] buf;
 
     ASSERT_NE(0UL, nowSpamSize);
 
     // Determine if we have the spam filter enabled
-    int sock = socket_local_client("logd",
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
+    int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
                                    SOCK_STREAM);
 
     ASSERT_TRUE(sock >= 0);
@@ -528,26 +516,27 @@
         char buffer[80];
         memset(buffer, 0, sizeof(buffer));
         read(sock, buffer, sizeof(buffer));
-        char *cp = strchr(buffer, '\n');
+        char* cp = strchr(buffer, '\n');
         if (!cp || (cp[1] != '~') || (cp[2] != '!')) {
             close(sock);
             fprintf(stderr,
                     "WARNING: "
-                    "Logger has SPAM filtration turned off \"%s\"\n", buffer);
+                    "Logger has SPAM filtration turned off \"%s\"\n",
+                    buffer);
             return;
         }
     } else {
         int save_errno = errno;
         close(sock);
-        FAIL() << "Can not send " << getPruneList << " to logger -- " << strerror(save_errno);
+        FAIL() << "Can not send " << getPruneList << " to logger -- "
+               << strerror(save_errno);
     }
 
     static const unsigned long expected_absolute_minimum_log_size = 65536UL;
     unsigned long totalSize = expected_absolute_minimum_log_size;
-    static const char getSize[] = {
-        'g', 'e', 't', 'L', 'o', 'g', 'S', 'i', 'z', 'e', ' ',
-        LOG_ID_MAIN + '0', '\0'
-    };
+    static const char getSize[] = { 'g', 'e', 't', 'L', 'o', 'g',
+                                    'S', 'i', 'z', 'e', ' ', LOG_ID_MAIN + '0',
+                                    '\0' };
     if (write(sock, getSize, sizeof(getSize)) > 0) {
         char buffer[80];
         memset(buffer, 0, sizeof(buffer));
@@ -556,21 +545,22 @@
         if (totalSize < expected_absolute_minimum_log_size) {
             fprintf(stderr,
                     "WARNING: "
-                    "Logger had unexpected referenced size \"%s\"\n", buffer);
+                    "Logger had unexpected referenced size \"%s\"\n",
+                    buffer);
             totalSize = expected_absolute_minimum_log_size;
         }
     }
     close(sock);
 
     // logd allows excursions to 110% of total size
-    totalSize = (totalSize * 11 ) / 10;
+    totalSize = (totalSize * 11) / 10;
 
     // 50% threshold for SPAM filter (<20% typical, lots of engineering margin)
     ASSERT_GT(totalSize, nowSpamSize * 2);
 }
 
 // b/26447386 confirm fixed
-void timeout_negative(const char *command) {
+void timeout_negative(const char* command) {
     log_msg msg_wrap, msg_timeout;
     bool content_wrap = false, content_timeout = false, written = false;
     unsigned int alarm_wrap = 0, alarm_timeout = 0;
@@ -579,8 +569,7 @@
     int i = 3;
 
     while (--i) {
-        int fd = socket_local_client("logdr",
-                                     ANDROID_SOCKET_NAMESPACE_RESERVED,
+        int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
                                      SOCK_SEQPACKET);
         ASSERT_LT(0, fd);
 
@@ -609,15 +598,16 @@
 
         // alarm triggers at 133% of the --wrap time out
         content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        if (!content_timeout) { // make sure we hit dumpAndClose
-            content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
+        if (!content_timeout) {  // make sure we hit dumpAndClose
+            content_timeout =
+                recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
         }
 
-        alarm_timeout = alarm((old_alarm <= 0)
-            ? old_alarm
-            : (old_alarm > (1 + 3 - alarm_wrap))
-                ? old_alarm - 3 + alarm_wrap
-                : 2);
+        alarm_timeout =
+            alarm((old_alarm <= 0) ? old_alarm
+                                   : (old_alarm > (1 + 3 - alarm_wrap))
+                                         ? old_alarm - 3 + alarm_wrap
+                                         : 2);
         sigaction(SIGALRM, &old_sigaction, NULL);
 
         close(fd);
@@ -647,7 +637,8 @@
 }
 
 TEST(logd, timeout_start_epoch) {
-    timeout_negative("dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=0.000000000");
+    timeout_negative(
+        "dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=0.000000000");
 }
 
 // b/26447386 refined behavior
@@ -672,18 +663,17 @@
     // content providers being active during the test.
     int i = 5;
     log_time now(android_log_clockid());
-    now.tv_sec -= 30; // reach back a moderate period of time
+    now.tv_sec -= 30;  // reach back a moderate period of time
 
     while (--i) {
-        int fd = socket_local_client("logdr",
-                                     ANDROID_SOCKET_NAMESPACE_RESERVED,
+        int fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
                                      SOCK_SEQPACKET);
         EXPECT_LT(0, fd);
         if (fd < 0) _exit(fd);
 
         std::string ask = android::base::StringPrintf(
-            "dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=%"
-                PRIu32 ".%09" PRIu32,
+            "dumpAndClose lids=0,1,2,3,4,5 timeout=6 start=%" PRIu32
+            ".%09" PRIu32,
             now.tv_sec, now.tv_nsec);
 
         struct sigaction ignore, old_sigaction;
@@ -709,15 +699,16 @@
 
         // alarm triggers at 133% of the --wrap time out
         content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
-        if (!content_timeout) { // make sure we hit dumpAndClose
-            content_timeout = recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
+        if (!content_timeout) {  // make sure we hit dumpAndClose
+            content_timeout =
+                recv(fd, msg_timeout.buf, sizeof(msg_timeout), 0) > 0;
         }
 
-        alarm_timeout = alarm((old_alarm <= 0)
-            ? old_alarm
-            : (old_alarm > (1 + 3 - alarm_wrap))
-                ? old_alarm - 3 + alarm_wrap
-                : 2);
+        alarm_timeout =
+            alarm((old_alarm <= 0) ? old_alarm
+                                   : (old_alarm > (1 + 3 - alarm_wrap))
+                                         ? old_alarm - 3 + alarm_wrap
+                                         : 2);
         sigaction(SIGALRM, &old_sigaction, NULL);
 
         close(fd);
@@ -742,7 +733,7 @@
                 }
             }
         } else {
-            now.tv_sec -= 120; // inactive, reach further back!
+            now.tv_sec -= 120;  // inactive, reach further back!
         }
     }
 
@@ -755,8 +746,8 @@
     }
 
     if (content_wrap || !content_timeout) {
-        fprintf(stderr, "now=%" PRIu32 ".%09" PRIu32 "\n",
-                now.tv_sec, now.tv_nsec);
+        fprintf(stderr, "now=%" PRIu32 ".%09" PRIu32 "\n", now.tv_sec,
+                now.tv_nsec);
     }
 
     EXPECT_TRUE(written);
@@ -765,20 +756,22 @@
     EXPECT_TRUE(content_timeout);
     EXPECT_NE(0U, alarm_timeout);
 
-    _exit(!written + content_wrap + alarm_wrap + !content_timeout + !alarm_timeout);
+    _exit(!written + content_wrap + alarm_wrap + !content_timeout +
+          !alarm_timeout);
 }
 
 // b/27242723 confirmed fixed
 TEST(logd, SNDTIMEO) {
-    static const unsigned sndtimeo = LOGD_SNDTIMEO; // <sigh> it has to be done!
+    static const unsigned sndtimeo =
+        LOGD_SNDTIMEO;  // <sigh> it has to be done!
     static const unsigned sleep_time = sndtimeo + 3;
     static const unsigned alarm_time = sleep_time + 5;
 
     int fd;
 
-    ASSERT_TRUE((fd = socket_local_client("logdr",
-                                 ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                 SOCK_SEQPACKET)) > 0);
+    ASSERT_TRUE(
+        (fd = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
+                                  SOCK_SEQPACKET)) > 0);
 
     struct sigaction ignore, old_sigaction;
     memset(&ignore, 0, sizeof(ignore));
@@ -787,7 +780,7 @@
     sigaction(SIGALRM, &ignore, &old_sigaction);
     unsigned int old_alarm = alarm(alarm_time);
 
-    static const char ask[] = "stream lids=0,1,2,3,4,5,6"; // all sources
+    static const char ask[] = "stream lids=0,1,2,3,4,5,6";  // all sources
     bool reader_requested = write(fd, ask, sizeof(ask)) == sizeof(ask);
     EXPECT_TRUE(reader_requested);
 
@@ -799,7 +792,7 @@
         dump_log_msg("user", &msg, 3, -1);
     }
 
-    fprintf (stderr, "Sleep for >%d seconds logd SO_SNDTIMEO ...\n", sndtimeo);
+    fprintf(stderr, "Sleep for >%d seconds logd SO_SNDTIMEO ...\n", sndtimeo);
     sleep(sleep_time);
 
     // flush will block if we did not trigger. if it did, last entry returns 0
@@ -828,7 +821,7 @@
     snprintf(buffer, sizeof(buffer), "getEventTag name=*");
     send_to_control(buffer, sizeof(buffer));
     buffer[sizeof(buffer) - 1] = '\0';
-    char *cp;
+    char* cp;
     long ret = strtol(buffer, &cp, 10);
     EXPECT_GT(ret, 4096);
 #else
@@ -843,7 +836,7 @@
     snprintf(buffer, sizeof(buffer), "getEventTag id=42");
     send_to_control(buffer, sizeof(buffer));
     buffer[sizeof(buffer) - 1] = '\0';
-    char *cp;
+    char* cp;
     long ret = strtol(buffer, &cp, 10);
     EXPECT_GT(ret, 16);
     EXPECT_TRUE(strstr(buffer, "\t(to life the universe etc|3)") != NULL);
@@ -860,24 +853,23 @@
     log_time now(CLOCK_MONOTONIC);
     char name[64];
     snprintf(name, sizeof(name), "a%" PRIu64, now.nsec());
-    snprintf(buffer, sizeof(buffer),
-             "getEventTag name=%s format=\"(new|1)\"", name);
+    snprintf(buffer, sizeof(buffer), "getEventTag name=%s format=\"(new|1)\"",
+             name);
     send_to_control(buffer, sizeof(buffer));
     buffer[sizeof(buffer) - 1] = '\0';
-    char *cp;
+    char* cp;
     long ret = strtol(buffer, &cp, 10);
     EXPECT_GT(ret, 16);
     EXPECT_TRUE(strstr(buffer, "\t(new|1)") != NULL);
     EXPECT_TRUE(strstr(buffer, name) != NULL);
-    // ToDo: also look for this in /data/misc/logd/event-log-tags and
-    // /dev/event-log-tags.
+// ToDo: also look for this in /data/misc/logd/event-log-tags and
+// /dev/event-log-tags.
 #else
     GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-static inline int32_t get4LE(const char* src)
-{
+static inline int32_t get4LE(const char* src) {
     return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
@@ -894,10 +886,12 @@
     if (pid == 0) {
         // child
         for (int i = count; i; --i) {
-            ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+            ASSERT_LT(
+                0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
             usleep(100);
         }
-        ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
+        ASSERT_LT(0,
+                  __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
         usleep(1000000);
 
         _exit(0);
@@ -907,9 +901,11 @@
     ASSERT_EQ(0, TEMP_FAILURE_RETRY(waitid(P_PID, pid, &info, WEXITED)));
     ASSERT_EQ(0, info.si_status);
 
-    struct logger_list *logger_list;
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 0, pid)));
+    struct logger_list* logger_list;
+    ASSERT_TRUE(NULL !=
+                (logger_list = android_logger_list_open(
+                     LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                     0, pid)));
 
     int expected_count = (count < 2) ? count : 2;
     int expected_chatty_count = (count <= 2) ? 0 : 1;
@@ -926,16 +922,17 @@
         log_msg log_msg;
         if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
 
-        if ((log_msg.entry.pid != pid) ||
-            (log_msg.entry.len < (4 + 1 + 8)) ||
-            (log_msg.id() != LOG_ID_EVENTS)) continue;
+        if ((log_msg.entry.pid != pid) || (log_msg.entry.len < (4 + 1 + 8)) ||
+            (log_msg.id() != LOG_ID_EVENTS))
+            continue;
 
-        char *eventData = log_msg.msg();
+        char* eventData = log_msg.msg();
         if (!eventData) continue;
 
         uint32_t tag = get4LE(eventData);
 
-        if ((eventData[4] == EVENT_TYPE_LONG) && (log_msg.entry.len == (4 + 1 + 8))) {
+        if ((eventData[4] == EVENT_TYPE_LONG) &&
+            (log_msg.entry.len == (4 + 1 + 8))) {
             if (tag != 0) continue;
 
             log_time tx(eventData + 4 + 1);
@@ -949,7 +946,7 @@
             ++chatty_count;
             // int len = get4LE(eventData + 4 + 1);
             log_msg.buf[LOGGER_ENTRY_MAX_LEN] = '\0';
-            const char *cp;
+            const char* cp;
             if ((cp = strstr(eventData + 4 + 1 + 4, " identical "))) {
                 unsigned val = 0;
                 sscanf(cp, " identical %u lines", &val);
@@ -1004,8 +1001,8 @@
         int save_errno = errno;
         security_context_t context;
         getcon(&context);
-        fprintf(stderr, "setcon(\"u:r:shell:s0\") failed @\"%s\" %s\n",
-                context, strerror(save_errno));
+        fprintf(stderr, "setcon(\"u:r:shell:s0\") failed @\"%s\" %s\n", context,
+                strerror(save_errno));
         freecon(context);
         _exit(-1);
         // NOTREACHED
@@ -1052,22 +1049,20 @@
 
     if (pid == 0) return count;
 
-    struct logger_list *logger_list;
-    if (!(logger_list = android_logger_list_open(LOG_ID_EVENTS,
-                                                 ANDROID_LOG_RDONLY |
-                                                     ANDROID_LOG_NONBLOCK,
-                                                 0,
-                                                 pid))) return count;
+    struct logger_list* logger_list;
+    if (!(logger_list = android_logger_list_open(
+              LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 0, pid)))
+        return count;
     for (;;) {
         log_msg log_msg;
 
         if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
 
-        if ((log_msg.entry.pid != pid) ||
-            (log_msg.entry.len < (4 + 1 + 8)) ||
-            (log_msg.id() != LOG_ID_EVENTS)) continue;
+        if ((log_msg.entry.pid != pid) || (log_msg.entry.len < (4 + 1 + 8)) ||
+            (log_msg.id() != LOG_ID_EVENTS))
+            continue;
 
-        char *eventData = log_msg.msg();
+        char* eventData = log_msg.msg();
         if (!eventData) continue;
 
         uint32_t tag = get4LE(eventData);
@@ -1077,7 +1072,7 @@
 
         // int len = get4LE(eventData + 4 + 1);
         log_msg.buf[LOGGER_ENTRY_MAX_LEN] = '\0';
-        const char *cp = strstr(eventData + 4 + 1 + 4, "): avc: denied");
+        const char* cp = strstr(eventData + 4 + 1 + 4, "): avc: denied");
         if (!cp) continue;
 
         ++count;
@@ -1103,10 +1098,11 @@
 TEST(logd, sepolicy_rate_limiter_sub_burst) {
 #ifdef __ANDROID__
     // maximum period below half way between sustainable and burst rate.
-    static const int threshold = ((AUDIT_RATE_LIMIT_BURST_DURATION *
-                                   (AUDIT_RATE_LIMIT_DEFAULT +
-                                    AUDIT_RATE_LIMIT_MAX)) +
-                                  1) / 2;
+    static const int threshold =
+        ((AUDIT_RATE_LIMIT_BURST_DURATION *
+          (AUDIT_RATE_LIMIT_DEFAULT + AUDIT_RATE_LIMIT_MAX)) +
+         1) /
+        2;
     static const int rate = (threshold / AUDIT_RATE_LIMIT_BURST_DURATION) - 1;
     static const int duration = AUDIT_RATE_LIMIT_BURST_DURATION;
     EXPECT_EQ(rate * duration, count_avc(sepolicy_rate(rate, rate * duration)));
@@ -1118,24 +1114,25 @@
 TEST(logd, sepolicy_rate_limiter_spam) {
 #ifdef __ANDROID__
     // maximum period of double the maximum burst rate
-    static const int threshold = ((AUDIT_RATE_LIMIT_BURST_DURATION *
-                                   (AUDIT_RATE_LIMIT_DEFAULT +
-                                    AUDIT_RATE_LIMIT_MAX)) +
-                                  1) / 2;
+    static const int threshold =
+        ((AUDIT_RATE_LIMIT_BURST_DURATION *
+          (AUDIT_RATE_LIMIT_DEFAULT + AUDIT_RATE_LIMIT_MAX)) +
+         1) /
+        2;
     static const int rate = AUDIT_RATE_LIMIT_DEFAULT * 2;
     static const int duration = threshold / AUDIT_RATE_LIMIT_DEFAULT;
-    EXPECT_GE(((AUDIT_RATE_LIMIT_DEFAULT * duration) * 115) /
-                                        100, // +15% margin
-              count_avc(sepolicy_rate(rate, rate * duration)));
+    EXPECT_GE(
+        ((AUDIT_RATE_LIMIT_DEFAULT * duration) * 115) / 100,  // +15% margin
+        count_avc(sepolicy_rate(rate, rate * duration)));
     // give logd another 3 seconds to react to the burst before checking
     sepolicy_rate(rate, rate * 3);
     // maximum period at double the maximum burst rate (spam filter kicked in)
-    EXPECT_GE(threshold * 2,
-              count_avc(sepolicy_rate(rate,
-                                      rate * AUDIT_RATE_LIMIT_BURST_DURATION)));
+    EXPECT_GE(
+        threshold * 2,
+        count_avc(sepolicy_rate(rate, rate * AUDIT_RATE_LIMIT_BURST_DURATION)));
     // cool down, and check unspammy rate still works
     sleep(2);
-    EXPECT_LE(AUDIT_RATE_LIMIT_BURST_DURATION - 1, // allow _one_ to be lost
+    EXPECT_LE(AUDIT_RATE_LIMIT_BURST_DURATION - 1,  // allow _one_ to be lost
               count_avc(sepolicy_rate(1, AUDIT_RATE_LIMIT_BURST_DURATION)));
 #else
     GTEST_LOG_(INFO) << "This test does nothing.\n";
