diff --git a/.clang-format b/.clang-format
new file mode 120000
index 0000000..9b45e0a
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1 @@
+.clang-format-4
\ No newline at end of file
diff --git a/.clang-format-2 b/.clang-format-2
new file mode 100644
index 0000000..fb967d8
--- /dev/null
+++ b/.clang-format-2
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+AllowShortBlocksOnASingleLine: false
+AllowShortFunctionsOnASingleLine: true
+
+AccessModifierOffset: -1
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 2
+PointerAlignment: Left
+TabWidth: 2
+UseTab: Never
+PenaltyExcessCharacter: 32
diff --git a/.clang-format-4 b/.clang-format-4
new file mode 100644
index 0000000..fc4eb1b
--- /dev/null
+++ b/.clang-format-4
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+AllowShortBlocksOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+
+AccessModifierOffset: -2
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+UseTab: Never
+PenaltyExcessCharacter: 32
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..c8dbf77
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,5 @@
+[Builtin Hooks]
+clang_format = true
+
+[Builtin Hooks Options]
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions c,h,cc,cpp
diff --git a/adb/Android.mk b/adb/Android.mk
index a2ea699..8a43e37 100644
--- a/adb/Android.mk
+++ b/adb/Android.mk
@@ -145,6 +145,7 @@
 LOCAL_SRC_FILES := \
     $(LIBADB_SRC_FILES) \
     adb_auth_host.cpp \
+    transport_mdns.cpp \
 
 LOCAL_SRC_FILES_darwin := $(LIBADB_darwin_SRC_FILES)
 LOCAL_SRC_FILES_linux := $(LIBADB_linux_SRC_FILES)
@@ -154,7 +155,7 @@
 
 # Even though we're building a static library (and thus there's no link step for
 # this to take effect), this adds the includes to our path.
-LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libbase
+LOCAL_STATIC_LIBRARIES := libcrypto_utils libcrypto libbase libmdnssd
 LOCAL_STATIC_LIBRARIES_linux := libusb
 LOCAL_STATIC_LIBRARIES_darwin := libusb
 
@@ -176,7 +177,7 @@
     shell_service_test.cpp \
 
 LOCAL_SANITIZE := $(adb_target_sanitize)
-LOCAL_STATIC_LIBRARIES := libadbd libcrypto_utils libcrypto libusb
+LOCAL_STATIC_LIBRARIES := libadbd libcrypto_utils libcrypto libusb libmdnssd
 LOCAL_SHARED_LIBRARIES := liblog libbase libcutils
 include $(BUILD_NATIVE_TEST)
 
@@ -224,7 +225,8 @@
     libcrypto \
     libcutils \
     libdiagnose_usb \
-    libgmock_host \
+    libmdnssd \
+    libgmock_host
 
 LOCAL_STATIC_LIBRARIES_linux := libusb
 LOCAL_STATIC_LIBRARIES_darwin := libusb
@@ -292,6 +294,7 @@
     libcrypto \
     libdiagnose_usb \
     liblog \
+    libmdnssd
 
 # Don't use libcutils on Windows.
 LOCAL_STATIC_LIBRARIES_darwin := libcutils
@@ -325,6 +328,7 @@
 
 LOCAL_SRC_FILES := \
     daemon/main.cpp \
+    daemon/mdns.cpp \
     services.cpp \
     file_sync_service.cpp \
     framebuffer_service.cpp \
@@ -372,6 +376,7 @@
     libcrypto_utils \
     libcrypto \
     libminijail \
+    libmdnssd \
     libdebuggerd_handler \
 
 include $(BUILD_EXECUTABLE)
diff --git a/adb/NOTICE b/adb/NOTICE
index 9ffcc08..ff47c95 100644
--- a/adb/NOTICE
+++ b/adb/NOTICE
@@ -189,3 +189,63 @@
 
    END OF TERMS AND CONDITIONS
 
+------------------------------------------------------------
+libwinpthread license:
+------------------------------------------------------------
+Copyright (c) 2011 mingw-w64 project
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+
+/*
+ * Parts of this library are derived by:
+ *
+ * Posix Threads library for Microsoft Windows
+ *
+ * Use at own risk, there is no implied warranty to this code.
+ * It uses undocumented features of Microsoft Windows that can change
+ * at any time in the future.
+ *
+ * (C) 2010 Lockless Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *  * Neither the name of Lockless Inc. nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AN
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
diff --git a/adb/adb_mdns.h b/adb/adb_mdns.h
new file mode 100644
index 0000000..2e544d7
--- /dev/null
+++ b/adb/adb_mdns.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 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 _ADB_MDNS_H_
+#define _ADB_MDNS_H_
+
+const char* kADBServiceType = "_adb._tcp";
+
+#endif
diff --git a/adb/client/main.cpp b/adb/client/main.cpp
index 97a54fd..606203c 100644
--- a/adb/client/main.cpp
+++ b/adb/client/main.cpp
@@ -117,6 +117,8 @@
 
     init_transport_registration();
 
+    init_mdns_transport_discovery();
+
     usb_init();
     local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
 
diff --git a/adb/daemon/main.cpp b/adb/daemon/main.cpp
index 6382b67..7da94ce 100644
--- a/adb/daemon/main.cpp
+++ b/adb/daemon/main.cpp
@@ -45,6 +45,8 @@
 #include "adb_utils.h"
 #include "transport.h"
 
+#include "mdns.h"
+
 static const char* root_seclabel = nullptr;
 
 static void drop_capabilities_bounding_set_if_needed(struct minijail *j) {
@@ -140,6 +142,11 @@
     }
 }
 
+static void setup_port(int port) {
+    local_init(port);
+    setup_mdns(port);
+}
+
 int adbd_main(int server_port) {
     umask(0);
 
@@ -188,10 +195,10 @@
     if (sscanf(prop_port.c_str(), "%d", &port) == 1 && port > 0) {
         D("using port=%d", port);
         // Listen on TCP port specified by service.adb.tcp.port property.
-        local_init(port);
+        setup_port(port);
     } else if (!is_usb) {
         // Listen on default port.
-        local_init(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
+        setup_port(DEFAULT_ADB_LOCAL_TRANSPORT_PORT);
     }
 
     D("adbd_main(): pre init_jdwp()");
diff --git a/adb/daemon/mdns.cpp b/adb/daemon/mdns.cpp
new file mode 100644
index 0000000..7811143
--- /dev/null
+++ b/adb/daemon/mdns.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2016 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 "adb_mdns.h"
+#include "sysdeps.h"
+
+#include <chrono>
+#include <dns_sd.h>
+#include <endian.h>
+#include <mutex>
+#include <unistd.h>
+
+#include <android-base/logging.h>
+#include <android-base/properties.h>
+
+using namespace std::chrono_literals;
+
+static std::mutex& mdns_lock = *new std::mutex();
+static int port;
+static DNSServiceRef mdns_ref;
+static bool mdns_registered = false;
+
+static void start_mdns() {
+    if (android::base::GetProperty("init.svc.mdnsd", "") == "running") {
+        return;
+    }
+
+    android::base::SetProperty("ctl.start", "mdnsd");
+
+    if (! android::base::WaitForProperty("init.svc.mdnsd", "running", 5s)) {
+        LOG(ERROR) << "Could not start mdnsd.";
+    }
+}
+
+static void mdns_callback(DNSServiceRef /*ref*/,
+                          DNSServiceFlags /*flags*/,
+                          DNSServiceErrorType errorCode,
+                          const char* /*name*/,
+                          const char* /*regtype*/,
+                          const char* /*domain*/,
+                          void* /*context*/) {
+    if (errorCode != kDNSServiceErr_NoError) {
+        LOG(ERROR) << "Encountered mDNS registration error ("
+            << errorCode << ").";
+    }
+}
+
+static void setup_mdns_thread(void* /* unused */) {
+    start_mdns();
+    std::lock_guard<std::mutex> lock(mdns_lock);
+
+    std::string hostname = "adb-";
+    hostname += android::base::GetProperty("ro.serialno", "unidentified");
+
+    auto error = DNSServiceRegister(&mdns_ref, 0, 0, hostname.c_str(),
+                                    kADBServiceType, nullptr, nullptr,
+                                    htobe16((uint16_t)port), 0, nullptr,
+                                    mdns_callback, nullptr);
+
+    if (error != kDNSServiceErr_NoError) {
+        LOG(ERROR) << "Could not register mDNS service (" << error << ").";
+        mdns_registered = false;
+    }
+
+    mdns_registered = true;
+}
+
+static void teardown_mdns() {
+    std::lock_guard<std::mutex> lock(mdns_lock);
+
+    if (mdns_registered) {
+        DNSServiceRefDeallocate(mdns_ref);
+    }
+}
+
+void setup_mdns(int port_in) {
+    port = port_in;
+    adb_thread_create(setup_mdns_thread, nullptr, nullptr);
+
+    // TODO: Make this more robust against a hard kill.
+    atexit(teardown_mdns);
+}
diff --git a/adb/daemon/mdns.h b/adb/daemon/mdns.h
new file mode 100644
index 0000000..4c6b1ca
--- /dev/null
+++ b/adb/daemon/mdns.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 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 _DAEMON_MDNS_H_
+#define _DAEMON_MDNS_H_
+
+void setup_mdns(int port);
+
+#endif  // _DAEMON_MDNS_H_
diff --git a/adb/daemon/usb.cpp b/adb/daemon/usb.cpp
index c08b922..92e9039 100644
--- a/adb/daemon/usb.cpp
+++ b/adb/daemon/usb.cpp
@@ -283,6 +283,8 @@
             D("[ %s: writing strings failed: errno=%d]", USB_FFS_ADB_EP0, errno);
             goto err;
         }
+        //Signal only when writing the descriptors to ffs
+        android::base::SetProperty("sys.usb.ffs.ready", "1");
     }
 
     h->bulk_out = adb_open(USB_FFS_ADB_OUT, O_RDWR);
@@ -358,7 +360,6 @@
             }
             std::this_thread::sleep_for(1s);
         }
-        android::base::SetProperty("sys.usb.ffs.ready", "1");
 
         D("[ usb_thread - registering device ]");
         register_usb_transport(usb, 0, 0, 1);
diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp
index 3135aa4..9589d88 100644
--- a/adb/jdwp_service.cpp
+++ b/adb/jdwp_service.cpp
@@ -571,7 +571,8 @@
     remove_socket(s);
 
     auto pred = [s](const auto& tracker) { return tracker.get() == s; };
-    std::remove_if(_jdwp_trackers.begin(), _jdwp_trackers.end(), pred);
+    _jdwp_trackers.erase(std::remove_if(_jdwp_trackers.begin(), _jdwp_trackers.end(), pred),
+                         _jdwp_trackers.end());
 }
 
 static void jdwp_tracker_ready(asocket* s) {
diff --git a/adb/remount_service.cpp b/adb/remount_service.cpp
index 5ca73cc..32ed28f 100644
--- a/adb/remount_service.cpp
+++ b/adb/remount_service.cpp
@@ -54,12 +54,10 @@
 
 // Returns the device used to mount a directory in the fstab.
 static std::string find_fstab_mount(const char* dir) {
-    std::string fstab_filename = "/fstab." + android::base::GetProperty("ro.hardware", "");
-    struct fstab* fstab = fs_mgr_read_fstab(fstab_filename.c_str());
-    struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab, dir);
-    std::string dev = rec ? std::string(rec->blk_device) : "";
-    fs_mgr_free_fstab(fstab);
-    return dev;
+    std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
+                                                               fs_mgr_free_fstab);
+    struct fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab.get(), dir);
+    return rec ? rec->blk_device : "";
 }
 
 // The proc entry for / is full of lies, so check fstab instead.
diff --git a/adb/services.cpp b/adb/services.cpp
index a48d855..47f0a03 100644
--- a/adb/services.cpp
+++ b/adb/services.cpp
@@ -377,45 +377,6 @@
     D("wait_for_state is done");
 }
 
-static void connect_device(const std::string& address, std::string* response) {
-    if (address.empty()) {
-        *response = "empty address";
-        return;
-    }
-
-    std::string serial;
-    std::string host;
-    int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
-    if (!android::base::ParseNetAddress(address, &host, &port, &serial, response)) {
-        return;
-    }
-
-    std::string error;
-    int fd = network_connect(host.c_str(), port, SOCK_STREAM, 10, &error);
-    if (fd == -1) {
-        *response = android::base::StringPrintf("unable to connect to %s: %s",
-                                                serial.c_str(), error.c_str());
-        return;
-    }
-
-    D("client: connected %s remote on fd %d", serial.c_str(), fd);
-    close_on_exec(fd);
-    disable_tcp_nagle(fd);
-
-    // Send a TCP keepalive ping to the device every second so we can detect disconnects.
-    if (!set_tcp_keepalive(fd, 1)) {
-        D("warning: failed to configure TCP keepalives (%s)", strerror(errno));
-    }
-
-    int ret = register_socket_transport(fd, serial.c_str(), port, 0);
-    if (ret < 0) {
-        adb_close(fd);
-        *response = android::base::StringPrintf("already connected to %s", serial.c_str());
-    } else {
-        *response = android::base::StringPrintf("connected to %s", serial.c_str());
-    }
-}
-
 void connect_emulator(const std::string& port_spec, std::string* response) {
     std::vector<std::string> pieces = android::base::Split(port_spec, ",");
     if (pieces.size() != 2) {
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 654072c..f195b4e 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -197,6 +197,7 @@
 extern int  adb_lseek(int  fd, int  pos, int  where);
 extern int  adb_shutdown(int  fd);
 extern int  adb_close(int  fd);
+extern int  adb_register_socket(SOCKET s);
 
 // See the comments for the !defined(_WIN32) version of unix_close().
 static __inline__ int  unix_close(int fd)
@@ -523,6 +524,12 @@
 #undef   close
 #define  close   ____xxx_close
 
+// On Windows, ADB has an indirection layer for file descriptors. If we get a
+// Win32 SOCKET object from an external library, we have to map it in to that
+// indirection layer, which this does.
+__inline__ int  adb_register_socket(int s) {
+    return s;
+}
 
 static __inline__  int  adb_read(int  fd, void*  buf, size_t  len)
 {
diff --git a/adb/sysdeps_win32.cpp b/adb/sysdeps_win32.cpp
index a4b5e69..f997e6b 100644
--- a/adb/sysdeps_win32.cpp
+++ b/adb/sysdeps_win32.cpp
@@ -126,10 +126,7 @@
         SOCKET      socket;
     } u;
 
-    int       mask;
-
     char  name[32];
-
 } FHRec;
 
 #define  fh_handle  u.handle
@@ -577,7 +574,6 @@
 
 static void _fh_socket_init(FH f) {
     f->fh_socket = INVALID_SOCKET;
-    f->mask      = 0;
 }
 
 static int _fh_socket_close( FH  f ) {
@@ -598,7 +594,6 @@
         }
         f->fh_socket = INVALID_SOCKET;
     }
-    f->mask = 0;
     return 0;
 }
 
@@ -913,6 +908,12 @@
     return fd;
 }
 
+int  adb_register_socket(SOCKET s) {
+    FH f = _fh_alloc( &_fh_socket_class );
+    f->fh_socket = s;
+    return _fh_to_int(f);
+}
+
 #undef accept
 int  adb_socket_accept(int  serverfd, struct sockaddr*  addr, socklen_t  *addrlen)
 {
@@ -1113,18 +1114,22 @@
 
     if (!fh || !fh->used) {
         errno = EBADF;
+        D("Setting nonblocking on bad file descriptor %d", fd);
         return false;
     }
 
     if (fh->clazz == &_fh_socket_class) {
         u_long x = !block;
         if (ioctlsocket(fh->u.socket, FIONBIO, &x) != 0) {
-            _socket_set_errno(WSAGetLastError());
+            int error = WSAGetLastError();
+            _socket_set_errno(error);
+            D("Setting %d nonblocking failed (%d)", fd, error);
             return false;
         }
         return true;
     } else {
         errno = ENOTSOCK;
+        D("Setting nonblocking on non-socket %d", fd);
         return false;
     }
 }
diff --git a/adb/transport.h b/adb/transport.h
index 490e513..4d97fc7 100644
--- a/adb/transport.h
+++ b/adb/transport.h
@@ -187,6 +187,7 @@
 void update_transports(void);
 
 void init_transport_registration(void);
+void init_mdns_transport_discovery(void);
 std::string list_transports(bool long_listing);
 atransport* find_transport(const char* serial);
 void kick_all_tcp_devices();
@@ -194,6 +195,9 @@
 void register_usb_transport(usb_handle* h, const char* serial,
                             const char* devpath, unsigned writeable);
 
+/* Connect to a network address and register it as a device */
+void connect_device(const std::string& address, std::string* response);
+
 /* cause new transports to be init'd and added to the list */
 int register_socket_transport(int s, const char* serial, int port, int local);
 
diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp
index b5d0ef0..12b98ba 100644
--- a/adb/transport_local.cpp
+++ b/adb/transport_local.cpp
@@ -30,6 +30,7 @@
 #include <thread>
 #include <vector>
 
+#include <android-base/parsenetaddress.h>
 #include <android-base/stringprintf.h>
 #include <cutils/sockets.h>
 
@@ -101,6 +102,46 @@
     return local_connect_arbitrary_ports(port-1, port, &dummy) == 0;
 }
 
+void connect_device(const std::string& address, std::string* response) {
+    if (address.empty()) {
+        *response = "empty address";
+        return;
+    }
+
+    std::string serial;
+    std::string host;
+    int port = DEFAULT_ADB_LOCAL_TRANSPORT_PORT;
+    if (!android::base::ParseNetAddress(address, &host, &port, &serial, response)) {
+        return;
+    }
+
+    std::string error;
+    int fd = network_connect(host.c_str(), port, SOCK_STREAM, 10, &error);
+    if (fd == -1) {
+        *response = android::base::StringPrintf("unable to connect to %s: %s",
+                                                serial.c_str(), error.c_str());
+        return;
+    }
+
+    D("client: connected %s remote on fd %d", serial.c_str(), fd);
+    close_on_exec(fd);
+    disable_tcp_nagle(fd);
+
+    // Send a TCP keepalive ping to the device every second so we can detect disconnects.
+    if (!set_tcp_keepalive(fd, 1)) {
+        D("warning: failed to configure TCP keepalives (%s)", strerror(errno));
+    }
+
+    int ret = register_socket_transport(fd, serial.c_str(), port, 0);
+    if (ret < 0) {
+        adb_close(fd);
+        *response = android::base::StringPrintf("already connected to %s", serial.c_str());
+    } else {
+        *response = android::base::StringPrintf("connected to %s", serial.c_str());
+    }
+}
+
+
 int local_connect_arbitrary_ports(int console_port, int adb_port, std::string* error) {
     int fd = -1;
 
diff --git a/adb/transport_mdns.cpp b/adb/transport_mdns.cpp
new file mode 100644
index 0000000..e49b1c6
--- /dev/null
+++ b/adb/transport_mdns.cpp
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#define TRACE_TAG TRANSPORT
+
+#include "transport.h"
+
+#ifdef _WIN32
+#include <winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+#include <android-base/stringprintf.h>
+#include <dns_sd.h>
+
+#include "adb_mdns.h"
+#include "adb_trace.h"
+#include "fdevent.h"
+#include "sysdeps.h"
+
+static DNSServiceRef service_ref;
+static fdevent service_ref_fde;
+
+// Use adb_DNSServiceRefSockFD() instead of calling DNSServiceRefSockFD()
+// directly so that the socket is put through the appropriate compatibility
+// layers to work with the rest of ADB's internal APIs.
+static inline int adb_DNSServiceRefSockFD(DNSServiceRef ref) {
+    return adb_register_socket(DNSServiceRefSockFD(ref));
+}
+#define DNSServiceRefSockFD ___xxx_DNSServiceRefSockFD
+
+static void DNSSD_API register_service_ip(DNSServiceRef sdRef,
+                                          DNSServiceFlags flags,
+                                          uint32_t interfaceIndex,
+                                          DNSServiceErrorType errorCode,
+                                          const char* hostname,
+                                          const sockaddr* address,
+                                          uint32_t ttl,
+                                          void* context);
+
+static void pump_service_ref(int /*fd*/, unsigned ev, void* data) {
+    DNSServiceRef* ref = reinterpret_cast<DNSServiceRef*>(data);
+
+    if (ev & FDE_READ)
+        DNSServiceProcessResult(*ref);
+}
+
+class AsyncServiceRef {
+  public:
+    bool Initialized() {
+        return initialized_;
+    }
+
+    virtual ~AsyncServiceRef() {
+        if (! initialized_) {
+            return;
+        }
+
+        DNSServiceRefDeallocate(sdRef_);
+        fdevent_remove(&fde_);
+    }
+
+  protected:
+    DNSServiceRef sdRef_;
+
+    void Initialize() {
+        fdevent_install(&fde_, adb_DNSServiceRefSockFD(sdRef_),
+                        pump_service_ref, &sdRef_);
+        fdevent_set(&fde_, FDE_READ);
+        initialized_ = true;
+    }
+
+  private:
+    bool initialized_;
+    fdevent fde_;
+};
+
+class ResolvedService : public AsyncServiceRef {
+  public:
+    virtual ~ResolvedService() = default;
+
+    ResolvedService(std::string name, uint32_t interfaceIndex,
+                    const char* hosttarget, uint16_t port) :
+            name_(name),
+            port_(port) {
+
+        /* TODO: We should be able to get IPv6 support by adding
+         * kDNSServiceProtocol_IPv6 to the flags below. However, when we do
+         * this, we get served link-local addresses that are usually useless to
+         * connect to. What's more, we seem to /only/ get those and nothing else.
+         * If we want IPv6 in the future we'll have to figure out why.
+         */
+        DNSServiceErrorType ret =
+            DNSServiceGetAddrInfo(
+                &sdRef_, 0, interfaceIndex,
+                kDNSServiceProtocol_IPv4, hosttarget,
+                register_service_ip, reinterpret_cast<void*>(this));
+
+        if (ret != kDNSServiceErr_NoError) {
+            D("Got %d from DNSServiceGetAddrInfo.", ret);
+        } else {
+            Initialize();
+        }
+    }
+
+    void Connect(const sockaddr* address) {
+        char ip_addr[INET6_ADDRSTRLEN];
+        const void* ip_addr_data;
+        const char* addr_format;
+
+        if (address->sa_family == AF_INET) {
+            ip_addr_data =
+                &reinterpret_cast<const sockaddr_in*>(address)->sin_addr;
+            addr_format = "%s:%hu";
+        } else if (address->sa_family == AF_INET6) {
+            ip_addr_data =
+                &reinterpret_cast<const sockaddr_in6*>(address)->sin6_addr;
+            addr_format = "[%s]:%hu";
+        } else { // Should be impossible
+            D("mDNS resolved non-IP address.");
+            return;
+        }
+
+        // Winsock version requires the const cast Because Microsoft.
+        if (!inet_ntop(address->sa_family, const_cast<void*>(ip_addr_data),
+                       ip_addr, INET6_ADDRSTRLEN)) {
+            D("Could not convert IP address to string.");
+            return;
+        }
+
+        std::string response;
+        connect_device(android::base::StringPrintf(addr_format, ip_addr, port_),
+                       &response);
+        D("Connect to %s (%s:%hu) : %s", name_.c_str(), ip_addr, port_,
+          response.c_str());
+    }
+
+  private:
+    std::string name_;
+    const uint16_t port_;
+};
+
+static void DNSSD_API register_service_ip(DNSServiceRef /*sdRef*/,
+                                          DNSServiceFlags /*flags*/,
+                                          uint32_t /*interfaceIndex*/,
+                                          DNSServiceErrorType /*errorCode*/,
+                                          const char* /*hostname*/,
+                                          const sockaddr* address,
+                                          uint32_t /*ttl*/,
+                                          void* context) {
+    D("Got IP for service.");
+    std::unique_ptr<ResolvedService> data(
+        reinterpret_cast<ResolvedService*>(context));
+    data->Connect(address);
+}
+
+static void DNSSD_API register_resolved_mdns_service(DNSServiceRef sdRef,
+                                                     DNSServiceFlags flags,
+                                                     uint32_t interfaceIndex,
+                                                     DNSServiceErrorType errorCode,
+                                                     const char* fullname,
+                                                     const char* hosttarget,
+                                                     uint16_t port,
+                                                     uint16_t txtLen,
+                                                     const unsigned char* txtRecord,
+                                                     void* context);
+
+class DiscoveredService : public AsyncServiceRef {
+  public:
+    DiscoveredService(uint32_t interfaceIndex, const char* serviceName,
+                      const char* regtype, const char* domain)
+        : serviceName_(serviceName) {
+
+        DNSServiceErrorType ret =
+            DNSServiceResolve(&sdRef_, 0, interfaceIndex, serviceName, regtype,
+                              domain, register_resolved_mdns_service,
+                              reinterpret_cast<void*>(this));
+
+        if (ret != kDNSServiceErr_NoError) {
+            D("Got %d from DNSServiceResolve.", ret);
+        } else {
+            Initialize();
+        }
+    }
+
+    const char* ServiceName() {
+        return serviceName_.c_str();
+    }
+
+  private:
+    std::string serviceName_;
+};
+
+static void DNSSD_API register_resolved_mdns_service(DNSServiceRef sdRef,
+                                                     DNSServiceFlags flags,
+                                                     uint32_t interfaceIndex,
+                                                     DNSServiceErrorType errorCode,
+                                                     const char* fullname,
+                                                     const char* hosttarget,
+                                                     uint16_t port,
+                                                     uint16_t /*txtLen*/,
+                                                     const unsigned char* /*txtRecord*/,
+                                                     void* context) {
+    D("Resolved a service.");
+    std::unique_ptr<DiscoveredService> discovered(
+        reinterpret_cast<DiscoveredService*>(context));
+
+    if (errorCode != kDNSServiceErr_NoError) {
+        D("Got error %d resolving service.", errorCode);
+        return;
+    }
+
+
+    auto resolved =
+        new ResolvedService(discovered->ServiceName(),
+                            interfaceIndex, hosttarget, ntohs(port));
+
+    if (! resolved->Initialized()) {
+        delete resolved;
+    }
+
+    if (flags) { /* Only ever equals MoreComing or 0 */
+        discovered.release();
+    }
+}
+
+static void DNSSD_API register_mdns_transport(DNSServiceRef sdRef,
+                                              DNSServiceFlags flags,
+                                              uint32_t interfaceIndex,
+                                              DNSServiceErrorType errorCode,
+                                              const char* serviceName,
+                                              const char* regtype,
+                                              const char* domain,
+                                              void*  /*context*/) {
+    D("Registering a transport.");
+    if (errorCode != kDNSServiceErr_NoError) {
+        D("Got error %d during mDNS browse.", errorCode);
+        DNSServiceRefDeallocate(sdRef);
+        fdevent_remove(&service_ref_fde);
+        return;
+    }
+
+    auto discovered = new DiscoveredService(interfaceIndex, serviceName,
+                                            regtype, domain);
+
+    if (! discovered->Initialized()) {
+        delete discovered;
+    }
+}
+
+void init_mdns_transport_discovery(void) {
+    DNSServiceErrorType errorCode =
+        DNSServiceBrowse(&service_ref, 0, 0, kADBServiceType, nullptr,
+                         register_mdns_transport, nullptr);
+
+    if (errorCode != kDNSServiceErr_NoError) {
+        D("Got %d initiating mDNS browse.", errorCode);
+        return;
+    }
+
+    fdevent_install(&service_ref_fde,
+                    adb_DNSServiceRefSockFD(service_ref),
+                    pump_service_ref,
+                    &service_ref);
+    fdevent_set(&service_ref_fde, FDE_READ);
+}
diff --git a/adb/transport_mdns_unsupported.cpp b/adb/transport_mdns_unsupported.cpp
new file mode 100644
index 0000000..387d341
--- /dev/null
+++ b/adb/transport_mdns_unsupported.cpp
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+/* For when mDNS discovery is unsupported */
+void init_mdns_transport_discovery(void) {}
diff --git a/debuggerd/Android.bp b/debuggerd/Android.bp
index 8d2ea68..af84be9 100644
--- a/debuggerd/Android.bp
+++ b/debuggerd/Android.bp
@@ -8,17 +8,35 @@
         "-Os",
     ],
 
+    // util.cpp gets async signal safe logging via libc_logging,
+    // which defines its interface in bionic private headers.
+    include_dirs: ["bionic/libc"],
+
     local_include_dirs: ["include"],
 }
 
+// Utility library to tombstoned and get an output fd.
+cc_library_static {
+    name: "libtombstoned_client",
+    defaults: ["debuggerd_defaults"],
+    srcs: [
+        "tombstoned_client.cpp",
+        "util.cpp",
+    ],
+
+    whole_static_libs: [
+        "libc_logging",
+        "libcutils",
+        "libbase",
+    ],
+}
+
+// Core implementation, linked into libdebuggerd_handler and the dynamic linker.
 cc_library_static {
     name: "libdebuggerd_handler_core",
     defaults: ["debuggerd_defaults"],
     srcs: ["handler/debuggerd_handler.cpp"],
 
-    // libdebuggerd_handler gets async signal safe logging via libc_logging,
-    // which defines its interface in bionic private headers.
-    include_dirs: ["bionic/libc"],
     whole_static_libs: [
         "libc_logging",
         "libdebuggerd",
@@ -27,6 +45,7 @@
     export_include_dirs: ["include"],
 }
 
+// Implementation with a no-op fallback.
 cc_library_static {
     name: "libdebuggerd_handler",
     defaults: ["debuggerd_defaults"],
@@ -39,15 +58,18 @@
     export_include_dirs: ["include"],
 }
 
+// Fallback implementation.
 cc_library_static {
     name: "libdebuggerd_handler_fallback",
     defaults: ["debuggerd_defaults"],
-    srcs: ["handler/debuggerd_fallback.cpp"],
+    srcs: [
+        "handler/debuggerd_fallback.cpp",
+    ],
 
-    // libdebuggerd_handler gets async signal safe logging via libc_logging,
-    // which defines its interface in bionic private headers.
-    include_dirs: ["bionic/libc"],
-    static_libs: [
+    whole_static_libs: [
+        "libdebuggerd_handler_core",
+        "libtombstoned_client",
+        "libbase",
         "libdebuggerd",
         "libbacktrace",
         "libunwind",
@@ -70,6 +92,7 @@
         "libbase",
         "libcutils",
     ],
+
     export_include_dirs: ["include"],
 }
 
@@ -187,6 +210,7 @@
     },
 
     static_libs: [
+        "libtombstoned_client",
         "libdebuggerd",
         "libcutils",
     ],
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 0e15472..57a6c44 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -48,6 +48,7 @@
 
 #include "debuggerd/handler.h"
 #include "debuggerd/protocol.h"
+#include "debuggerd/tombstoned.h"
 #include "debuggerd/util.h"
 
 using android::base::unique_fd;
@@ -128,55 +129,6 @@
   return true;
 }
 
-static bool tombstoned_connect(pid_t pid, unique_fd* tombstoned_socket, unique_fd* output_fd) {
-  unique_fd sockfd(socket_local_client(kTombstonedCrashSocketName,
-                                       ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET));
-  if (sockfd == -1) {
-    PLOG(ERROR) << "failed to connect to tombstoned";
-    return false;
-  }
-
-  TombstonedCrashPacket packet = {};
-  packet.packet_type = CrashPacketType::kDumpRequest;
-  packet.packet.dump_request.pid = pid;
-  if (TEMP_FAILURE_RETRY(write(sockfd, &packet, sizeof(packet))) != sizeof(packet)) {
-    PLOG(ERROR) << "failed to write DumpRequest packet";
-    return false;
-  }
-
-  unique_fd tmp_output_fd;
-  ssize_t rc = recv_fd(sockfd, &packet, sizeof(packet), &tmp_output_fd);
-  if (rc == -1) {
-    PLOG(ERROR) << "failed to read response to DumpRequest packet";
-    return false;
-  } else if (rc != sizeof(packet)) {
-    LOG(ERROR) << "read DumpRequest response packet of incorrect length (expected "
-               << sizeof(packet) << ", got " << rc << ")";
-    return false;
-  }
-
-  // Make the fd O_APPEND so that our output is guaranteed to be at the end of a file.
-  // (This also makes selinux rules consistent, because selinux distinguishes between writing to
-  // a regular fd, and writing to an fd with O_APPEND).
-  int flags = fcntl(tmp_output_fd.get(), F_GETFL);
-  if (fcntl(tmp_output_fd.get(), F_SETFL, flags | O_APPEND) != 0) {
-    PLOG(WARNING) << "failed to set output fd flags";
-  }
-
-  *tombstoned_socket = std::move(sockfd);
-  *output_fd = std::move(tmp_output_fd);
-  return true;
-}
-
-static bool tombstoned_notify_completion(int tombstoned_socket) {
-  TombstonedCrashPacket packet = {};
-  packet.packet_type = CrashPacketType::kCompletedDump;
-  if (TEMP_FAILURE_RETRY(write(tombstoned_socket, &packet, sizeof(packet))) != sizeof(packet)) {
-    return false;
-  }
-  return true;
-}
-
 static void signal_handler(int) {
   // We can't log easily, because the heap might be corrupt.
   // Just die and let the surrounding log context explain things.
@@ -196,7 +148,12 @@
     }
   }
 
-  dprintf(output_fd.get(), "crash_dump failed to dump process %d: %s\n", target, abort_msg);
+  dprintf(output_fd.get(), "crash_dump failed to dump process");
+  if (target != 1) {
+    dprintf(output_fd.get(), " %d: %s\n", target, abort_msg);
+  } else {
+    dprintf(output_fd.get(), ": %s\n", abort_msg);
+  }
 
   _exit(1);
 }
@@ -243,7 +200,7 @@
   pid_t pseudothread_tid;
 
   if (target == 1) {
-    LOG(FATAL) << "target died before we could attach";
+    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())) {
diff --git a/debuggerd/handler/debuggerd_fallback.cpp b/debuggerd/handler/debuggerd_fallback.cpp
index 77ad6ac..5c6c59c 100644
--- a/debuggerd/handler/debuggerd_fallback.cpp
+++ b/debuggerd/handler/debuggerd_fallback.cpp
@@ -26,23 +26,206 @@
  * SUCH DAMAGE.
  */
 
+#include <dirent.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <pthread.h>
 #include <stddef.h>
 #include <sys/ucontext.h>
+#include <syscall.h>
 #include <unistd.h>
 
+#include <atomic>
+
+#include <android-base/file.h>
+#include <android-base/unique_fd.h>
+
+#include "debuggerd/handler.h"
+#include "debuggerd/tombstoned.h"
+#include "debuggerd/util.h"
+
+#include "backtrace.h"
 #include "tombstone.h"
 
-extern "C" void __linker_use_fallback_allocator();
+#include "private/libc_logging.h"
 
-extern "C" bool debuggerd_fallback(ucontext_t* ucontext, siginfo_t* siginfo, void* abort_message) {
-  // This is incredibly sketchy to do inside of a signal handler, especially when libbacktrace
-  // uses the C++ standard library throughout, but this code runs in the linker, so we'll be using
-  // the linker's malloc instead of the libc one. Switch it out for a replacement, just in case.
-  //
-  // This isn't the default method of dumping because it can fail in cases such as memory space
-  // exhaustion.
-  __linker_use_fallback_allocator();
-  engrave_tombstone_ucontext(-1, getpid(), gettid(), reinterpret_cast<uintptr_t>(abort_message),
-                             siginfo, ucontext);
-  return true;
+using android::base::unique_fd;
+
+extern "C" void __linker_enable_fallback_allocator();
+extern "C" void __linker_disable_fallback_allocator();
+
+// This is incredibly sketchy to do inside of a signal handler, especially when libbacktrace
+// uses the C++ standard library throughout, but this code runs in the linker, so we'll be using
+// the linker's malloc instead of the libc one. Switch it out for a replacement, just in case.
+//
+// This isn't the default method of dumping because it can fail in cases such as address space
+// exhaustion.
+static void debuggerd_fallback_trace(int output_fd, ucontext_t* ucontext) {
+  __linker_enable_fallback_allocator();
+  dump_backtrace_ucontext(output_fd, ucontext);
+  __linker_disable_fallback_allocator();
+}
+
+static void debuggerd_fallback_tombstone(int output_fd, ucontext_t* ucontext, siginfo_t* siginfo,
+                                         void* abort_message) {
+  __linker_enable_fallback_allocator();
+  engrave_tombstone_ucontext(output_fd, reinterpret_cast<uintptr_t>(abort_message), siginfo,
+                             ucontext);
+  __linker_disable_fallback_allocator();
+}
+
+static void iterate_siblings(bool (*callback)(pid_t, int), int output_fd) {
+  pid_t current_tid = gettid();
+  char buf[BUFSIZ];
+  snprintf(buf, sizeof(buf), "/proc/%d/task", current_tid);
+  DIR* dir = opendir(buf);
+
+  if (!dir) {
+    __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to open %s: %s", buf, strerror(errno));
+    return;
+  }
+
+  struct dirent* ent;
+  while ((ent = readdir(dir))) {
+    char* end;
+    long tid = strtol(ent->d_name, &end, 10);
+    if (end == ent->d_name || *end != '\0') {
+      continue;
+    }
+
+    if (tid != current_tid) {
+      callback(tid, output_fd);
+    }
+  }
+  closedir(dir);
+}
+
+static bool forward_output(int src_fd, int dst_fd) {
+  // Make sure the thread actually got the signal.
+  struct pollfd pfd = {
+    .fd = src_fd, .events = POLLIN,
+  };
+
+  // Wait for up to a second for output to start flowing.
+  if (poll(&pfd, 1, 1000) != 1) {
+    return false;
+  }
+
+  while (true) {
+    char buf[512];
+    ssize_t rc = TEMP_FAILURE_RETRY(read(src_fd, buf, sizeof(buf)));
+    if (rc == 0) {
+      return true;
+    } else if (rc < 0) {
+      return false;
+    }
+
+    if (!android::base::WriteFully(dst_fd, buf, rc)) {
+      // We failed to write to tombstoned, but there's not much we can do.
+      // Keep reading from src_fd to keep things going.
+      continue;
+    }
+  }
+}
+
+static void trace_handler(siginfo_t* info, ucontext_t* ucontext) {
+  static std::atomic<int> trace_output_fd(-1);
+
+  if (info->si_value.sival_int == ~0) {
+    // Asked to dump by the original signal recipient.
+    debuggerd_fallback_trace(trace_output_fd, ucontext);
+
+    int tmp = trace_output_fd.load();
+    trace_output_fd.store(-1);
+    close(tmp);
+    return;
+  }
+
+  // Only allow one thread to perform a trace at a time.
+  static pthread_mutex_t trace_mutex = PTHREAD_MUTEX_INITIALIZER;
+  int ret = pthread_mutex_trylock(&trace_mutex);
+  if (ret != 0) {
+    __libc_format_log(ANDROID_LOG_INFO, "libc", "pthread_mutex_try_lock failed: %s", strerror(ret));
+    return;
+  }
+
+  // Fetch output fd from tombstoned.
+  unique_fd tombstone_socket, output_fd;
+  if (!tombstoned_connect(getpid(), &tombstone_socket, &output_fd)) {
+    goto exit;
+  }
+
+  dump_backtrace_header(output_fd.get());
+
+  // Dump our own stack.
+  debuggerd_fallback_trace(output_fd.get(), ucontext);
+
+  // Send a signal to all of our siblings, asking them to dump their stack.
+  iterate_siblings(
+    [](pid_t tid, int output_fd) {
+      // Use a pipe, to be able to detect situations where the thread gracefully exits before
+      // receiving our signal.
+      unique_fd pipe_read, pipe_write;
+      if (!Pipe(&pipe_read, &pipe_write)) {
+        __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to create pipe: %s", strerror(errno));
+        return false;
+      }
+
+      trace_output_fd.store(pipe_write.get());
+
+      siginfo_t siginfo = {};
+      siginfo.si_code = SI_QUEUE;
+      siginfo.si_value.sival_int = ~0;
+      siginfo.si_pid = getpid();
+      siginfo.si_uid = getuid();
+
+      if (syscall(__NR_rt_tgsigqueueinfo, getpid(), tid, DEBUGGER_SIGNAL, &siginfo) != 0) {
+        __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to send trace signal to %d: %s", tid,
+                          strerror(errno));
+        return false;
+      }
+
+      bool success = forward_output(pipe_read.get(), output_fd);
+      if (success) {
+        // The signaled thread has closed trace_output_fd already.
+        (void)pipe_write.release();
+      } else {
+        trace_output_fd.store(-1);
+      }
+
+      return true;
+    },
+    output_fd.get());
+
+  dump_backtrace_footer(output_fd.get());
+  tombstoned_notify_completion(tombstone_socket.get());
+
+exit:
+  pthread_mutex_unlock(&trace_mutex);
+}
+
+static void crash_handler(siginfo_t* info, ucontext_t* ucontext, void* abort_message) {
+  // Only allow one thread to handle a crash.
+  static pthread_mutex_t crash_mutex = PTHREAD_MUTEX_INITIALIZER;
+  int ret = pthread_mutex_lock(&crash_mutex);
+  if (ret != 0) {
+    __libc_format_log(ANDROID_LOG_INFO, "libc", "pthread_mutex_lock failed: %s", strerror(ret));
+    return;
+  }
+
+  unique_fd tombstone_socket, output_fd;
+  bool tombstoned_connected = tombstoned_connect(getpid(), &tombstone_socket, &output_fd);
+  debuggerd_fallback_tombstone(output_fd.get(), ucontext, info, abort_message);
+  if (tombstoned_connected) {
+    tombstoned_notify_completion(tombstone_socket.get());
+  }
+}
+
+extern "C" void debuggerd_fallback_handler(siginfo_t* info, ucontext_t* ucontext,
+                                           void* abort_message) {
+  if (info->si_signo == DEBUGGER_SIGNAL) {
+    return trace_handler(info, ucontext);
+  } else {
+    return crash_handler(info, ucontext, abort_message);
+  }
 }
diff --git a/debuggerd/handler/debuggerd_fallback_nop.cpp b/debuggerd/handler/debuggerd_fallback_nop.cpp
index 9b3053f..331301f 100644
--- a/debuggerd/handler/debuggerd_fallback_nop.cpp
+++ b/debuggerd/handler/debuggerd_fallback_nop.cpp
@@ -26,10 +26,5 @@
  * SUCH DAMAGE.
  */
 
-#include <stddef.h>
-#include <sys/ucontext.h>
-#include <unistd.h>
-
-extern "C" bool debuggerd_fallback(ucontext_t*, siginfo_t*, void*) {
-  return false;
+extern "C" void debuggerd_fallback_handler(struct siginfo_t*, struct ucontext_t*, void*) {
 }
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index 67c26e2..cf24d57 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -62,7 +62,20 @@
 
 #define CRASH_DUMP_PATH "/system/bin/" CRASH_DUMP_NAME
 
-extern "C" bool debuggerd_fallback(ucontext_t*, siginfo_t*, void*);
+class ErrnoRestorer {
+ public:
+  ErrnoRestorer() : saved_errno_(errno) {
+  }
+
+  ~ErrnoRestorer() {
+    errno = saved_errno_;
+  }
+
+ private:
+  int saved_errno_;
+};
+
+extern "C" void debuggerd_fallback_handler(siginfo_t*, ucontext_t*, void*);
 
 static debuggerd_callbacks_t g_callbacks;
 
@@ -323,20 +336,14 @@
       fatal_errno("failed to resend signal during crash");
     }
   }
-
-  if (info->si_signo == DEBUGGER_SIGNAL) {
-    pthread_mutex_unlock(&crash_mutex);
-  }
 }
 
 // Handler that does crash dumping by forking and doing the processing in the child.
 // Do this by ptracing the relevant thread, and then execing debuggerd to do the actual dump.
 static void debuggerd_signal_handler(int signal_number, siginfo_t* info, void* context) {
-  int ret = pthread_mutex_lock(&crash_mutex);
-  if (ret != 0) {
-    __libc_format_log(ANDROID_LOG_INFO, "libc", "pthread_mutex_lock failed: %s", strerror(ret));
-    return;
-  }
+  // Make sure we don't change the value of errno, in case a signal comes in between the process
+  // making a syscall and checking errno.
+  ErrnoRestorer restorer;
 
   // It's possible somebody cleared the SA_SIGINFO flag, which would mean
   // our "info" arg holds an undefined value.
@@ -359,24 +366,29 @@
     // check to allow all si_code values in calls coming from inside the house.
   }
 
-  log_signal_summary(signal_number, info);
-
   void* abort_message = nullptr;
   if (g_callbacks.get_abort_message) {
     abort_message = g_callbacks.get_abort_message();
   }
 
   if (prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0) == 1) {
-    ucontext_t* ucontext = static_cast<ucontext_t*>(context);
-    if (signal_number == DEBUGGER_SIGNAL || !debuggerd_fallback(ucontext, info, abort_message)) {
-      // The process has NO_NEW_PRIVS enabled, so we can't transition to the crash_dump context.
-      __libc_format_log(ANDROID_LOG_INFO, "libc",
-                        "Suppressing debuggerd output because prctl(PR_GET_NO_NEW_PRIVS)==1");
-    }
+    // This check might be racy if another thread sets NO_NEW_PRIVS, but this should be unlikely,
+    // you can only set NO_NEW_PRIVS to 1, and the effect should be at worst a single missing
+    // ANR trace.
+    debuggerd_fallback_handler(info, static_cast<ucontext_t*>(context), abort_message);
     resend_signal(info, false);
     return;
   }
 
+  // Only allow one thread to handle a signal at a time.
+  int ret = pthread_mutex_lock(&crash_mutex);
+  if (ret != 0) {
+    __libc_format_log(ANDROID_LOG_INFO, "libc", "pthread_mutex_lock failed: %s", strerror(ret));
+    return;
+  }
+
+  log_signal_summary(signal_number, info);
+
   // Populate si_value with the abort message address, if found.
   if (abort_message) {
     info->si_value.sival_ptr = abort_message;
@@ -427,6 +439,11 @@
   }
 
   resend_signal(info, thread_info.crash_dump_started);
+  if (info->si_signo == DEBUGGER_SIGNAL) {
+    // If the signal is fatal, don't unlock the mutex to prevent other crashing threads from
+    // starting to dump right before our death.
+    pthread_mutex_unlock(&crash_mutex);
+  }
 }
 
 void debuggerd_init(debuggerd_callbacks_t* callbacks) {
diff --git a/debuggerd/include/debuggerd/tombstoned.h b/debuggerd/include/debuggerd/tombstoned.h
new file mode 100644
index 0000000..d158d50
--- /dev/null
+++ b/debuggerd/include/debuggerd/tombstoned.h
@@ -0,0 +1,26 @@
+#pragma once
+
+/*
+ * Copyright 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 <sys/types.h>
+
+#include <android-base/unique_fd.h>
+
+bool tombstoned_connect(pid_t pid, android::base::unique_fd* tombstoned_socket,
+                        android::base::unique_fd* output_fd);
+
+bool tombstoned_notify_completion(int tombstoned_socket);
diff --git a/debuggerd/libdebuggerd/backtrace.cpp b/debuggerd/libdebuggerd/backtrace.cpp
index 0664442..df49aef 100644
--- a/debuggerd/libdebuggerd/backtrace.cpp
+++ b/debuggerd/libdebuggerd/backtrace.cpp
@@ -67,15 +67,15 @@
   _LOG(log, logtype::BACKTRACE, "\n----- end %d -----\n", pid);
 }
 
-static void dump_thread(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid) {
-  char path[PATH_MAX];
-  char threadnamebuf[1024];
-  char* threadname = NULL;
+static void log_thread_name(log_t* log, pid_t tid) {
   FILE* fp;
+  char buf[1024];
+  char path[PATH_MAX];
+  char* threadname = NULL;
 
   snprintf(path, sizeof(path), "/proc/%d/comm", tid);
   if ((fp = fopen(path, "r"))) {
-    threadname = fgets(threadnamebuf, sizeof(threadnamebuf), fp);
+    threadname = fgets(buf, sizeof(buf), fp);
     fclose(fp);
     if (threadname) {
       size_t len = strlen(threadname);
@@ -84,8 +84,11 @@
       }
     }
   }
-
   _LOG(log, logtype::BACKTRACE, "\n\"%s\" sysTid=%d\n", threadname ? threadname : "<unknown>", tid);
+}
+
+static void dump_thread(log_t* log, BacktraceMap* map, pid_t pid, pid_t tid) {
+  log_thread_name(log, tid);
 
   std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid, map));
   if (backtrace->Unwind(0)) {
@@ -112,6 +115,41 @@
   dump_process_footer(&log, pid);
 }
 
+void dump_backtrace_ucontext(int output_fd, ucontext_t* ucontext) {
+  pid_t pid = getpid();
+  pid_t tid = gettid();
+
+  log_t log;
+  log.tfd = output_fd;
+  log.amfd_data = nullptr;
+
+  log_thread_name(&log, tid);
+
+  std::unique_ptr<Backtrace> backtrace(Backtrace::Create(pid, tid));
+  if (backtrace->Unwind(0, ucontext)) {
+    dump_backtrace_to_log(backtrace.get(), &log, "  ");
+  } else {
+    ALOGE("Unwind failed: tid = %d: %s", tid,
+          backtrace->GetErrorString(backtrace->GetError()).c_str());
+  }
+}
+
+void dump_backtrace_header(int output_fd) {
+  log_t log;
+  log.tfd = output_fd;
+  log.amfd_data = nullptr;
+
+  dump_process_header(&log, getpid());
+}
+
+void dump_backtrace_footer(int output_fd) {
+  log_t log;
+  log.tfd = output_fd;
+  log.amfd_data = nullptr;
+
+  dump_process_footer(&log, getpid());
+}
+
 void dump_backtrace_to_log(Backtrace* backtrace, log_t* log, const char* prefix) {
   for (size_t i = 0; i < backtrace->NumFrames(); i++) {
     _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, backtrace->FormatFrameData(i).c_str());
diff --git a/debuggerd/libdebuggerd/include/backtrace.h b/debuggerd/libdebuggerd/include/backtrace.h
index acd5eaa..5bfdac8 100644
--- a/debuggerd/libdebuggerd/include/backtrace.h
+++ b/debuggerd/libdebuggerd/include/backtrace.h
@@ -18,6 +18,7 @@
 #define _DEBUGGERD_BACKTRACE_H
 
 #include <sys/types.h>
+#include <sys/ucontext.h>
 
 #include <set>
 #include <string>
@@ -35,4 +36,8 @@
 /* Dumps the backtrace in the backtrace data structure to the log. */
 void dump_backtrace_to_log(Backtrace* backtrace, log_t* log, const char* prefix);
 
+void dump_backtrace_ucontext(int output_fd, ucontext_t* ucontext);
+void dump_backtrace_header(int output_fd);
+void dump_backtrace_footer(int output_fd);
+
 #endif // _DEBUGGERD_BACKTRACE_H
diff --git a/debuggerd/libdebuggerd/include/tombstone.h b/debuggerd/libdebuggerd/include/tombstone.h
index aed71de..8e60278 100644
--- a/debuggerd/libdebuggerd/include/tombstone.h
+++ b/debuggerd/libdebuggerd/include/tombstone.h
@@ -39,7 +39,13 @@
                        const std::set<pid_t>* siblings, uintptr_t abort_msg_address,
                        std::string* amfd_data);
 
-void engrave_tombstone_ucontext(int tombstone_fd, pid_t pid, pid_t tid, uintptr_t abort_msg_address,
-                                siginfo_t* siginfo, ucontext_t* ucontext);
+void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo,
+                                ucontext_t* ucontext);
+
+// Compatibility shim.
+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);
+}
 
 #endif // _DEBUGGERD_TOMBSTONE_H
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 4686bfd..c05ccc3 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -751,8 +751,11 @@
   dump_crash(&log, map, open_files, pid, tid, siblings, abort_msg_address);
 }
 
-void engrave_tombstone_ucontext(int tombstone_fd, pid_t pid, pid_t tid, uintptr_t abort_msg_address,
-                                siginfo_t* siginfo, ucontext_t* ucontext) {
+void engrave_tombstone_ucontext(int tombstone_fd, uintptr_t abort_msg_address, siginfo_t* siginfo,
+                                ucontext_t* ucontext) {
+  pid_t pid = getpid();
+  pid_t tid = gettid();
+
   log_t log;
   log.current_tid = tid;
   log.crashed_tid = tid;
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp
index 57209aa..744cd72 100644
--- a/debuggerd/libdebuggerd/utility.cpp
+++ b/debuggerd/libdebuggerd/utility.cpp
@@ -41,6 +41,7 @@
   return false;
 }
 
+__attribute__((__weak__, visibility("default")))
 void _LOG(log_t* log, enum logtype ltype, const char* fmt, ...) {
   bool write_to_tombstone = (log->tfd != -1);
   bool write_to_logcat = is_allowed_in_logcat(ltype)
diff --git a/debuggerd/tombstoned/tombstoned.cpp b/debuggerd/tombstoned/tombstoned.cpp
index 8705ece..6754508 100644
--- a/debuggerd/tombstoned/tombstoned.cpp
+++ b/debuggerd/tombstoned/tombstoned.cpp
@@ -34,6 +34,7 @@
 #include <android-base/unique_fd.h>
 #include <cutils/sockets.h>
 
+#include "debuggerd/handler.h"
 #include "debuggerd/protocol.h"
 #include "debuggerd/util.h"
 
@@ -116,7 +117,7 @@
   }
 
   result.reset(
-    openat(tombstone_directory_fd, buf, O_CREAT | O_EXCL | O_WRONLY | O_APPEND | O_CLOEXEC, 0700));
+    openat(tombstone_directory_fd, buf, O_CREAT | O_EXCL | O_WRONLY | O_APPEND | O_CLOEXEC, 0640));
   if (result == -1) {
     PLOG(FATAL) << "failed to create tombstone at " << kTombstoneDirectory << buf;
   }
@@ -254,6 +255,16 @@
 }
 
 int main(int, char* []) {
+  umask(0137);
+
+  // Don't try to connect to ourselves if we crash.
+  struct sigaction action = {};
+  action.sa_handler = [](int signal) {
+    LOG(ERROR) << "received fatal signal " << signal;
+    _exit(1);
+  };
+  debuggerd_register_handlers(&action);
+
   tombstone_directory_fd = open(kTombstoneDirectory, O_DIRECTORY | O_RDONLY | O_CLOEXEC);
   if (tombstone_directory_fd == -1) {
     PLOG(FATAL) << "failed to open tombstone directory";
diff --git a/debuggerd/tombstoned_client.cpp b/debuggerd/tombstoned_client.cpp
new file mode 100644
index 0000000..03b4a20
--- /dev/null
+++ b/debuggerd/tombstoned_client.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright 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 "debuggerd/tombstoned.h"
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <utility>
+
+#include <android-base/unique_fd.h>
+#include <cutils/sockets.h>
+
+#include "debuggerd/protocol.h"
+#include "debuggerd/util.h"
+#include "private/libc_logging.h"
+
+using android::base::unique_fd;
+
+bool tombstoned_connect(pid_t pid, unique_fd* tombstoned_socket, unique_fd* output_fd) {
+  unique_fd sockfd(socket_local_client(kTombstonedCrashSocketName,
+                                       ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET));
+  if (sockfd == -1) {
+    __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to connect to tombstoned: %s",
+                      strerror(errno));
+    return false;
+  }
+
+  TombstonedCrashPacket packet = {};
+  packet.packet_type = CrashPacketType::kDumpRequest;
+  packet.packet.dump_request.pid = pid;
+  if (TEMP_FAILURE_RETRY(write(sockfd, &packet, sizeof(packet))) != sizeof(packet)) {
+    __libc_format_log(ANDROID_LOG_ERROR, "libc", "failed to write DumpRequest packet: %s",
+                      strerror(errno));
+    return false;
+  }
+
+  unique_fd tmp_output_fd;
+  ssize_t rc = recv_fd(sockfd, &packet, sizeof(packet), &tmp_output_fd);
+  if (rc == -1) {
+    __libc_format_log(ANDROID_LOG_ERROR, "libc",
+                      "failed to read response to DumpRequest packet: %s", strerror(errno));
+    return false;
+  } else if (rc != sizeof(packet)) {
+    __libc_format_log(
+      ANDROID_LOG_ERROR, "libc",
+      "received DumpRequest response packet of incorrect length (expected %zu, got %zd)",
+      sizeof(packet), rc);
+    return false;
+  }
+
+  // Make the fd O_APPEND so that our output is guaranteed to be at the end of a file.
+  // (This also makes selinux rules consistent, because selinux distinguishes between writing to
+  // a regular fd, and writing to an fd with O_APPEND).
+  int flags = fcntl(tmp_output_fd.get(), F_GETFL);
+  if (fcntl(tmp_output_fd.get(), F_SETFL, flags | O_APPEND) != 0) {
+    __libc_format_log(ANDROID_LOG_WARN, "libc", "failed to set output fd flags: %s",
+                      strerror(errno));
+  }
+
+  *tombstoned_socket = std::move(sockfd);
+  *output_fd = std::move(tmp_output_fd);
+  return true;
+}
+
+bool tombstoned_notify_completion(int tombstoned_socket) {
+  TombstonedCrashPacket packet = {};
+  packet.packet_type = CrashPacketType::kCompletedDump;
+  if (TEMP_FAILURE_RETRY(write(tombstoned_socket, &packet, sizeof(packet))) != sizeof(packet)) {
+    return false;
+  }
+  return true;
+}
diff --git a/debuggerd/util.cpp b/debuggerd/util.cpp
index 738abdf..4c015d7 100644
--- a/debuggerd/util.cpp
+++ b/debuggerd/util.cpp
@@ -22,8 +22,13 @@
 
 #include <android-base/unique_fd.h>
 #include <cutils/sockets.h>
+#include <debuggerd/protocol.h>
 
-ssize_t send_fd(int sockfd, const void* data, size_t len, android::base::unique_fd fd) {
+#include "private/libc_logging.h"
+
+using android::base::unique_fd;
+
+ssize_t send_fd(int sockfd, const void* data, size_t len, unique_fd fd) {
   char cmsg_buf[CMSG_SPACE(sizeof(int))];
 
   iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len };
@@ -39,8 +44,7 @@
   return TEMP_FAILURE_RETRY(sendmsg(sockfd, &msg, 0));
 }
 
-ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len,
-                android::base::unique_fd* _Nullable out_fd) {
+ssize_t recv_fd(int sockfd, void* _Nonnull data, size_t len, unique_fd* _Nullable out_fd) {
   char cmsg_buf[CMSG_SPACE(sizeof(int))];
 
   iovec iov = { .iov_base = const_cast<void*>(data), .iov_len = len };
@@ -61,7 +65,7 @@
     return -1;
   }
 
-  android::base::unique_fd fd;
+  unique_fd fd;
   bool received_fd = msg.msg_controllen == sizeof(cmsg_buf);
   if (received_fd) {
     fd.reset(*reinterpret_cast<int*>(CMSG_DATA(cmsg)));
@@ -85,7 +89,7 @@
   return result;
 }
 
-bool Pipe(android::base::unique_fd* read, android::base::unique_fd* write) {
+bool Pipe(unique_fd* read, unique_fd* write) {
   int pipefds[2];
   if (pipe(pipefds) != 0) {
     return false;
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index a50817e..6c84d73 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -31,6 +31,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <android-base/file.h>
+#include <android-base/stringprintf.h>
 #include <android-base/unique_fd.h>
 #include <cutils/android_reboot.h>
 #include <cutils/partition_utils.h>
@@ -64,6 +66,21 @@
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
 
+// record fs stat
+enum FsStatFlags {
+    FS_STAT_IS_EXT4           = 0x0001,
+    FS_STAT_NEW_IMAGE_VERSION = 0x0002,
+    FS_STAT_E2FSCK_F_ALWAYS   = 0x0004,
+    FS_STAT_UNCLEAN_SHUTDOWN  = 0x0008,
+    FS_STAT_QUOTA_ENABLED     = 0x0010,
+    FS_STAT_TUNE2FS_FAILED    = 0x0020,
+    FS_STAT_RO_MOUNT_FAILED   = 0x0040,
+    FS_STAT_RO_UNMOUNT_FAILED = 0x0080,
+    FS_STAT_FULL_MOUNT_FAILED = 0x0100,
+    FS_STAT_E2FSCK_FAILED     = 0x0200,
+    FS_STAT_E2FSCK_FS_FIXED   = 0x0400,
+};
+
 /*
  * gettime() - returns the time in seconds of the system's monotonic clock or
  * zero on error.
@@ -94,7 +111,18 @@
     return ret;
 }
 
-static void check_fs(const char *blk_device, char *fs_type, char *target)
+static void log_fs_stat(const char* blk_device, int fs_stat)
+{
+    if ((fs_stat & FS_STAT_IS_EXT4) == 0) return; // only log ext4
+    std::string msg = android::base::StringPrintf("\nfs_stat,%s,0x%x\n", blk_device, fs_stat);
+    android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(FSCK_LOG_FILE, O_WRONLY | O_CLOEXEC |
+                                                        O_APPEND | O_CREAT, 0664)));
+    if (fd == -1 || !android::base::WriteStringToFd(msg, fd)) {
+        LWARNING << __FUNCTION__ << "() cannot log " << msg;
+    }
+}
+
+static void check_fs(const char *blk_device, char *fs_type, char *target, int *fs_stat)
 {
     int status;
     int ret;
@@ -141,10 +169,13 @@
                           << ") succeeded";
                     break;
                 }
+                *fs_stat |= FS_STAT_RO_UNMOUNT_FAILED;
                 PERROR << __FUNCTION__ << "(): umount(" << target << ")="
                        << result;
                 sleep(1);
             }
+        } else {
+            *fs_stat |= FS_STAT_RO_MOUNT_FAILED;
         }
 
         /*
@@ -157,6 +188,7 @@
         } else {
             LINFO << "Running " << E2FSCK_BIN << " on " << blk_device;
 
+            *fs_stat |= FS_STAT_E2FSCK_F_ALWAYS;
             ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv),
                                           const_cast<char **>(e2fsck_argv),
                                           &status, true, LOG_KLOG | LOG_FILE,
@@ -167,6 +199,10 @@
             if (ret < 0) {
                 /* No need to check for error in fork, we can't really handle it now */
                 LERROR << "Failed trying to run " << E2FSCK_BIN;
+                *fs_stat |= FS_STAT_E2FSCK_FAILED;
+            } else if (status != 0) {
+                LINFO << "e2fsck returned status 0x" << std::hex << status;
+                *fs_stat |= FS_STAT_E2FSCK_FS_FIXED;
             }
         }
     } else if (!strcmp(fs_type, "f2fs")) {
@@ -221,7 +257,8 @@
             le32_to_cpu(es->s_r_blocks_count_lo);
 }
 
-static int do_quota(char *blk_device, char *fs_type, struct fstab_rec *rec)
+static int do_quota_with_shutdown_check(char *blk_device, char *fs_type,
+                                        struct fstab_rec *rec, int *fs_stat)
 {
     int force_check = 0;
     if (!strcmp(fs_type, "ext4")) {
@@ -246,7 +283,16 @@
                     PERROR << "Can't read '" << blk_device << "' super block";
                     return force_check;
                 }
-
+                *fs_stat |= FS_STAT_IS_EXT4;
+                //TODO check if it is new version or not
+                if ((sb.s_feature_incompat & EXT4_FEATURE_INCOMPAT_RECOVER) != 0 ||
+                    (sb.s_state & EXT4_VALID_FS) == 0) {
+                    LINFO << __FUNCTION__ << "(): was not clealy shutdown, state flag:"
+                          << std::hex << sb.s_state
+                          << "incompat flag:" << std::hex << sb.s_feature_incompat;
+                    force_check = 1;
+                    *fs_stat |= FS_STAT_UNCLEAN_SHUTDOWN;
+                }
                 int has_quota = (sb.s_feature_ro_compat
                         & cpu_to_le32(EXT4_FEATURE_RO_COMPAT_QUOTA)) != 0;
                 int want_quota = fs_mgr_is_quota(rec) != 0;
@@ -259,6 +305,7 @@
                     arg1 = "-Oquota";
                     arg2 = "-Qusrquota,grpquota";
                     force_check = 1;
+                    *fs_stat |= FS_STAT_QUOTA_ENABLED;
                 } else {
                     LINFO << "Disabling quota on " << blk_device;
                     arg1 = "-Q^usrquota,^grpquota";
@@ -282,13 +329,14 @@
             if (ret < 0) {
                 /* No need to check for error in fork, we can't really handle it now */
                 LERROR << "Failed trying to run " << TUNE2FS_BIN;
+                *fs_stat |= FS_STAT_TUNE2FS_FAILED;
             }
         }
     }
     return force_check;
 }
 
-static void do_reserved_size(char *blk_device, char *fs_type, struct fstab_rec *rec)
+static void do_reserved_size(char *blk_device, char *fs_type, struct fstab_rec *rec, int *fs_stat)
 {
     /* Check for the types of filesystems we know how to check */
     if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) {
@@ -347,6 +395,7 @@
             if (ret < 0) {
                 /* No need to check for error in fork, we can't really handle it now */
                 LERROR << "Failed trying to run " << TUNE2FS_BIN;
+                *fs_stat |= FS_STAT_TUNE2FS_FAILED;
             }
         }
     }
@@ -487,17 +536,19 @@
                 continue;
             }
 
-            int force_check = do_quota(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
-                                       &fstab->recs[i]);
+            int fs_stat = 0;
+            int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device,
+                                                           fstab->recs[i].fs_type,
+                                                           &fstab->recs[i], &fs_stat);
 
             if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
                 check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
-                         fstab->recs[i].mount_point);
+                         fstab->recs[i].mount_point, &fs_stat);
             }
 
             if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
                 do_reserved_size(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
-                                 &fstab->recs[i]);
+                                 &fstab->recs[i], &fs_stat);
             }
 
             if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point, &fstab->recs[i])) {
@@ -511,9 +562,13 @@
                            << fstab->recs[start_idx].fs_type;
                 }
             } else {
-                /* back up errno for crypto decisions */
-                mount_errno = errno;
+                fs_stat |= FS_STAT_FULL_MOUNT_FAILED;
+                /* back up the first errno for crypto decisions */
+                if (mount_errno == 0) {
+                    mount_errno = errno;
+                }
             }
+            log_fs_stat(fstab->recs[i].blk_device, fs_stat);
     }
 
     /* Adjust i for the case where it was still withing the recs[] */
@@ -950,16 +1005,18 @@
             wait_for_file(n_blk_device, WAIT_TIMEOUT);
         }
 
-        int force_check = do_quota(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
-                                   &fstab->recs[i]);
+        int fs_stat = 0;
+        int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device,
+                                                       fstab->recs[i].fs_type,
+                                                       &fstab->recs[i], &fs_stat);
 
         if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
             check_fs(n_blk_device, fstab->recs[i].fs_type,
-                     fstab->recs[i].mount_point);
+                     fstab->recs[i].mount_point, &fs_stat);
         }
 
         if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
-            do_reserved_size(n_blk_device, fstab->recs[i].fs_type, &fstab->recs[i]);
+            do_reserved_size(n_blk_device, fstab->recs[i].fs_type, &fstab->recs[i], &fs_stat);
         }
 
         if (fs_mgr_is_avb_used() && (fstab->recs[i].fs_mgr_flags & MF_AVB)) {
@@ -996,9 +1053,12 @@
         if (__mount(n_blk_device, m, &fstab->recs[i])) {
             if (!first_mount_errno) first_mount_errno = errno;
             mount_errors++;
+            fs_stat |= FS_STAT_FULL_MOUNT_FAILED;
+            log_fs_stat(fstab->recs[i].blk_device, fs_stat);
             continue;
         } else {
             ret = 0;
+            log_fs_stat(fstab->recs[i].blk_device, fs_stat);
             goto out;
         }
     }
diff --git a/fs_mgr/fs_mgr_fstab.cpp b/fs_mgr/fs_mgr_fstab.cpp
index 5b0243d..2e54d69 100644
--- a/fs_mgr/fs_mgr_fstab.cpp
+++ b/fs_mgr/fs_mgr_fstab.cpp
@@ -404,7 +404,7 @@
     return false;
 }
 
-struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
+static struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file)
 {
     int cnt, entries;
     ssize_t len;
@@ -540,6 +540,41 @@
     return NULL;
 }
 
+/* merges fstab entries from both a and b, then returns the merged result.
+ * note that the caller should only manage the return pointer without
+ * doing further memory management for the two inputs, i.e. only need to
+ * frees up memory of the return value without touching a and b. */
+static struct fstab *in_place_merge(struct fstab *a, struct fstab *b)
+{
+    if (!a) return b;
+    if (!b) return a;
+
+    int total_entries = a->num_entries + b->num_entries;
+    a->recs = static_cast<struct fstab_rec *>(realloc(
+        a->recs, total_entries * (sizeof(struct fstab_rec))));
+    if (!a->recs) {
+        LERROR << __FUNCTION__ << "(): failed to allocate fstab recs";
+        // If realloc() fails the original block is left untouched;
+        // it is not freed or moved. So we have to free both a and b here.
+        fs_mgr_free_fstab(a);
+        fs_mgr_free_fstab(b);
+        return nullptr;
+    }
+
+    for (int i = a->num_entries, j = 0; i < total_entries; i++, j++) {
+        // copy the pointer directly *without* malloc and memcpy
+        a->recs[i] = b->recs[j];
+    }
+
+    // Frees up b, but don't free b->recs[X] to make sure they are
+    // accessible through a->recs[X].
+    free(b->fstab_filename);
+    free(b);
+
+    a->num_entries = total_entries;
+    return a;
+}
+
 struct fstab *fs_mgr_read_fstab(const char *fstab_path)
 {
     FILE *fstab_file;
@@ -547,13 +582,17 @@
 
     fstab_file = fopen(fstab_path, "r");
     if (!fstab_file) {
-        LERROR << "Cannot open file " << fstab_path;
-        return NULL;
+        PERROR << __FUNCTION__<< "(): cannot open file: '" << fstab_path << "'";
+        return nullptr;
     }
+
     fstab = fs_mgr_read_fstab_file(fstab_file);
     if (fstab) {
         fstab->fstab_filename = strdup(fstab_path);
+    } else {
+        LERROR << __FUNCTION__ << "(): failed to load fstab from : '" << fstab_path << "'";
     }
+
     fclose(fstab_file);
     return fstab;
 }
@@ -565,75 +604,58 @@
 {
     std::string fstab_buf = read_fstab_from_dt();
     if (fstab_buf.empty()) {
-        return NULL;
+        LERROR << __FUNCTION__ << "(): failed to read fstab from dt";
+        return nullptr;
     }
 
     std::unique_ptr<FILE, decltype(&fclose)> fstab_file(
         fmemopen(static_cast<void*>(const_cast<char*>(fstab_buf.c_str())),
                  fstab_buf.length(), "r"), fclose);
     if (!fstab_file) {
-        return NULL;
+        PERROR << __FUNCTION__ << "(): failed to create a file stream for fstab dt";
+        return nullptr;
     }
 
     struct fstab *fstab = fs_mgr_read_fstab_file(fstab_file.get());
     if (!fstab) {
-        LERROR << "failed to load fstab from kernel:" << std::endl << fstab_buf;
+        LERROR << __FUNCTION__ << "(): failed to load fstab from kernel:"
+               << std::endl << fstab_buf;
     }
 
     return fstab;
 }
 
 /* combines fstab entries passed in from device tree with
- * the ones found in /fstab.<hardware>
+ * the ones found from fstab_path
+ */
+struct fstab *fs_mgr_read_fstab_with_dt(const char *fstab_path)
+{
+    struct fstab *fstab_dt = fs_mgr_read_fstab_dt();
+    struct fstab *fstab = fs_mgr_read_fstab(fstab_path);
+
+    return in_place_merge(fstab_dt, fstab);
+}
+
+/*
+ * tries to load default fstab.<hardware> file from /odm/etc, /vendor/etc
+ * or /. loads the first one found and also combines fstab entries passed
+ * in from device tree.
  */
 struct fstab *fs_mgr_read_fstab_default()
 {
-    struct fstab *fstab = fs_mgr_read_fstab_dt();
     std::string hw;
-    if (!fs_mgr_get_boot_config("hardware", &hw)) {
-        // if we fail to find this, return whatever was found in device tree
-        LWARNING << "failed to find device hardware name";
-        return fstab;
-    }
+    std::string default_fstab;
 
-    std::string default_fstab = FSTAB_PREFIX + hw;
-    struct fstab *f = fs_mgr_read_fstab(default_fstab.c_str());
-    if (!f) {
-        // return what we have
-        LWARNING << "failed to read fstab entries from '" << default_fstab << "'";
-        return fstab;
-    }
-
-    // return the fstab read from file if device tree doesn't
-    // have one, other wise merge the two
-    if (!fstab) {
-        fstab = f;
+    if (fs_mgr_get_boot_config("hardware", &hw)) {
+        for (const char *prefix : {"/odm/etc/fstab.","/vendor/etc/fstab.", "/fstab."}) {
+            default_fstab = prefix + hw;
+            if (access(default_fstab.c_str(), F_OK) == 0) break;
+        }
     } else {
-        int total_entries = fstab->num_entries + f->num_entries;
-        fstab->recs = static_cast<struct fstab_rec *>(realloc(
-                        fstab->recs, total_entries * (sizeof(struct fstab_rec))));
-        if (!fstab->recs) {
-            LERROR << "failed to allocate fstab recs";
-            fstab->num_entries = 0;
-            fs_mgr_free_fstab(fstab);
-            return NULL;
-        }
-
-        for (int i = fstab->num_entries, j = 0; i < total_entries; i++, j++) {
-            // copy everything and *not* strdup
-            fstab->recs[i] = f->recs[j];
-        }
-
-        // free up fstab entries read from file, but don't cleanup
-        // the strings within f->recs[X] to make sure they are accessible
-        // through fstab->recs[X].
-        free(f->fstab_filename);
-        free(f);
-
-        fstab->num_entries = total_entries;
+        LWARNING << __FUNCTION__ << "(): failed to find device hardware name";
     }
 
-    return fstab;
+    return fs_mgr_read_fstab_with_dt(default_fstab.c_str());
 }
 
 void fs_mgr_free_fstab(struct fstab *fstab)
diff --git a/fs_mgr/fs_mgr_priv.h b/fs_mgr/fs_mgr_priv.h
index 4e2ac8b..377d2ec 100644
--- a/fs_mgr/fs_mgr_priv.h
+++ b/fs_mgr/fs_mgr_priv.h
@@ -41,8 +41,6 @@
 #define PWARNING PLOG(WARNING) << FS_MGR_TAG
 #define PERROR   PLOG(ERROR) << FS_MGR_TAG
 
-const std::string FSTAB_PREFIX("/fstab.");
-
 __BEGIN_DECLS
 
 #define CRYPTO_TMPFS_OPTIONS "size=256m,mode=0771,uid=1000,gid=1000"
diff --git a/fs_mgr/fs_mgr_verity.cpp b/fs_mgr/fs_mgr_verity.cpp
index e8ed6a2..54a6f71 100644
--- a/fs_mgr/fs_mgr_verity.cpp
+++ b/fs_mgr/fs_mgr_verity.cpp
@@ -30,6 +30,7 @@
 #include <unistd.h>
 
 #include <android-base/file.h>
+#include <android-base/properties.h>
 #include <android-base/strings.h>
 #include <android-base/unique_fd.h>
 #include <crypto_utils/android_pubkey.h>
@@ -874,6 +875,11 @@
     // read verity metadata
     if (fec_verity_get_metadata(f, &verity) < 0) {
         PERROR << "Failed to get verity metadata '" << fstab->blk_device << "'";
+        // Allow verity disabled when the device is unlocked without metadata
+        if ("0" == android::base::GetProperty("ro.boot.flash.locked", "")) {
+            retval = FS_MGR_SETUP_VERITY_DISABLED;
+            LWARNING << "Allow invalid metadata when the device is unlocked";
+        }
         goto out;
     }
 
diff --git a/fs_mgr/include/fs_mgr.h b/fs_mgr/include/fs_mgr.h
index a5e5beb..e4aeb48 100644
--- a/fs_mgr/include/fs_mgr.h
+++ b/fs_mgr/include/fs_mgr.h
@@ -87,8 +87,8 @@
 
 struct fstab *fs_mgr_read_fstab_default();
 struct fstab *fs_mgr_read_fstab_dt();
-struct fstab *fs_mgr_read_fstab_file(FILE *fstab_file);
 struct fstab *fs_mgr_read_fstab(const char *fstab_path);
+struct fstab *fs_mgr_read_fstab_with_dt(const char *fstab_path);
 void fs_mgr_free_fstab(struct fstab *fstab);
 
 #define FS_MGR_MNTALL_DEV_FILE_ENCRYPTED 5
diff --git a/healthd/BatteryMonitor.cpp b/healthd/BatteryMonitor.cpp
index 0c90a54..45b6eda 100644
--- a/healthd/BatteryMonitor.cpp
+++ b/healthd/BatteryMonitor.cpp
@@ -129,7 +129,7 @@
 }
 
 int BatteryMonitor::readFromFile(const String8& path, std::string* buf) {
-    if (android::base::ReadFileToString(String8::std_string(path), buf)) {
+    if (android::base::ReadFileToString(path.c_str(), buf)) {
         *buf = android::base::Trim(*buf);
     }
     return buf->length();
diff --git a/init/Android.mk b/init/Android.mk
index 2fc6f19..1a47eb4 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -119,10 +119,20 @@
     mapping_sepolicy.cil \
     nonplat_sepolicy.cil \
     plat_sepolicy.cil \
-    secilc
+    plat_sepolicy.cil.sha256 \
+    secilc \
+    nonplat_file_contexts \
+    plat_file_contexts
+
+# Include precompiled policy, unless told otherwise
+ifneq ($(PRODUCT_PRECOMPILED_SEPOLICY),false)
+LOCAL_REQUIRED_MODULES += precompiled_sepolicy precompiled_sepolicy.plat.sha256
+endif
+
 else
 # Use monolithic SELinux policy
-LOCAL_REQUIRED_MODULES += sepolicy
+LOCAL_REQUIRED_MODULES += sepolicy \
+    file_contexts.bin
 endif
 
 # Create symlinks.
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 6dd1cbb..9e3489e 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -604,20 +604,27 @@
     int mount_mode = MOUNT_MODE_DEFAULT;
     const char* fstabfile = args[1].c_str();
     std::size_t path_arg_end = args.size();
+    const char* prop_post_fix = "default";
 
     for (na = args.size() - 1; na > 1; --na) {
         if (args[na] == "--early") {
             path_arg_end = na;
             queue_event = false;
             mount_mode = MOUNT_MODE_EARLY;
+            prop_post_fix = "early";
         } else if (args[na] == "--late") {
             path_arg_end = na;
             import_rc = false;
             mount_mode = MOUNT_MODE_LATE;
+            prop_post_fix = "late";
         }
     }
 
+    std::string prop_name = android::base::StringPrintf("ro.boottime.init.mount_all.%s",
+                                                        prop_post_fix);
+    Timer t;
     int ret =  mount_fstab(fstabfile, mount_mode);
+    property_set(prop_name.c_str(), std::to_string(t.duration_ms()).c_str());
 
     if (import_rc) {
         /* Paths of .rc files are specified at the 2nd argument and beyond */
diff --git a/init/init.cpp b/init/init.cpp
index 28e6008..5ab421b 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -621,11 +621,21 @@
 
 /*
  * Forks, executes the provided program in the child, and waits for the completion in the parent.
+ * Child's stderr is captured and logged using LOG(ERROR).
  *
  * Returns true if the child exited with status code 0, returns false otherwise.
  */
 static bool fork_execve_and_wait_for_completion(const char* filename, char* const argv[],
                                                 char* const envp[]) {
+    // Create a pipe used for redirecting child process's output.
+    // * pipe_fds[0] is the FD the parent will use for reading.
+    // * pipe_fds[1] is the FD the child will use for writing.
+    int pipe_fds[2];
+    if (pipe(pipe_fds) == -1) {
+        PLOG(ERROR) << "Failed to create pipe";
+        return false;
+    }
+
     pid_t child_pid = fork();
     if (child_pid == -1) {
         PLOG(ERROR) << "Failed to fork for " << filename;
@@ -634,6 +644,18 @@
 
     if (child_pid == 0) {
         // fork succeeded -- this is executing in the child process
+
+        // Close the pipe FD not used by this process
+        TEMP_FAILURE_RETRY(close(pipe_fds[0]));
+
+        // Redirect stderr to the pipe FD provided by the parent
+        if (TEMP_FAILURE_RETRY(dup2(pipe_fds[1], STDERR_FILENO)) == -1) {
+            PLOG(ERROR) << "Failed to redirect stderr of " << filename;
+            _exit(127);
+            return false;
+        }
+        TEMP_FAILURE_RETRY(close(pipe_fds[1]));
+
         if (execve(filename, argv, envp) == -1) {
             PLOG(ERROR) << "Failed to execve " << filename;
             return false;
@@ -644,6 +666,30 @@
         return false;
     } else {
         // fork succeeded -- this is executing in the original/parent process
+
+        // Close the pipe FD not used by this process
+        TEMP_FAILURE_RETRY(close(pipe_fds[1]));
+
+        // Log the redirected output of the child process.
+        // It's unfortunate that there's no standard way to obtain an istream for a file descriptor.
+        // As a result, we're buffering all output and logging it in one go at the end of the
+        // invocation, instead of logging it as it comes in.
+        const int child_out_fd = pipe_fds[0];
+        std::string child_output;
+        if (!android::base::ReadFdToString(child_out_fd, &child_output)) {
+            PLOG(ERROR) << "Failed to capture full output of " << filename;
+        }
+        TEMP_FAILURE_RETRY(close(child_out_fd));
+        if (!child_output.empty()) {
+            // Log captured output, line by line, because LOG expects to be invoked for each line
+            std::istringstream in(child_output);
+            std::string line;
+            while (std::getline(in, line)) {
+                LOG(ERROR) << filename << ": " << line;
+            }
+        }
+
+        // Wait for child to terminate
         int status;
         if (TEMP_FAILURE_RETRY(waitpid(child_pid, &status, 0)) != child_pid) {
             PLOG(ERROR) << "Failed to wait for " << filename;
@@ -669,6 +715,44 @@
     }
 }
 
+static bool read_first_line(const char* file, std::string* line) {
+    line->clear();
+
+    std::string contents;
+    if (!android::base::ReadFileToString(file, &contents, true /* follow symlinks */)) {
+        return false;
+    }
+    std::istringstream in(contents);
+    std::getline(in, *line);
+    return true;
+}
+
+static bool selinux_find_precompiled_split_policy(std::string* file) {
+    file->clear();
+
+    static constexpr const char precompiled_sepolicy[] = "/vendor/etc/selinux/precompiled_sepolicy";
+    if (access(precompiled_sepolicy, R_OK) == -1) {
+        return false;
+    }
+    std::string actual_plat_id;
+    if (!read_first_line("/system/etc/selinux/plat_sepolicy.cil.sha256", &actual_plat_id)) {
+        PLOG(INFO) << "Failed to read /system/etc/selinux/plat_sepolicy.cil.sha256";
+        return false;
+    }
+    std::string precompiled_plat_id;
+    if (!read_first_line("/vendor/etc/selinux/precompiled_sepolicy.plat.sha256",
+                         &precompiled_plat_id)) {
+        PLOG(INFO) << "Failed to read /vendor/etc/selinux/precompiled_sepolicy.plat.sha256";
+        return false;
+    }
+    if ((actual_plat_id.empty()) || (actual_plat_id != precompiled_plat_id)) {
+        return false;
+    }
+
+    *file = precompiled_sepolicy;
+    return true;
+}
+
 static constexpr const char plat_policy_cil_file[] = "/system/etc/selinux/plat_sepolicy.cil";
 
 static bool selinux_is_split_policy_device() { return access(plat_policy_cil_file, R_OK) != -1; }
@@ -688,8 +772,32 @@
     // secilc is invoked to compile the above three policy files into a single monolithic policy
     // file. This file is then loaded into the kernel.
 
+    // Load precompiled policy from vendor image, if a matching policy is found there. The policy
+    // must match the platform policy on the system image.
+    std::string precompiled_sepolicy_file;
+    if (selinux_find_precompiled_split_policy(&precompiled_sepolicy_file)) {
+        android::base::unique_fd fd(
+            open(precompiled_sepolicy_file.c_str(), O_RDONLY | O_CLOEXEC | O_BINARY));
+        if (fd != -1) {
+            if (selinux_android_load_policy_from_fd(fd, precompiled_sepolicy_file.c_str()) < 0) {
+                LOG(ERROR) << "Failed to load SELinux policy from " << precompiled_sepolicy_file;
+                return false;
+            }
+            return true;
+        }
+    }
+    // No suitable precompiled policy could be loaded
+
     LOG(INFO) << "Compiling SELinux policy";
 
+    // Determine the highest policy language version supported by the kernel
+    set_selinuxmnt("/sys/fs/selinux");
+    int max_policy_version = security_policyvers();
+    if (max_policy_version == -1) {
+        PLOG(ERROR) << "Failed to determine highest policy version supported by kernel";
+        return false;
+    }
+
     // We store the output of the compilation on /dev because this is the most convenient tmpfs
     // storage mount available this early in the boot sequence.
     char compiled_sepolicy[] = "/dev/sepolicy.XXXXXX";
@@ -699,14 +807,20 @@
         return false;
     }
 
-    const char* compile_args[] = {"/system/bin/secilc", plat_policy_cil_file, "-M", "true", "-c",
-                                  "30",  // TODO: pass in SELinux policy version from build system
-                                  "/vendor/etc/selinux/mapping_sepolicy.cil",
-                                  "/vendor/etc/selinux/nonplat_sepolicy.cil", "-o",
-                                  compiled_sepolicy,
-                                  // We don't care about file_contexts output by the compiler
-                                  "-f", "/sys/fs/selinux/null",  // /dev/null is not yet available
-                                  nullptr};
+    // clang-format off
+    const char* compile_args[] = {
+        "/system/bin/secilc",
+        plat_policy_cil_file,
+        "-M", "true",
+        // Target the highest policy language version supported by the kernel
+        "-c", std::to_string(max_policy_version).c_str(),
+        "/vendor/etc/selinux/mapping_sepolicy.cil",
+        "/vendor/etc/selinux/nonplat_sepolicy.cil",
+        "-o", compiled_sepolicy,
+        // We don't care about file_contexts output by the compiler
+        "-f", "/sys/fs/selinux/null",  // /dev/null is not yet available
+        nullptr};
+    // clang-format on
 
     if (!fork_execve_and_wait_for_completion(compile_args[0], (char**)compile_args, (char**)ENV)) {
         unlink(compiled_sepolicy);
diff --git a/init/property_service.cpp b/init/property_service.cpp
index d88b72e..983e684 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -62,7 +62,6 @@
 using android::base::StringPrintf;
 
 #define PERSISTENT_PROPERTY_DIR  "/data/property"
-#define FSTAB_PREFIX "/fstab."
 #define RECOVERY_MOUNT_POINT "/recovery"
 
 static int persistent_properties_loaded = 0;
@@ -613,21 +612,14 @@
 }
 
 void load_recovery_id_prop() {
-    std::string ro_hardware = property_get("ro.hardware");
-    if (ro_hardware.empty()) {
-        LOG(ERROR) << "ro.hardware not set - unable to load recovery id";
-        return;
-    }
-    std::string fstab_filename = FSTAB_PREFIX + ro_hardware;
-
-    std::unique_ptr<fstab, void(*)(fstab*)> tab(fs_mgr_read_fstab(fstab_filename.c_str()),
-                                                fs_mgr_free_fstab);
-    if (!tab) {
-        PLOG(ERROR) << "unable to read fstab " << fstab_filename;
+    std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
+                                                               fs_mgr_free_fstab);
+    if (!fstab) {
+        PLOG(ERROR) << "unable to read default fstab";
         return;
     }
 
-    fstab_rec* rec = fs_mgr_get_entry_for_mount_point(tab.get(), RECOVERY_MOUNT_POINT);
+    fstab_rec* rec = fs_mgr_get_entry_for_mount_point(fstab.get(), RECOVERY_MOUNT_POINT);
     if (rec == NULL) {
         LOG(ERROR) << "/recovery not specified in fstab";
         return;
diff --git a/libbacktrace/.clang-format b/libbacktrace/.clang-format
new file mode 120000
index 0000000..fd0645f
--- /dev/null
+++ b/libbacktrace/.clang-format
@@ -0,0 +1 @@
+../.clang-format-2
\ No newline at end of file
diff --git a/libbinderwrapper/Android.mk b/libbinderwrapper/Android.mk
index b38d262..c768373 100644
--- a/libbinderwrapper/Android.mk
+++ b/libbinderwrapper/Android.mk
@@ -41,7 +41,7 @@
 
 include $(BUILD_SHARED_LIBRARY)
 
-# libbinderwrapper_test_support shared library
+# libbinderwrapper_test_support static library
 # ========================================================
 
 include $(CLEAR_VARS)
@@ -59,4 +59,4 @@
   binder_test_base.cc \
   stub_binder_wrapper.cc \
 
-include $(BUILD_SHARED_LIBRARY)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/liblog/.clang-format b/liblog/.clang-format
new file mode 100644
index 0000000..9db87a8
--- /dev/null
+++ b/liblog/.clang-format
@@ -0,0 +1,9 @@
+BasedOnStyle: Google
+AllowShortFunctionsOnASingleLine: false
+
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+PointerAlignment: Left
+PenaltyExcessCharacter: 32
+
+Cpp11BracedListStyle: false
diff --git a/liblog/Android.bp b/liblog/Android.bp
index 310dbf4..bb8c3af 100644
--- a/liblog/Android.bp
+++ b/liblog/Android.bp
@@ -26,6 +26,7 @@
     "logger_read.c",
     "logger_write.c",
     "logprint.c",
+    "stderr_write.c",
 ]
 liblog_host_sources = [
     "fake_log_device.c",
diff --git a/liblog/README b/liblog/README
index 40a39ad..5a845be 100644
--- a/liblog/README
+++ b/liblog/README
@@ -108,10 +108,10 @@
 
        int android_log_destroy(android_log_context *ctx)
 
-       #include <log/log_frontend.h>
+       #include <log/log_transport.h>
 
-       int android_set_log_frontend(int frontend_flag)
-       int android_get_log_frontend()
+       int android_set_log_transport(int transport_flag)
+       int android_get_log_transport()
 
        Link with -llog
 
@@ -167,12 +167,12 @@
        when  opening  the  sub-log.    It  is  recommended  to  open  the  log
        ANDROID_LOG_RDONLY in these cases.
 
-       android_set_log_frontend() selects frontend filters. Argument is either
-       LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to logger
-       daemon for default or logd,  drop contents on floor,  or log into local
-       memory   respectively.          Both   android_set_log_frontend()   and
-       android_get_log_frontend()  return  the  current  frontend mask,   or a
-       negative errno for any problems.
+       android_set_log_transport()  selects  transport  filters.  Argument  is
+       either LOGGER_DEFAULT, LOGGER_LOGD, LOGGER_NULL or LOGGER_LOCAL. Log to
+       logger daemon for default or logd, drop contents on floor,  or log into
+       local   memory   respectively.       Both   android_set_log_transport()
+       and android_get_log_transport() return the current  transport mask,  or
+       a negative errno for any problems.
 
 ERRORS
        If messages fail, a negative error code will be returned to the caller.
diff --git a/liblog/config_read.c b/liblog/config_read.c
index b9a281b..ca80c80 100644
--- a/liblog/config_read.c
+++ b/liblog/config_read.c
@@ -14,75 +14,73 @@
  * limitations under the License.
  */
 
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 
 #include "config_read.h"
 #include "logger.h"
 
-LIBLOG_HIDDEN struct listnode __android_log_transport_read =
-    { &__android_log_transport_read, &__android_log_transport_read };
-LIBLOG_HIDDEN struct listnode __android_log_persist_read =
-    { &__android_log_persist_read, &__android_log_persist_read };
+LIBLOG_HIDDEN struct listnode __android_log_transport_read = {
+  &__android_log_transport_read, &__android_log_transport_read
+};
+LIBLOG_HIDDEN struct listnode __android_log_persist_read = {
+  &__android_log_persist_read, &__android_log_persist_read
+};
 
 static void __android_log_add_transport(
-        struct listnode *list, struct android_log_transport_read *transport) {
-    size_t i;
+    struct listnode* list, struct android_log_transport_read* transport) {
+  size_t i;
 
-    /* Try to keep one functioning transport for each log buffer id */
-    for (i = LOG_ID_MIN; i < LOG_ID_MAX; i++) {
-        struct android_log_transport_read *transp;
+  /* Try to keep one functioning transport for each log buffer id */
+  for (i = LOG_ID_MIN; i < LOG_ID_MAX; i++) {
+    struct android_log_transport_read* transp;
 
-        if (list_empty(list)) {
-            if (!transport->available || ((*transport->available)(i) >= 0)) {
-                list_add_tail(list, &transport->node);
-                return;
-            }
-        } else {
-            read_transport_for_each(transp, list) {
-                if (!transp->available) {
-                    return;
-                }
-                if (((*transp->available)(i) < 0) &&
-                        (!transport->available ||
-                            ((*transport->available)(i) >= 0))) {
-                    list_add_tail(list, &transport->node);
-                    return;
-                }
-            }
+    if (list_empty(list)) {
+      if (!transport->available || ((*transport->available)(i) >= 0)) {
+        list_add_tail(list, &transport->node);
+        return;
+      }
+    } else {
+      read_transport_for_each(transp, list) {
+        if (!transp->available) {
+          return;
         }
+        if (((*transp->available)(i) < 0) &&
+            (!transport->available || ((*transport->available)(i) >= 0))) {
+          list_add_tail(list, &transport->node);
+          return;
+        }
+      }
     }
+  }
 }
 
 LIBLOG_HIDDEN void __android_log_config_read() {
-    if (__android_log_frontend & LOGGER_LOCAL) {
-        extern struct android_log_transport_read localLoggerRead;
+  if (__android_log_transport & LOGGER_LOCAL) {
+    extern struct android_log_transport_read localLoggerRead;
 
-        __android_log_add_transport(&__android_log_transport_read,
-                                    &localLoggerRead);
-    }
+    __android_log_add_transport(&__android_log_transport_read, &localLoggerRead);
+  }
 
 #if (FAKE_LOG_DEVICE == 0)
-    if ((__android_log_frontend == LOGGER_DEFAULT) ||
-        (__android_log_frontend & LOGGER_LOGD)) {
-        extern struct android_log_transport_read logdLoggerRead;
-        extern struct android_log_transport_read pmsgLoggerRead;
+  if ((__android_log_transport == LOGGER_DEFAULT) ||
+      (__android_log_transport & LOGGER_LOGD)) {
+    extern struct android_log_transport_read logdLoggerRead;
+    extern struct android_log_transport_read pmsgLoggerRead;
 
-        __android_log_add_transport(&__android_log_transport_read,
-                                    &logdLoggerRead);
-        __android_log_add_transport(&__android_log_persist_read,
-                                    &pmsgLoggerRead);
-    }
+    __android_log_add_transport(&__android_log_transport_read, &logdLoggerRead);
+    __android_log_add_transport(&__android_log_persist_read, &pmsgLoggerRead);
+  }
 #endif
 }
 
 LIBLOG_HIDDEN void __android_log_config_read_close() {
-    struct android_log_transport_read *transport;
-    struct listnode *n;
+  struct android_log_transport_read* transport;
+  struct listnode* n;
 
-    read_transport_for_each_safe(transport, n, &__android_log_transport_read) {
-        list_remove(&transport->node);
-    }
-    read_transport_for_each_safe(transport, n, &__android_log_persist_read) {
-        list_remove(&transport->node);
-    }
+  read_transport_for_each_safe(transport, n, &__android_log_transport_read) {
+    list_remove(&transport->node);
+  }
+  read_transport_for_each_safe(transport, n, &__android_log_persist_read) {
+    list_remove(&transport->node);
+  }
 }
diff --git a/liblog/config_read.h b/liblog/config_read.h
index 892e80d..7b29fa4 100644
--- a/liblog/config_read.h
+++ b/liblog/config_read.h
@@ -26,30 +26,26 @@
 extern LIBLOG_HIDDEN struct listnode __android_log_transport_read;
 extern LIBLOG_HIDDEN struct listnode __android_log_persist_read;
 
-#define read_transport_for_each(transp, transports)                         \
-    for ((transp) = node_to_item((transports)->next,                        \
-                                 struct android_log_transport_read, node);  \
-         ((transp) != node_to_item((transports),                            \
-                                   struct android_log_transport_read,       \
-                                   node)) &&                                \
-         ((transp) != node_to_item((transp)->node.next,                     \
-                                   struct android_log_transport_read,       \
-                                   node));                                  \
-         (transp) = node_to_item((transp)->node.next,                       \
-                                 struct android_log_transport_read, node))
+#define read_transport_for_each(transp, transports)                           \
+  for ((transp) = node_to_item((transports)->next,                            \
+                               struct android_log_transport_read, node);      \
+       ((transp) != node_to_item((transports),                                \
+                                 struct android_log_transport_read, node)) && \
+       ((transp) != node_to_item((transp)->node.next,                         \
+                                 struct android_log_transport_read, node));   \
+       (transp) = node_to_item((transp)->node.next,                           \
+                               struct android_log_transport_read, node))
 
-#define read_transport_for_each_safe(transp, n, transports)                 \
-    for ((transp) = node_to_item((transports)->next,                        \
-                                 struct android_log_transport_read, node),  \
-         (n) = (transp)->node.next;                                         \
-         ((transp) != node_to_item((transports),                            \
-                                   struct android_log_transport_read,       \
-                                   node)) &&                                \
-         ((transp) != node_to_item((n), struct android_log_transport_read,  \
-                                   node));                                  \
-         (transp) = node_to_item((n), struct android_log_transport_read,    \
-                                 node),                                     \
-         (n) = (transp)->node.next)
+#define read_transport_for_each_safe(transp, n, transports)                   \
+  for ((transp) = node_to_item((transports)->next,                            \
+                               struct android_log_transport_read, node),      \
+      (n) = (transp)->node.next;                                              \
+       ((transp) != node_to_item((transports),                                \
+                                 struct android_log_transport_read, node)) && \
+       ((transp) !=                                                           \
+        node_to_item((n), struct android_log_transport_read, node));          \
+       (transp) = node_to_item((n), struct android_log_transport_read, node), \
+      (n) = (transp)->node.next)
 
 LIBLOG_HIDDEN void __android_log_config_read();
 LIBLOG_HIDDEN void __android_log_config_read_close();
diff --git a/liblog/config_write.c b/liblog/config_write.c
index 583dcff..0a8b52f 100644
--- a/liblog/config_write.c
+++ b/liblog/config_write.c
@@ -14,82 +14,105 @@
  * limitations under the License.
  */
 
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 
 #include "config_write.h"
 #include "logger.h"
 
-LIBLOG_HIDDEN struct listnode __android_log_transport_write =
-    { &__android_log_transport_write, &__android_log_transport_write };
-LIBLOG_HIDDEN struct listnode __android_log_persist_write =
-    { &__android_log_persist_write, &__android_log_persist_write};
+LIBLOG_HIDDEN struct listnode __android_log_transport_write = {
+  &__android_log_transport_write, &__android_log_transport_write
+};
+LIBLOG_HIDDEN struct listnode __android_log_persist_write = {
+  &__android_log_persist_write, &__android_log_persist_write
+};
 
 static void __android_log_add_transport(
-        struct listnode *list, struct android_log_transport_write *transport) {
-    size_t i;
+    struct listnode* list, struct android_log_transport_write* transport) {
+  size_t i;
 
-    /* Try to keep one functioning transport for each log buffer id */
-    for (i = LOG_ID_MIN; i < LOG_ID_MAX; i++) {
-        struct android_log_transport_write *transp;
+  /* Try to keep one functioning transport for each log buffer id */
+  for (i = LOG_ID_MIN; i < LOG_ID_MAX; i++) {
+    struct android_log_transport_write* transp;
 
-        if (list_empty(list)) {
-            if (!transport->available || ((*transport->available)(i) >= 0)) {
-                list_add_tail(list, &transport->node);
-                return;
-            }
-        } else {
-            write_transport_for_each(transp, list) {
-                if (!transp->available) {
-                    return;
-                }
-                if (((*transp->available)(i) < 0) &&
-                        (!transport->available ||
-                            ((*transport->available)(i) >= 0))) {
-                    list_add_tail(list, &transport->node);
-                    return;
-                }
-            }
+    if (list_empty(list)) {
+      if (!transport->available || ((*transport->available)(i) >= 0)) {
+        list_add_tail(list, &transport->node);
+        return;
+      }
+    } else {
+      write_transport_for_each(transp, list) {
+        if (!transp->available) {
+          return;
         }
+        if (((*transp->available)(i) < 0) &&
+            (!transport->available || ((*transport->available)(i) >= 0))) {
+          list_add_tail(list, &transport->node);
+          return;
+        }
+      }
     }
+  }
 }
 
 LIBLOG_HIDDEN void __android_log_config_write() {
-    if (__android_log_frontend & LOGGER_LOCAL) {
-        extern struct android_log_transport_write localLoggerWrite;
+  if (__android_log_transport & LOGGER_LOCAL) {
+    extern struct android_log_transport_write localLoggerWrite;
 
-        __android_log_add_transport(&__android_log_transport_write,
-                                    &localLoggerWrite);
-    }
+    __android_log_add_transport(&__android_log_transport_write,
+                                &localLoggerWrite);
+  }
 
-    if ((__android_log_frontend == LOGGER_DEFAULT) ||
-        (__android_log_frontend & LOGGER_LOGD)) {
+  if ((__android_log_transport == LOGGER_DEFAULT) ||
+      (__android_log_transport & LOGGER_LOGD)) {
 #if (FAKE_LOG_DEVICE == 0)
-        extern struct android_log_transport_write logdLoggerWrite;
-        extern struct android_log_transport_write pmsgLoggerWrite;
+    extern struct android_log_transport_write logdLoggerWrite;
+    extern struct android_log_transport_write pmsgLoggerWrite;
 
-        __android_log_add_transport(&__android_log_transport_write,
-                                    &logdLoggerWrite);
-        __android_log_add_transport(&__android_log_persist_write,
-                                    &pmsgLoggerWrite);
+    __android_log_add_transport(&__android_log_transport_write,
+                                &logdLoggerWrite);
+    __android_log_add_transport(&__android_log_persist_write, &pmsgLoggerWrite);
 #else
-        extern struct android_log_transport_write fakeLoggerWrite;
+    extern struct android_log_transport_write fakeLoggerWrite;
 
-        __android_log_add_transport(&__android_log_transport_write,
-                                    &fakeLoggerWrite);
+    __android_log_add_transport(&__android_log_transport_write,
+                                &fakeLoggerWrite);
 #endif
+  }
+
+  if (__android_log_transport & LOGGER_STDERR) {
+    extern struct android_log_transport_write stderrLoggerWrite;
+
+    /*
+     * stderr logger should be primary if we can be the only one, or if
+     * already in the primary list.  Otherwise land in the persist list.
+     * Remember we can be called here if we are already initialized.
+     */
+    if (list_empty(&__android_log_transport_write)) {
+      __android_log_add_transport(&__android_log_transport_write,
+                                  &stderrLoggerWrite);
+    } else {
+      struct android_log_transport_write* transp;
+      write_transport_for_each(transp, &__android_log_transport_write) {
+        if (transp == &stderrLoggerWrite) {
+          return;
+        }
+      }
+      __android_log_add_transport(&__android_log_persist_write,
+                                  &stderrLoggerWrite);
     }
+  }
 }
 
 LIBLOG_HIDDEN void __android_log_config_write_close() {
-    struct android_log_transport_write *transport;
-    struct listnode *n;
+  struct android_log_transport_write* transport;
+  struct listnode* n;
 
-    write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
-        transport->logMask = 0;
-        list_remove(&transport->node);
-    }
-    write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
-        transport->logMask = 0;
-        list_remove(&transport->node);
-    }
+  write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
+    transport->logMask = 0;
+    list_remove(&transport->node);
+  }
+  write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
+    transport->logMask = 0;
+    list_remove(&transport->node);
+  }
 }
diff --git a/liblog/config_write.h b/liblog/config_write.h
index 8825411..db1a083 100644
--- a/liblog/config_write.h
+++ b/liblog/config_write.h
@@ -26,30 +26,26 @@
 extern LIBLOG_HIDDEN struct listnode __android_log_transport_write;
 extern LIBLOG_HIDDEN struct listnode __android_log_persist_write;
 
-#define write_transport_for_each(transp, transports)                         \
-    for ((transp) = node_to_item((transports)->next,                         \
-                                 struct android_log_transport_write, node);  \
-         ((transp) != node_to_item((transports),                             \
-                                   struct android_log_transport_write,       \
-                                   node)) &&                                 \
-         ((transp) != node_to_item((transp)->node.next,                      \
-                                   struct android_log_transport_write,       \
-                                   node));                                   \
-         (transp) = node_to_item((transp)->node.next,                        \
-                                 struct android_log_transport_write, node))
+#define write_transport_for_each(transp, transports)                           \
+  for ((transp) = node_to_item((transports)->next,                             \
+                               struct android_log_transport_write, node);      \
+       ((transp) != node_to_item((transports),                                 \
+                                 struct android_log_transport_write, node)) && \
+       ((transp) != node_to_item((transp)->node.next,                          \
+                                 struct android_log_transport_write, node));   \
+       (transp) = node_to_item((transp)->node.next,                            \
+                               struct android_log_transport_write, node))
 
-#define write_transport_for_each_safe(transp, n, transports)                 \
-    for ((transp) = node_to_item((transports)->next,                         \
-                                 struct android_log_transport_write, node),  \
-         (n) = (transp)->node.next;                                          \
-         ((transp) != node_to_item((transports),                             \
-                                   struct android_log_transport_write,       \
-                                   node)) &&                                 \
-         ((transp) != node_to_item((n), struct android_log_transport_write,  \
-                                   node));                                   \
-         (transp) = node_to_item((n), struct android_log_transport_write,    \
-                                 node),                                      \
-         (n) = (transp)->node.next)
+#define write_transport_for_each_safe(transp, n, transports)                   \
+  for ((transp) = node_to_item((transports)->next,                             \
+                               struct android_log_transport_write, node),      \
+      (n) = (transp)->node.next;                                               \
+       ((transp) != node_to_item((transports),                                 \
+                                 struct android_log_transport_write, node)) && \
+       ((transp) !=                                                            \
+        node_to_item((n), struct android_log_transport_write, node));          \
+       (transp) = node_to_item((n), struct android_log_transport_write, node), \
+      (n) = (transp)->node.next)
 
 LIBLOG_HIDDEN void __android_log_config_write();
 LIBLOG_HIDDEN void __android_log_config_write_close();
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
index 42f0f37..bdad2c2 100644
--- a/liblog/event_tag_map.cpp
+++ b/liblog/event_tag_map.cpp
@@ -31,9 +31,9 @@
 #include <unordered_map>
 
 #include <log/event_tag_map.h>
+#include <private/android_logger.h>
 #include <utils/FastStrcmp.h>
 #include <utils/RWLock.h>
-#include <private/android_logger.h>
 
 #include "log_portability.h"
 #include "logd_reader.h"
@@ -41,184 +41,192 @@
 #define OUT_TAG "EventTagMap"
 
 class MapString {
-private:
-    const std::string* alloc; // HAS-AN
-    const std::experimental::string_view str; // HAS-A
+ private:
+  const std::string* alloc;                  // HAS-AN
+  const std::experimental::string_view str;  // HAS-A
 
-public:
-    operator const std::experimental::string_view() const { return str; }
+ public:
+  operator const std::experimental::string_view() const {
+    return str;
+  }
 
-    const char* data() const { return str.data(); }
-    size_t length() const { return str.length(); }
+  const char* data() const {
+    return str.data();
+  }
+  size_t length() const {
+    return str.length();
+  }
 
-    bool operator== (const MapString& rval) const {
-        if (length() != rval.length()) return false;
-        if (length() == 0) return true;
-        return fastcmp<strncmp>(data(), rval.data(), length()) == 0;
-    }
-    bool operator!= (const MapString& rval) const {
-        return !(*this == rval);
-    }
+  bool operator==(const MapString& rval) const {
+    if (length() != rval.length()) return false;
+    if (length() == 0) return true;
+    return fastcmp<strncmp>(data(), rval.data(), length()) == 0;
+  }
+  bool operator!=(const MapString& rval) const {
+    return !(*this == rval);
+  }
 
-    MapString(const char* str, size_t len) : alloc(NULL), str(str, len) { }
-    explicit MapString(const std::string& str) :
-            alloc(new std::string(str)),
-            str(alloc->data(), alloc->length()) { }
-    MapString(MapString &&rval) :
-            alloc(rval.alloc),
-            str(rval.data(), rval.length()) {
-        rval.alloc = NULL;
-    }
-    explicit MapString(const MapString &rval) :
-            alloc(rval.alloc ? new std::string(*rval.alloc) : NULL),
-            str(alloc ? alloc->data() : rval.data(), rval.length()) { }
+  MapString(const char* str, size_t len) : alloc(NULL), str(str, len) {
+  }
+  explicit MapString(const std::string& str)
+      : alloc(new std::string(str)), str(alloc->data(), alloc->length()) {
+  }
+  MapString(MapString&& rval)
+      : alloc(rval.alloc), str(rval.data(), rval.length()) {
+    rval.alloc = NULL;
+  }
+  explicit MapString(const MapString& rval)
+      : alloc(rval.alloc ? new std::string(*rval.alloc) : NULL),
+        str(alloc ? alloc->data() : rval.data(), rval.length()) {
+  }
 
-    ~MapString() { if (alloc) delete alloc; }
+  ~MapString() {
+    if (alloc) delete alloc;
+  }
 };
 
 // Hash for MapString
-template <> struct std::hash<MapString>
-        : public std::unary_function<const MapString&, size_t> {
-    size_t operator()(const MapString& __t) const noexcept {
-        if (!__t.length()) return 0;
-        return std::hash<std::experimental::string_view>()(std::experimental::string_view(__t));
-    }
+template <>
+struct std::hash<MapString>
+    : public std::unary_function<const MapString&, size_t> {
+  size_t operator()(const MapString& __t) const noexcept {
+    if (!__t.length()) return 0;
+    return std::hash<std::experimental::string_view>()(
+        std::experimental::string_view(__t));
+  }
 };
 
 typedef std::pair<MapString, MapString> TagFmt;
 
-template <> struct std::hash<TagFmt>
-        : public std::unary_function<const TagFmt&, size_t> {
-    size_t operator()(const TagFmt& __t) const noexcept {
-        // Tag is typically unique.  Will cost us an extra 100ns for the
-        // unordered_map lookup if we instead did a hash that combined
-        // both of tag and fmt members, e.g.:
-        //
-        // return std::hash<MapString>()(__t.first) ^
-        //        std::hash<MapString>()(__t.second);
-        return std::hash<MapString>()(__t.first);
-    }
+template <>
+struct std::hash<TagFmt> : public std::unary_function<const TagFmt&, size_t> {
+  size_t operator()(const TagFmt& __t) const noexcept {
+    // Tag is typically unique.  Will cost us an extra 100ns for the
+    // unordered_map lookup if we instead did a hash that combined
+    // both of tag and fmt members, e.g.:
+    //
+    // return std::hash<MapString>()(__t.first) ^
+    //        std::hash<MapString>()(__t.second);
+    return std::hash<MapString>()(__t.first);
+  }
 };
 
 // Map
 struct EventTagMap {
-#   define NUM_MAPS 2
-    // memory-mapped source file; we get strings from here
-    void*  mapAddr[NUM_MAPS];
-    size_t mapLen[NUM_MAPS];
+#define NUM_MAPS 2
+  // memory-mapped source file; we get strings from here
+  void* mapAddr[NUM_MAPS];
+  size_t mapLen[NUM_MAPS];
 
-private:
-    std::unordered_map<uint32_t, TagFmt> Idx2TagFmt;
-    std::unordered_map<TagFmt, uint32_t> TagFmt2Idx;
-    std::unordered_map<MapString, uint32_t> Tag2Idx;
-    // protect unordered sets
-    android::RWLock rwlock;
+ private:
+  std::unordered_map<uint32_t, TagFmt> Idx2TagFmt;
+  std::unordered_map<TagFmt, uint32_t> TagFmt2Idx;
+  std::unordered_map<MapString, uint32_t> Tag2Idx;
+  // protect unordered sets
+  android::RWLock rwlock;
 
-public:
-    EventTagMap() {
-        memset(mapAddr, 0, sizeof(mapAddr));
-        memset(mapLen, 0, sizeof(mapLen));
+ public:
+  EventTagMap() {
+    memset(mapAddr, 0, sizeof(mapAddr));
+    memset(mapLen, 0, sizeof(mapLen));
+  }
+
+  ~EventTagMap() {
+    Idx2TagFmt.clear();
+    TagFmt2Idx.clear();
+    Tag2Idx.clear();
+    for (size_t which = 0; which < NUM_MAPS; ++which) {
+      if (mapAddr[which]) {
+        munmap(mapAddr[which], mapLen[which]);
+        mapAddr[which] = 0;
+      }
     }
+  }
 
-    ~EventTagMap() {
-        Idx2TagFmt.clear();
-        TagFmt2Idx.clear();
-        Tag2Idx.clear();
-        for (size_t which = 0; which < NUM_MAPS; ++which) {
-            if (mapAddr[which]) {
-                munmap(mapAddr[which], mapLen[which]);
-                mapAddr[which] = 0;
-            }
-        }
-    }
-
-    bool emplaceUnique(uint32_t tag, const TagFmt& tagfmt, bool verbose = false);
-    const TagFmt* find(uint32_t tag) const;
-    int find(TagFmt&& tagfmt) const;
-    int find(MapString&& tag) const;
+  bool emplaceUnique(uint32_t tag, const TagFmt& tagfmt, bool verbose = false);
+  const TagFmt* find(uint32_t tag) const;
+  int find(TagFmt&& tagfmt) const;
+  int find(MapString&& tag) const;
 };
 
-bool EventTagMap::emplaceUnique(uint32_t tag, const TagFmt& tagfmt, bool verbose) {
-    bool ret = true;
-    static const char errorFormat[] = OUT_TAG ": duplicate tag entries %" PRIu32
-                                      ":%.*s:%.*s and %" PRIu32
-                                      ":%.*s:%.*s)\n";
-    android::RWLock::AutoWLock writeLock(rwlock);
-    {
-        std::unordered_map<uint32_t, TagFmt>::const_iterator it;
-        it = Idx2TagFmt.find(tag);
-        if (it != Idx2TagFmt.end()) {
-            if (verbose) {
-                fprintf(stderr, errorFormat,
-                        it->first,
-                        (int)it->second.first.length(), it->second.first.data(),
-                        (int)it->second.second.length(), it->second.second.data(),
-                        tag,
-                        (int)tagfmt.first.length(), tagfmt.first.data(),
-                        (int)tagfmt.second.length(), tagfmt.second.data());
-            }
-            ret = false;
-        } else {
-            Idx2TagFmt.emplace(std::make_pair(tag, tagfmt));
-        }
+bool EventTagMap::emplaceUnique(uint32_t tag, const TagFmt& tagfmt,
+                                bool verbose) {
+  bool ret = true;
+  static const char errorFormat[] =
+      OUT_TAG ": duplicate tag entries %" PRIu32 ":%.*s:%.*s and %" PRIu32
+              ":%.*s:%.*s)\n";
+  android::RWLock::AutoWLock writeLock(rwlock);
+  {
+    std::unordered_map<uint32_t, TagFmt>::const_iterator it;
+    it = Idx2TagFmt.find(tag);
+    if (it != Idx2TagFmt.end()) {
+      if (verbose) {
+        fprintf(stderr, errorFormat, it->first, (int)it->second.first.length(),
+                it->second.first.data(), (int)it->second.second.length(),
+                it->second.second.data(), tag, (int)tagfmt.first.length(),
+                tagfmt.first.data(), (int)tagfmt.second.length(),
+                tagfmt.second.data());
+      }
+      ret = false;
+    } else {
+      Idx2TagFmt.emplace(std::make_pair(tag, tagfmt));
     }
+  }
 
-    {
-        std::unordered_map<TagFmt, uint32_t>::const_iterator it;
-        it = TagFmt2Idx.find(tagfmt);
-        if (it != TagFmt2Idx.end()) {
-            if (verbose) {
-                fprintf(stderr, errorFormat,
-                        it->second,
-                        (int)it->first.first.length(), it->first.first.data(),
-                        (int)it->first.second.length(), it->first.second.data(),
-                        tag,
-                        (int)tagfmt.first.length(), tagfmt.first.data(),
-                        (int)tagfmt.second.length(), tagfmt.second.data());
-            }
-            ret = false;
-        } else {
-            TagFmt2Idx.emplace(std::make_pair(tagfmt, tag));
-        }
+  {
+    std::unordered_map<TagFmt, uint32_t>::const_iterator it;
+    it = TagFmt2Idx.find(tagfmt);
+    if (it != TagFmt2Idx.end()) {
+      if (verbose) {
+        fprintf(stderr, errorFormat, it->second, (int)it->first.first.length(),
+                it->first.first.data(), (int)it->first.second.length(),
+                it->first.second.data(), tag, (int)tagfmt.first.length(),
+                tagfmt.first.data(), (int)tagfmt.second.length(),
+                tagfmt.second.data());
+      }
+      ret = false;
+    } else {
+      TagFmt2Idx.emplace(std::make_pair(tagfmt, tag));
     }
+  }
 
-    {
-        std::unordered_map<MapString, uint32_t>::const_iterator it;
-        it = Tag2Idx.find(tagfmt.first);
-        if (!tagfmt.second.length() && (it != Tag2Idx.end())) {
-            Tag2Idx.erase(it);
-            it = Tag2Idx.end();
-        }
-        if (it == Tag2Idx.end()) {
-            Tag2Idx.emplace(std::make_pair(tagfmt.first, tag));
-        }
+  {
+    std::unordered_map<MapString, uint32_t>::const_iterator it;
+    it = Tag2Idx.find(tagfmt.first);
+    if (!tagfmt.second.length() && (it != Tag2Idx.end())) {
+      Tag2Idx.erase(it);
+      it = Tag2Idx.end();
     }
+    if (it == Tag2Idx.end()) {
+      Tag2Idx.emplace(std::make_pair(tagfmt.first, tag));
+    }
+  }
 
-    return ret;
+  return ret;
 }
 
 const TagFmt* EventTagMap::find(uint32_t tag) const {
-    std::unordered_map<uint32_t, TagFmt>::const_iterator it;
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-    it = Idx2TagFmt.find(tag);
-    if (it == Idx2TagFmt.end()) return NULL;
-    return &(it->second);
+  std::unordered_map<uint32_t, TagFmt>::const_iterator it;
+  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
+  it = Idx2TagFmt.find(tag);
+  if (it == Idx2TagFmt.end()) return NULL;
+  return &(it->second);
 }
 
 int EventTagMap::find(TagFmt&& tagfmt) const {
-    std::unordered_map<TagFmt, uint32_t>::const_iterator it;
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-    it = TagFmt2Idx.find(std::move(tagfmt));
-    if (it == TagFmt2Idx.end()) return -1;
-    return it->second;
+  std::unordered_map<TagFmt, uint32_t>::const_iterator it;
+  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
+  it = TagFmt2Idx.find(std::move(tagfmt));
+  if (it == TagFmt2Idx.end()) return -1;
+  return it->second;
 }
 
 int EventTagMap::find(MapString&& tag) const {
-    std::unordered_map<MapString, uint32_t>::const_iterator it;
-    android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
-    it = Tag2Idx.find(std::move(tag));
-    if (it == Tag2Idx.end()) return -1;
-    return it->second;
+  std::unordered_map<MapString, uint32_t>::const_iterator it;
+  android::RWLock::AutoRLock readLock(const_cast<android::RWLock&>(rwlock));
+  it = Tag2Idx.find(std::move(tag));
+  if (it == Tag2Idx.end()) return -1;
+  return it->second;
 }
 
 // Scan one tag line.
@@ -234,158 +242,158 @@
 //
 // Returns 0 on success, nonzero on failure.
 static int scanTagLine(EventTagMap* map, char** pData, int lineNum) {
-    char* cp;
-    unsigned long val = strtoul(*pData, &cp, 10);
-    if (cp == *pData) {
-        if (lineNum) {
-            fprintf(stderr, OUT_TAG ": malformed tag number on line %d\n",
-                    lineNum);
-        }
-        errno = EINVAL;
-        return -1;
-    }
-
-    uint32_t tagIndex = val;
-    if (tagIndex != val) {
-        if (lineNum) {
-            fprintf(stderr, OUT_TAG ": tag number too large on line %d\n",
-                    lineNum);
-        }
-        errno = ERANGE;
-        return -1;
-    }
-
-    while ((*++cp != '\n') && isspace(*cp)) {
-    }
-
-    if (*cp == '\n') {
-        if (lineNum) {
-            fprintf(stderr, OUT_TAG ": missing tag string on line %d\n",
-                    lineNum);
-        }
-        errno = EINVAL;
-        return -1;
-    }
-
-    const char* tag = cp;
-    // Determine whether "c" is a valid tag char.
-    while (isalnum(*++cp) || (*cp == '_')) { }
-    size_t tagLen = cp - tag;
-
-    if (!isspace(*cp)) {
-        if (lineNum) {
-            fprintf(stderr, OUT_TAG ": invalid tag chars on line %d\n",
-                    lineNum);
-        }
-        errno = EINVAL;
-        return -1;
-    }
-
-    while (isspace(*cp) && (*cp != '\n')) ++cp;
-    const char* fmt = NULL;
-    size_t fmtLen = 0;
-    if (*cp != '#') {
-        fmt = cp;
-        while ((*cp != '\n') && (*cp != '#')) ++cp;
-        while ((cp > fmt) && isspace(*(cp - 1))) --cp;
-        fmtLen = cp - fmt;
-    }
-
-    // KISS Only report identicals if they are global
-    // Ideally we want to check if there are identicals
-    // recorded for the same uid, but recording that
-    // unused detail in our database is too burdensome.
-    bool verbose = true;
-    while ((*cp != '#') && (*cp != '\n')) ++cp;
-    if (*cp == '#') {
-        do {
-            ++cp;
-        } while (isspace(*cp) && (*cp != '\n'));
-        verbose = !!fastcmp<strncmp>(cp, "uid=", strlen("uid="));
-    }
-
-    while (*cp != '\n') ++cp;
-#ifdef DEBUG
-    fprintf(stderr, "%d: %p: %.*s\n", lineNum, tag, (int)(cp - *pData), *pData);
-#endif
-    *pData = cp;
-
+  char* cp;
+  unsigned long val = strtoul(*pData, &cp, 10);
+  if (cp == *pData) {
     if (lineNum) {
-        if (map->emplaceUnique(tagIndex, TagFmt(std::make_pair(
-                MapString(tag, tagLen), MapString(fmt, fmtLen))), verbose)) {
-            return 0;
-        }
-    } else {
-        // cache
-        if (map->emplaceUnique(tagIndex, TagFmt(std::make_pair(
-                MapString(std::string(tag, tagLen)),
-                MapString(std::string(fmt, fmtLen)))))) {
-            return 0;
-        }
+      fprintf(stderr, OUT_TAG ": malformed tag number on line %d\n", lineNum);
     }
-    errno = EMLINK;
+    errno = EINVAL;
     return -1;
+  }
+
+  uint32_t tagIndex = val;
+  if (tagIndex != val) {
+    if (lineNum) {
+      fprintf(stderr, OUT_TAG ": tag number too large on line %d\n", lineNum);
+    }
+    errno = ERANGE;
+    return -1;
+  }
+
+  while ((*++cp != '\n') && isspace(*cp)) {
+  }
+
+  if (*cp == '\n') {
+    if (lineNum) {
+      fprintf(stderr, OUT_TAG ": missing tag string on line %d\n", lineNum);
+    }
+    errno = EINVAL;
+    return -1;
+  }
+
+  const char* tag = cp;
+  // Determine whether "c" is a valid tag char.
+  while (isalnum(*++cp) || (*cp == '_')) {
+  }
+  size_t tagLen = cp - tag;
+
+  if (!isspace(*cp)) {
+    if (lineNum) {
+      fprintf(stderr, OUT_TAG ": invalid tag chars on line %d\n", lineNum);
+    }
+    errno = EINVAL;
+    return -1;
+  }
+
+  while (isspace(*cp) && (*cp != '\n')) ++cp;
+  const char* fmt = NULL;
+  size_t fmtLen = 0;
+  if (*cp != '#') {
+    fmt = cp;
+    while ((*cp != '\n') && (*cp != '#')) ++cp;
+    while ((cp > fmt) && isspace(*(cp - 1))) --cp;
+    fmtLen = cp - fmt;
+  }
+
+  // KISS Only report identicals if they are global
+  // Ideally we want to check if there are identicals
+  // recorded for the same uid, but recording that
+  // unused detail in our database is too burdensome.
+  bool verbose = true;
+  while ((*cp != '#') && (*cp != '\n')) ++cp;
+  if (*cp == '#') {
+    do {
+      ++cp;
+    } while (isspace(*cp) && (*cp != '\n'));
+    verbose = !!fastcmp<strncmp>(cp, "uid=", strlen("uid="));
+  }
+
+  while (*cp != '\n') ++cp;
+#ifdef DEBUG
+  fprintf(stderr, "%d: %p: %.*s\n", lineNum, tag, (int)(cp - *pData), *pData);
+#endif
+  *pData = cp;
+
+  if (lineNum) {
+    if (map->emplaceUnique(tagIndex,
+                           TagFmt(std::make_pair(MapString(tag, tagLen),
+                                                 MapString(fmt, fmtLen))),
+                           verbose)) {
+      return 0;
+    }
+  } else {
+    // cache
+    if (map->emplaceUnique(
+            tagIndex,
+            TagFmt(std::make_pair(MapString(std::string(tag, tagLen)),
+                                  MapString(std::string(fmt, fmtLen)))))) {
+      return 0;
+    }
+  }
+  errno = EMLINK;
+  return -1;
 }
 
 static const char* eventTagFiles[NUM_MAPS] = {
-    EVENT_TAG_MAP_FILE,
-    "/dev/event-log-tags",
+  EVENT_TAG_MAP_FILE, "/dev/event-log-tags",
 };
 
 // Parse the tags out of the file.
 static int parseMapLines(EventTagMap* map, size_t which) {
-    char* cp = static_cast<char*>(map->mapAddr[which]);
-    size_t len = map->mapLen[which];
-    char* endp = cp + len;
+  char* cp = static_cast<char*>(map->mapAddr[which]);
+  size_t len = map->mapLen[which];
+  char* endp = cp + len;
 
-    // insist on EOL at EOF; simplifies parsing and null-termination
-    if (!len || (*(endp - 1) != '\n')) {
+  // insist on EOL at EOF; simplifies parsing and null-termination
+  if (!len || (*(endp - 1) != '\n')) {
 #ifdef DEBUG
-        fprintf(stderr, OUT_TAG ": map file %zu[%zu] missing EOL on last line\n",
-                which, len);
+    fprintf(stderr, OUT_TAG ": map file %zu[%zu] missing EOL on last line\n",
+            which, len);
 #endif
-        if (which) { // do not propagate errors for other files
-            return 0;
+    if (which) {  // do not propagate errors for other files
+      return 0;
+    }
+    errno = EINVAL;
+    return -1;
+  }
+
+  bool lineStart = true;
+  int lineNum = 1;
+  while (cp < endp) {
+    if (*cp == '\n') {
+      lineStart = true;
+      lineNum++;
+    } else if (lineStart) {
+      if (*cp == '#') {
+        // comment; just scan to end
+        lineStart = false;
+      } else if (isdigit(*cp)) {
+        // looks like a tag; scan it out
+        if (scanTagLine(map, &cp, lineNum) != 0) {
+          if (!which || (errno != EMLINK)) {
+            return -1;
+          }
         }
+        lineNum++;  // we eat the '\n'
+                    // leave lineStart==true
+      } else if (isspace(*cp)) {
+        // looks like leading whitespace; keep scanning
+      } else {
+        fprintf(stderr,
+                OUT_TAG
+                ": unexpected chars (0x%02x) in tag number on line %d\n",
+                *cp, lineNum);
         errno = EINVAL;
         return -1;
+      }
+    } else {
+      // this is a blank or comment line
     }
+    cp++;
+  }
 
-    bool lineStart = true;
-    int lineNum = 1;
-    while (cp < endp) {
-        if (*cp == '\n') {
-            lineStart = true;
-            lineNum++;
-        } else if (lineStart) {
-            if (*cp == '#') {
-                // comment; just scan to end
-                lineStart = false;
-            } else if (isdigit(*cp)) {
-                // looks like a tag; scan it out
-                if (scanTagLine(map, &cp, lineNum) != 0) {
-                    if (!which || (errno != EMLINK)) {
-                        return -1;
-                    }
-                }
-                lineNum++;      // we eat the '\n'
-                // leave lineStart==true
-            } else if (isspace(*cp)) {
-                // looks like leading whitespace; keep scanning
-            } else {
-                fprintf(stderr,
-                        OUT_TAG ": unexpected chars (0x%02x) in tag number on line %d\n",
-                        *cp, lineNum);
-                errno = EINVAL;
-                return -1;
-            }
-        } else {
-            // this is a blank or comment line
-        }
-        cp++;
-    }
-
-    return 0;
+  return 0;
 }
 
 // Open the map file and allocate a structure to manage it.
@@ -393,159 +401,155 @@
 // We create a private mapping because we want to terminate the log tag
 // strings with '\0'.
 LIBLOG_ABI_PUBLIC EventTagMap* android_openEventTagMap(const char* fileName) {
-    EventTagMap* newTagMap;
-    off_t end[NUM_MAPS];
-    int save_errno, fd[NUM_MAPS];
-    size_t which;
+  EventTagMap* newTagMap;
+  off_t end[NUM_MAPS];
+  int save_errno, fd[NUM_MAPS];
+  size_t which;
 
-    memset(fd, -1, sizeof(fd));
-    memset(end, 0, sizeof(end));
+  memset(fd, -1, sizeof(fd));
+  memset(end, 0, sizeof(end));
 
-    for (which = 0; which < NUM_MAPS; ++which) {
+  for (which = 0; which < NUM_MAPS; ++which) {
+    const char* tagfile = fileName ? fileName : eventTagFiles[which];
+
+    fd[which] = open(tagfile, O_RDONLY | O_CLOEXEC);
+    if (fd[which] < 0) {
+      if (!which) {
+        save_errno = errno;
+        fprintf(stderr, OUT_TAG ": unable to open map '%s': %s\n", tagfile,
+                strerror(save_errno));
+        goto fail_errno;
+      }
+      continue;
+    }
+    end[which] = lseek(fd[which], 0L, SEEK_END);
+    save_errno = errno;
+    (void)lseek(fd[which], 0L, SEEK_SET);
+    if (!which && (end[0] < 0)) {
+      fprintf(stderr, OUT_TAG ": unable to seek map '%s' %s\n", tagfile,
+              strerror(save_errno));
+      goto fail_close;
+    }
+    if (fileName) break;  // Only allow one as specified
+  }
+
+  newTagMap = new EventTagMap;
+  if (newTagMap == NULL) {
+    save_errno = errno;
+    goto fail_close;
+  }
+
+  for (which = 0; which < NUM_MAPS; ++which) {
+    if (fd[which] >= 0) {
+      newTagMap->mapAddr[which] =
+          mmap(NULL, end[which], which ? PROT_READ : PROT_READ | PROT_WRITE,
+               which ? MAP_SHARED : MAP_PRIVATE, fd[which], 0);
+      save_errno = errno;
+      close(fd[which]);
+      fd[which] = -1;
+      if ((newTagMap->mapAddr[which] != MAP_FAILED) &&
+          (newTagMap->mapAddr[which] != NULL)) {
+        newTagMap->mapLen[which] = end[which];
+      } else if (!which) {
         const char* tagfile = fileName ? fileName : eventTagFiles[which];
 
-        fd[which] = open(tagfile, O_RDONLY | O_CLOEXEC);
-        if (fd[which] < 0) {
-            if (!which) {
-                save_errno = errno;
-                fprintf(stderr, OUT_TAG ": unable to open map '%s': %s\n",
-                        tagfile, strerror(save_errno));
-                goto fail_errno;
-            }
-            continue;
-        }
-        end[which] = lseek(fd[which], 0L, SEEK_END);
-        save_errno = errno;
-        (void)lseek(fd[which], 0L, SEEK_SET);
-        if (!which && (end[0] < 0)) {
-            fprintf(stderr, OUT_TAG ": unable to seek map '%s' %s\n",
-                    tagfile, strerror(save_errno));
-            goto fail_close;
-        }
-        if (fileName) break; // Only allow one as specified
+        fprintf(stderr, OUT_TAG ": mmap(%s) failed: %s\n", tagfile,
+                strerror(save_errno));
+        goto fail_unmap;
+      }
     }
+  }
 
-    newTagMap = new EventTagMap;
-    if (newTagMap == NULL) {
-        save_errno = errno;
-        goto fail_close;
+  for (which = 0; which < NUM_MAPS; ++which) {
+    if (parseMapLines(newTagMap, which) != 0) {
+      delete newTagMap;
+      return NULL;
     }
+  }
 
-    for (which = 0; which < NUM_MAPS; ++which) {
-        if (fd[which] >= 0) {
-            newTagMap->mapAddr[which] = mmap(NULL, end[which],
-                                             which ?
-                                                 PROT_READ :
-                                                 PROT_READ | PROT_WRITE,
-                                             which ?
-                                                 MAP_SHARED :
-                                                 MAP_PRIVATE,
-                                             fd[which], 0);
-            save_errno = errno;
-            close(fd[which]);
-            fd[which] = -1;
-            if ((newTagMap->mapAddr[which] != MAP_FAILED) &&
-                (newTagMap->mapAddr[which] != NULL)) {
-                newTagMap->mapLen[which] = end[which];
-            } else if (!which) {
-                const char* tagfile = fileName ? fileName : eventTagFiles[which];
-
-                fprintf(stderr, OUT_TAG ": mmap(%s) failed: %s\n",
-                        tagfile, strerror(save_errno));
-                goto fail_unmap;
-            }
-        }
-    }
-
-    for (which = 0; which < NUM_MAPS; ++which) {
-        if (parseMapLines(newTagMap, which) != 0) {
-            delete newTagMap;
-            return NULL;
-        }
-    }
-
-    return newTagMap;
+  return newTagMap;
 
 fail_unmap:
-    save_errno = EINVAL;
-    delete newTagMap;
+  save_errno = EINVAL;
+  delete newTagMap;
 fail_close:
-    for (which = 0; which < NUM_MAPS; ++which) close(fd[which]);
+  for (which = 0; which < NUM_MAPS; ++which) close(fd[which]);
 fail_errno:
-    errno = save_errno;
-    return NULL;
+  errno = save_errno;
+  return NULL;
 }
 
 // Close the map.
 LIBLOG_ABI_PUBLIC void android_closeEventTagMap(EventTagMap* map) {
-    if (map) delete map;
+  if (map) delete map;
 }
 
 // Cache miss, go to logd to acquire a public reference.
 // Because we lack access to a SHARED PUBLIC /dev/event-log-tags file map?
 static const TagFmt* __getEventTag(EventTagMap* map, unsigned int tag) {
-    // call event tag service to arrange for a new tag
-    char *buf = NULL;
-    // Can not use android::base::StringPrintf, asprintf + free instead.
-    static const char command_template[] = "getEventTag id=%u";
-    int ret = asprintf(&buf, command_template, tag);
-    if (ret > 0) {
-        // Add some buffer margin for an estimate of the full return content.
-        char *cp;
-        size_t size = ret - strlen(command_template) +
-            strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
-        if (size > (size_t)ret) {
-            cp = static_cast<char*>(realloc(buf, size));
-            if (cp) {
-                buf = cp;
-            } else {
-                size = ret;
-            }
-        } else {
-            size = ret;
-        }
-        // Ask event log tag service for an existing entry
-        if (__send_log_msg(buf, size) >= 0) {
-            buf[size - 1] = '\0';
-            unsigned long val = strtoul(buf, &cp, 10); // return size
-            if ((buf != cp) && (val > 0) && (*cp == '\n')) { // truncation OK
-                ++cp;
-                if (!scanTagLine(map, &cp, 0)) {
-                    free(buf);
-                    return map->find(tag);
-                }
-            }
-        }
-        free(buf);
+  // call event tag service to arrange for a new tag
+  char* buf = NULL;
+  // Can not use android::base::StringPrintf, asprintf + free instead.
+  static const char command_template[] = "getEventTag id=%u";
+  int ret = asprintf(&buf, command_template, tag);
+  if (ret > 0) {
+    // Add some buffer margin for an estimate of the full return content.
+    char* cp;
+    size_t size =
+        ret - strlen(command_template) +
+        strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
+    if (size > (size_t)ret) {
+      cp = static_cast<char*>(realloc(buf, size));
+      if (cp) {
+        buf = cp;
+      } else {
+        size = ret;
+      }
+    } else {
+      size = ret;
     }
-    return NULL;
+    // Ask event log tag service for an existing entry
+    if (__send_log_msg(buf, size) >= 0) {
+      buf[size - 1] = '\0';
+      unsigned long val = strtoul(buf, &cp, 10);        // return size
+      if ((buf != cp) && (val > 0) && (*cp == '\n')) {  // truncation OK
+        ++cp;
+        if (!scanTagLine(map, &cp, 0)) {
+          free(buf);
+          return map->find(tag);
+        }
+      }
+    }
+    free(buf);
+  }
+  return NULL;
 }
 
 // Look up an entry in the map.
 LIBLOG_ABI_PUBLIC const char* android_lookupEventTag_len(const EventTagMap* map,
-                                                         size_t *len,
+                                                         size_t* len,
                                                          unsigned int tag) {
-    if (len) *len = 0;
-    const TagFmt* str = map->find(tag);
-    if (!str) {
-        str = __getEventTag(const_cast<EventTagMap*>(map), tag);
-    }
-    if (!str) return NULL;
-    if (len) *len = str->first.length();
-    return str->first.data();
+  if (len) *len = 0;
+  const TagFmt* str = map->find(tag);
+  if (!str) {
+    str = __getEventTag(const_cast<EventTagMap*>(map), tag);
+  }
+  if (!str) return NULL;
+  if (len) *len = str->first.length();
+  return str->first.data();
 }
 
 // Look up an entry in the map.
 LIBLOG_ABI_PUBLIC const char* android_lookupEventFormat_len(
-        const EventTagMap* map, size_t *len, unsigned int tag) {
-    if (len) *len = 0;
-    const TagFmt* str = map->find(tag);
-    if (!str) {
-        str = __getEventTag(const_cast<EventTagMap*>(map), tag);
-    }
-    if (!str) return NULL;
-    if (len) *len = str->second.length();
-    return str->second.data();
+    const EventTagMap* map, size_t* len, unsigned int tag) {
+  if (len) *len = 0;
+  const TagFmt* str = map->find(tag);
+  if (!str) {
+    str = __getEventTag(const_cast<EventTagMap*>(map), tag);
+  }
+  if (!str) return NULL;
+  if (len) *len = str->second.length();
+  return str->second.data();
 }
 
 // This function is deprecated and replaced with android_lookupEventTag_len
@@ -554,84 +558,84 @@
 // deprecating this function everywhere, we save 100s of MB of memory space.
 LIBLOG_ABI_PUBLIC const char* android_lookupEventTag(const EventTagMap* map,
                                                      unsigned int tag) {
-    size_t len;
-    const char* tagStr = android_lookupEventTag_len(map, &len, tag);
+  size_t len;
+  const char* tagStr = android_lookupEventTag_len(map, &len, tag);
 
-    if (!tagStr) return tagStr;
-    char* cp = const_cast<char*>(tagStr);
-    cp += len;
-    if (*cp) *cp = '\0'; // Trigger copy on write :-( and why deprecated.
-    return tagStr;
+  if (!tagStr) return tagStr;
+  char* cp = const_cast<char*>(tagStr);
+  cp += len;
+  if (*cp) *cp = '\0';  // Trigger copy on write :-( and why deprecated.
+  return tagStr;
 }
 
 // Look up tagname, generate one if necessary, and return a tag
 LIBLOG_ABI_PUBLIC int android_lookupEventTagNum(EventTagMap* map,
                                                 const char* tagname,
-                                                const char* format,
-                                                int prio) {
-    size_t len = strlen(tagname);
-    if (!len) {
-        errno = EINVAL;
-        return -1;
+                                                const char* format, int prio) {
+  size_t len = strlen(tagname);
+  if (!len) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  if ((prio != ANDROID_LOG_UNKNOWN) && (prio < ANDROID_LOG_SILENT) &&
+      !__android_log_is_loggable_len(prio, tagname, len,
+                                     __android_log_is_debuggable()
+                                         ? ANDROID_LOG_VERBOSE
+                                         : ANDROID_LOG_DEBUG)) {
+    errno = EPERM;
+    return -1;
+  }
+
+  if (!format) format = "";
+  ssize_t fmtLen = strlen(format);
+  int ret = map->find(TagFmt(
+      std::make_pair(MapString(tagname, len), MapString(format, fmtLen))));
+  if (ret != -1) return ret;
+
+  // call event tag service to arrange for a new tag
+  char* buf = NULL;
+  // Can not use android::base::StringPrintf, asprintf + free instead.
+  static const char command_template[] = "getEventTag name=%s format=\"%s\"";
+  ret = asprintf(&buf, command_template, tagname, format);
+  if (ret > 0) {
+    // Add some buffer margin for an estimate of the full return content.
+    char* cp;
+    size_t size =
+        ret - strlen(command_template) +
+        strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
+    if (size > (size_t)ret) {
+      cp = static_cast<char*>(realloc(buf, size));
+      if (cp) {
+        buf = cp;
+      } else {
+        size = ret;
+      }
+    } else {
+      size = ret;
     }
-
-    if ((prio != ANDROID_LOG_UNKNOWN) && (prio < ANDROID_LOG_SILENT) &&
-            !__android_log_is_loggable_len(prio, tagname, len,
-                                           __android_log_is_debuggable() ?
-                                             ANDROID_LOG_VERBOSE :
-                                             ANDROID_LOG_DEBUG)) {
-        errno = EPERM;
-        return -1;
-    }
-
-    if (!format) format="";
-    ssize_t fmtLen = strlen(format);
-    int ret = map->find(TagFmt(std::make_pair(MapString(tagname, len),
-                                              MapString(format, fmtLen))));
-    if (ret != -1) return ret;
-
-    // call event tag service to arrange for a new tag
-    char *buf = NULL;
-    // Can not use android::base::StringPrintf, asprintf + free instead.
-    static const char command_template[] = "getEventTag name=%s format=\"%s\"";
-    ret = asprintf(&buf, command_template, tagname, format);
-    if (ret > 0) {
-        // Add some buffer margin for an estimate of the full return content.
-        char *cp;
-        size_t size = ret - strlen(command_template) +
-            strlen("65535\n4294967295\t?\t\t\t?\t# uid=32767\n\n\f?success?");
-        if (size > (size_t)ret) {
-            cp = static_cast<char*>(realloc(buf, size));
-            if (cp) {
-                buf = cp;
-            } else {
-                size = ret;
-            }
-        } else {
-            size = ret;
+    // Ask event log tag service for an allocation
+    if (__send_log_msg(buf, size) >= 0) {
+      buf[size - 1] = '\0';
+      unsigned long val = strtoul(buf, &cp, 10);        // return size
+      if ((buf != cp) && (val > 0) && (*cp == '\n')) {  // truncation OK
+        val = strtoul(cp + 1, &cp, 10);                 // allocated tag number
+        if ((val > 0) && (val < UINT32_MAX) && (*cp == '\t')) {
+          free(buf);
+          ret = val;
+          // cache
+          map->emplaceUnique(ret, TagFmt(std::make_pair(
+                                      MapString(std::string(tagname, len)),
+                                      MapString(std::string(format, fmtLen)))));
+          return ret;
         }
-        // Ask event log tag service for an allocation
-        if (__send_log_msg(buf, size) >= 0) {
-            buf[size - 1] = '\0';
-            unsigned long val = strtoul(buf, &cp, 10); // return size
-            if ((buf != cp) && (val > 0) && (*cp == '\n')) { // truncation OK
-                val = strtoul(cp + 1, &cp, 10); // allocated tag number
-                if ((val > 0) && (val < UINT32_MAX) && (*cp == '\t')) {
-                    free(buf);
-                    ret = val;
-                    // cache
-                    map->emplaceUnique(ret, TagFmt(std::make_pair(
-                            MapString(std::string(tagname, len)),
-                            MapString(std::string(format, fmtLen)))));
-                    return ret;
-                }
-            }
-        }
-        free(buf);
+      }
     }
+    free(buf);
+  }
 
-    // Hail Mary
-    ret = map->find(MapString(tagname, len));
-    if (ret == -1) errno = ESRCH;
-    return ret;
+  // Hail Mary
+  ret = map->find(MapString(tagname, len));
+  if (ret == -1) errno = ESRCH;
+  return ret;
 }
diff --git a/liblog/fake_log_device.c b/liblog/fake_log_device.c
index 1d7a157..ae7a334 100644
--- a/liblog/fake_log_device.c
+++ b/liblog/fake_log_device.c
@@ -37,9 +37,9 @@
 #include "fake_log_device.h"
 #include "log_portability.h"
 
-#define kMaxTagLen  16      /* from the long-dead utils/Log.cpp */
+#define kMaxTagLen 16 /* from the long-dead utils/Log.cpp */
 
-#define kTagSetSize 16      /* arbitrary */
+#define kTagSetSize 16 /* arbitrary */
 
 #if 0
 #define TRACE(...) printf("fake_log_device: " __VA_ARGS__)
@@ -49,45 +49,43 @@
 
 /* from the long-dead utils/Log.cpp */
 typedef enum {
-    FORMAT_OFF = 0,
-    FORMAT_BRIEF,
-    FORMAT_PROCESS,
-    FORMAT_TAG,
-    FORMAT_THREAD,
-    FORMAT_RAW,
-    FORMAT_TIME,
-    FORMAT_THREADTIME,
-    FORMAT_LONG
+  FORMAT_OFF = 0,
+  FORMAT_BRIEF,
+  FORMAT_PROCESS,
+  FORMAT_TAG,
+  FORMAT_THREAD,
+  FORMAT_RAW,
+  FORMAT_TIME,
+  FORMAT_THREADTIME,
+  FORMAT_LONG
 } LogFormat;
 
-
 /*
  * Log driver state.
  */
 typedef struct LogState {
-    /* the fake fd that's seen by the user */
-    int     fakeFd;
+  /* the fake fd that's seen by the user */
+  int fakeFd;
 
-    /* a printable name for this fake device */
-    char   debugName[sizeof("/dev/log/security")];
+  /* a printable name for this fake device */
+  char debugName[sizeof("/dev/log/security")];
 
-    /* nonzero if this is a binary log */
-    int     isBinary;
+  /* nonzero if this is a binary log */
+  int isBinary;
 
-    /* global minimum priority */
-    int     globalMinPriority;
+  /* global minimum priority */
+  int globalMinPriority;
 
-    /* output format */
-    LogFormat outputFormat;
+  /* output format */
+  LogFormat outputFormat;
 
-    /* tags and priorities */
-    struct {
-        char    tag[kMaxTagLen];
-        int     minPriority;
-    } tagSet[kTagSetSize];
+  /* tags and priorities */
+  struct {
+    char tag[kMaxTagLen];
+    int minPriority;
+  } tagSet[kTagSetSize];
 } LogState;
 
-
 #if !defined(_WIN32)
 /*
  * Locking.  Since we're emulating a device, we need to be prepared
@@ -97,28 +95,25 @@
  */
 static pthread_mutex_t fakeLogDeviceLock = PTHREAD_MUTEX_INITIALIZER;
 
-static void lock()
-{
-    /*
-     * If we trigger a signal handler in the middle of locked activity and the
-     * signal handler logs a message, we could get into a deadlock state.
-     */
-    pthread_mutex_lock(&fakeLogDeviceLock);
+static void lock() {
+  /*
+   * If we trigger a signal handler in the middle of locked activity and the
+   * signal handler logs a message, we could get into a deadlock state.
+   */
+  pthread_mutex_lock(&fakeLogDeviceLock);
 }
 
-static void unlock()
-{
-    pthread_mutex_unlock(&fakeLogDeviceLock);
+static void unlock() {
+  pthread_mutex_unlock(&fakeLogDeviceLock);
 }
 
-#else   // !defined(_WIN32)
+#else  // !defined(_WIN32)
 
 #define lock() ((void)0)
 #define unlock() ((void)0)
 
 #endif  // !defined(_WIN32)
 
-
 /*
  * File descriptor management.
  */
@@ -130,45 +125,42 @@
  * Allocate an fd and associate a new LogState with it.
  * The fd is available via the fakeFd field of the return value.
  */
-static LogState *createLogState()
-{
-    size_t i;
+static LogState* createLogState() {
+  size_t i;
 
-    for (i = 0; i < (sizeof(openLogTable) / sizeof(openLogTable[0])); i++) {
-        if (openLogTable[i].fakeFd == 0) {
-            openLogTable[i].fakeFd = FAKE_FD_BASE + i;
-            return &openLogTable[i];
-        }
+  for (i = 0; i < (sizeof(openLogTable) / sizeof(openLogTable[0])); i++) {
+    if (openLogTable[i].fakeFd == 0) {
+      openLogTable[i].fakeFd = FAKE_FD_BASE + i;
+      return &openLogTable[i];
     }
-    return NULL;
+  }
+  return NULL;
 }
 
 /*
  * Translate an fd to a LogState.
  */
-static LogState *fdToLogState(int fd)
-{
-    if (fd >= FAKE_FD_BASE && fd < FAKE_FD_BASE + MAX_OPEN_LOGS) {
-        return &openLogTable[fd - FAKE_FD_BASE];
-    }
-    return NULL;
+static LogState* fdToLogState(int fd) {
+  if (fd >= FAKE_FD_BASE && fd < FAKE_FD_BASE + MAX_OPEN_LOGS) {
+    return &openLogTable[fd - FAKE_FD_BASE];
+  }
+  return NULL;
 }
 
 /*
  * Unregister the fake fd and free the memory it pointed to.
  */
-static void deleteFakeFd(int fd)
-{
-    LogState *ls;
+static void deleteFakeFd(int fd) {
+  LogState* ls;
 
-    lock();
+  lock();
 
-    ls = fdToLogState(fd);
-    if (ls != NULL) {
-        memset(&openLogTable[fd - FAKE_FD_BASE], 0, sizeof(openLogTable[0]));
-    }
+  ls = fdToLogState(fd);
+  if (ls != NULL) {
+    memset(&openLogTable[fd - FAKE_FD_BASE], 0, sizeof(openLogTable[0]));
+  }
 
-    unlock();
+  unlock();
 }
 
 /*
@@ -184,145 +176,154 @@
  * We also want to check ANDROID_PRINTF_LOG to determine how the output
  * will look.
  */
-static void configureInitialState(const char* pathName, LogState* logState)
-{
-    static const int kDevLogLen = sizeof("/dev/log/") - 1;
+static void configureInitialState(const char* pathName, LogState* logState) {
+  static const int kDevLogLen = sizeof("/dev/log/") - 1;
 
-    strncpy(logState->debugName, pathName, sizeof(logState->debugName));
-    logState->debugName[sizeof(logState->debugName) - 1] = '\0';
+  strncpy(logState->debugName, pathName, sizeof(logState->debugName));
+  logState->debugName[sizeof(logState->debugName) - 1] = '\0';
 
-    /* identify binary logs */
-    if (!strcmp(pathName + kDevLogLen, "events") ||
-            !strcmp(pathName + kDevLogLen, "security")) {
-        logState->isBinary = 1;
-    }
+  /* identify binary logs */
+  if (!strcmp(pathName + kDevLogLen, "events") ||
+      !strcmp(pathName + kDevLogLen, "security")) {
+    logState->isBinary = 1;
+  }
 
-    /* global min priority defaults to "info" level */
-    logState->globalMinPriority = ANDROID_LOG_INFO;
+  /* global min priority defaults to "info" level */
+  logState->globalMinPriority = ANDROID_LOG_INFO;
 
-    /*
-     * This is based on the the long-dead utils/Log.cpp code.
-     */
-    const char* tags = getenv("ANDROID_LOG_TAGS");
-    TRACE("Found ANDROID_LOG_TAGS='%s'\n", tags);
-    if (tags != NULL) {
-        int entry = 0;
+  /*
+   * This is based on the the long-dead utils/Log.cpp code.
+   */
+  const char* tags = getenv("ANDROID_LOG_TAGS");
+  TRACE("Found ANDROID_LOG_TAGS='%s'\n", tags);
+  if (tags != NULL) {
+    int entry = 0;
 
-        while (*tags != '\0') {
-            char tagName[kMaxTagLen];
-            int i, minPrio;
+    while (*tags != '\0') {
+      char tagName[kMaxTagLen];
+      int i, minPrio;
 
-            while (isspace(*tags))
-                tags++;
+      while (isspace(*tags)) tags++;
 
-            i = 0;
-            while (*tags != '\0' && !isspace(*tags) && *tags != ':' &&
-                    i < kMaxTagLen) {
-                tagName[i++] = *tags++;
-            }
-            if (i == kMaxTagLen) {
-                TRACE("ERROR: env tag too long (%d chars max)\n", kMaxTagLen-1);
-                return;
-            }
-            tagName[i] = '\0';
+      i = 0;
+      while (*tags != '\0' && !isspace(*tags) && *tags != ':' &&
+             i < kMaxTagLen) {
+        tagName[i++] = *tags++;
+      }
+      if (i == kMaxTagLen) {
+        TRACE("ERROR: env tag too long (%d chars max)\n", kMaxTagLen - 1);
+        return;
+      }
+      tagName[i] = '\0';
 
-            /* default priority, if there's no ":" part; also zero out '*' */
+      /* default priority, if there's no ":" part; also zero out '*' */
+      minPrio = ANDROID_LOG_VERBOSE;
+      if (tagName[0] == '*' && tagName[1] == '\0') {
+        minPrio = ANDROID_LOG_DEBUG;
+        tagName[0] = '\0';
+      }
+
+      if (*tags == ':') {
+        tags++;
+        if (*tags >= '0' && *tags <= '9') {
+          if (*tags >= ('0' + ANDROID_LOG_SILENT))
             minPrio = ANDROID_LOG_VERBOSE;
-            if (tagName[0] == '*' && tagName[1] == '\0') {
-                minPrio = ANDROID_LOG_DEBUG;
-                tagName[0] = '\0';
-            }
-
-            if (*tags == ':') {
-                tags++;
-                if (*tags >= '0' && *tags <= '9') {
-                    if (*tags >= ('0' + ANDROID_LOG_SILENT))
-                        minPrio = ANDROID_LOG_VERBOSE;
-                    else
-                        minPrio = *tags - '\0';
-                } else {
-                    switch (*tags) {
-                    case 'v':   minPrio = ANDROID_LOG_VERBOSE;  break;
-                    case 'd':   minPrio = ANDROID_LOG_DEBUG;    break;
-                    case 'i':   minPrio = ANDROID_LOG_INFO;     break;
-                    case 'w':   minPrio = ANDROID_LOG_WARN;     break;
-                    case 'e':   minPrio = ANDROID_LOG_ERROR;    break;
-                    case 'f':   minPrio = ANDROID_LOG_FATAL;    break;
-                    case 's':   minPrio = ANDROID_LOG_SILENT;   break;
-                    default:    minPrio = ANDROID_LOG_DEFAULT;  break;
-                    }
-                }
-
-                tags++;
-                if (*tags != '\0' && !isspace(*tags)) {
-                    TRACE("ERROR: garbage in tag env; expected whitespace\n");
-                    TRACE("       env='%s'\n", tags);
-                    return;
-                }
-            }
-
-            if (tagName[0] == 0) {
-                logState->globalMinPriority = minPrio;
-                TRACE("+++ global min prio %d\n", logState->globalMinPriority);
-            } else {
-                logState->tagSet[entry].minPriority = minPrio;
-                strcpy(logState->tagSet[entry].tag, tagName);
-                TRACE("+++ entry %d: %s:%d\n",
-                    entry,
-                    logState->tagSet[entry].tag,
-                    logState->tagSet[entry].minPriority);
-                entry++;
-            }
+          else
+            minPrio = *tags - '\0';
+        } else {
+          switch (*tags) {
+            case 'v':
+              minPrio = ANDROID_LOG_VERBOSE;
+              break;
+            case 'd':
+              minPrio = ANDROID_LOG_DEBUG;
+              break;
+            case 'i':
+              minPrio = ANDROID_LOG_INFO;
+              break;
+            case 'w':
+              minPrio = ANDROID_LOG_WARN;
+              break;
+            case 'e':
+              minPrio = ANDROID_LOG_ERROR;
+              break;
+            case 'f':
+              minPrio = ANDROID_LOG_FATAL;
+              break;
+            case 's':
+              minPrio = ANDROID_LOG_SILENT;
+              break;
+            default:
+              minPrio = ANDROID_LOG_DEFAULT;
+              break;
+          }
         }
+
+        tags++;
+        if (*tags != '\0' && !isspace(*tags)) {
+          TRACE("ERROR: garbage in tag env; expected whitespace\n");
+          TRACE("       env='%s'\n", tags);
+          return;
+        }
+      }
+
+      if (tagName[0] == 0) {
+        logState->globalMinPriority = minPrio;
+        TRACE("+++ global min prio %d\n", logState->globalMinPriority);
+      } else {
+        logState->tagSet[entry].minPriority = minPrio;
+        strcpy(logState->tagSet[entry].tag, tagName);
+        TRACE("+++ entry %d: %s:%d\n", entry, logState->tagSet[entry].tag,
+              logState->tagSet[entry].minPriority);
+        entry++;
+      }
     }
+  }
 
+  /*
+   * Taken from the long-dead utils/Log.cpp
+   */
+  const char* fstr = getenv("ANDROID_PRINTF_LOG");
+  LogFormat format;
+  if (fstr == NULL) {
+    format = FORMAT_BRIEF;
+  } else {
+    if (strcmp(fstr, "brief") == 0)
+      format = FORMAT_BRIEF;
+    else if (strcmp(fstr, "process") == 0)
+      format = FORMAT_PROCESS;
+    else if (strcmp(fstr, "tag") == 0)
+      format = FORMAT_PROCESS;
+    else if (strcmp(fstr, "thread") == 0)
+      format = FORMAT_PROCESS;
+    else if (strcmp(fstr, "raw") == 0)
+      format = FORMAT_PROCESS;
+    else if (strcmp(fstr, "time") == 0)
+      format = FORMAT_PROCESS;
+    else if (strcmp(fstr, "long") == 0)
+      format = FORMAT_PROCESS;
+    else
+      format = (LogFormat)atoi(fstr);  // really?!
+  }
 
-    /*
-     * Taken from the long-dead utils/Log.cpp
-     */
-    const char* fstr = getenv("ANDROID_PRINTF_LOG");
-    LogFormat format;
-    if (fstr == NULL) {
-        format = FORMAT_BRIEF;
-    } else {
-        if (strcmp(fstr, "brief") == 0)
-            format = FORMAT_BRIEF;
-        else if (strcmp(fstr, "process") == 0)
-            format = FORMAT_PROCESS;
-        else if (strcmp(fstr, "tag") == 0)
-            format = FORMAT_PROCESS;
-        else if (strcmp(fstr, "thread") == 0)
-            format = FORMAT_PROCESS;
-        else if (strcmp(fstr, "raw") == 0)
-            format = FORMAT_PROCESS;
-        else if (strcmp(fstr, "time") == 0)
-            format = FORMAT_PROCESS;
-        else if (strcmp(fstr, "long") == 0)
-            format = FORMAT_PROCESS;
-        else
-            format = (LogFormat) atoi(fstr);        // really?!
-    }
-
-    logState->outputFormat = format;
+  logState->outputFormat = format;
 }
 
 /*
  * Return a human-readable string for the priority level.  Always returns
  * a valid string.
  */
-static const char* getPriorityString(int priority)
-{
-    /* the first character of each string should be unique */
-    static const char* priorityStrings[] = {
-        "Verbose", "Debug", "Info", "Warn", "Error", "Assert"
-    };
-    int idx;
+static const char* getPriorityString(int priority) {
+  /* the first character of each string should be unique */
+  static const char* priorityStrings[] = { "Verbose", "Debug", "Info",
+                                           "Warn",    "Error", "Assert" };
+  int idx;
 
-    idx = (int)priority - (int)ANDROID_LOG_VERBOSE;
-    if (idx < 0 ||
-            idx >= (int)(sizeof(priorityStrings) / sizeof(priorityStrings[0])))
-        return "?unknown?";
-    return priorityStrings[idx];
+  idx = (int)priority - (int)ANDROID_LOG_VERBOSE;
+  if (idx < 0 ||
+      idx >= (int)(sizeof(priorityStrings) / sizeof(priorityStrings[0])))
+    return "?unknown?";
+  return priorityStrings[idx];
 }
 
 #if defined(_WIN32)
@@ -330,227 +331,229 @@
  * WIN32 does not have writev().
  * Make up something to replace it.
  */
-static ssize_t fake_writev(int fd, const struct iovec *iov, int iovcnt) {
-    ssize_t result = 0;
-    const struct iovec* end = iov + iovcnt;
-    for (; iov < end; iov++) {
-        ssize_t w = write(fd, iov->iov_base, iov->iov_len);
-        if (w != (ssize_t) iov->iov_len) {
-            if (w < 0)
-                return w;
-            return result + w;
-        }
-        result += w;
+static ssize_t fake_writev(int fd, const struct iovec* iov, int iovcnt) {
+  ssize_t result = 0;
+  const struct iovec* end = iov + iovcnt;
+  for (; iov < end; iov++) {
+    ssize_t w = write(fd, iov->iov_base, iov->iov_len);
+    if (w != (ssize_t)iov->iov_len) {
+      if (w < 0) return w;
+      return result + w;
     }
-    return result;
+    result += w;
+  }
+  return result;
 }
 
 #define writev fake_writev
 #endif
 
-
 /*
  * Write a filtered log message to stderr.
  *
  * Log format parsing taken from the long-dead utils/Log.cpp.
  */
-static void showLog(LogState *state,
-        int logPrio, const char* tag, const char* msg)
-{
+static void showLog(LogState* state, int logPrio, const char* tag,
+                    const char* msg) {
 #if !defined(_WIN32)
-    struct tm tmBuf;
+  struct tm tmBuf;
 #endif
-    struct tm* ptm;
-    char timeBuf[32];
-    char prefixBuf[128], suffixBuf[128];
-    char priChar;
-    time_t when;
+  struct tm* ptm;
+  char timeBuf[32];
+  char prefixBuf[128], suffixBuf[128];
+  char priChar;
+  time_t when;
 #if !defined(_WIN32)
-    pid_t pid, tid;
+  pid_t pid, tid;
 #else
-    uint32_t pid, tid;
+  uint32_t pid, tid;
 #endif
 
-    TRACE("LOG %d: %s %s", logPrio, tag, msg);
+  TRACE("LOG %d: %s %s", logPrio, tag, msg);
 
-    priChar = getPriorityString(logPrio)[0];
-    when = time(NULL);
-    pid = tid = getpid();       // find gettid()?
+  priChar = getPriorityString(logPrio)[0];
+  when = time(NULL);
+  pid = tid = getpid();  // find gettid()?
 
-    /*
-     * Get the current date/time in pretty form
-     *
-     * It's often useful when examining a log with "less" to jump to
-     * a specific point in the file by searching for the date/time stamp.
-     * For this reason it's very annoying to have regexp meta characters
-     * in the time stamp.  Don't use forward slashes, parenthesis,
-     * brackets, asterisks, or other special chars here.
-     */
+/*
+ * Get the current date/time in pretty form
+ *
+ * It's often useful when examining a log with "less" to jump to
+ * a specific point in the file by searching for the date/time stamp.
+ * For this reason it's very annoying to have regexp meta characters
+ * in the time stamp.  Don't use forward slashes, parenthesis,
+ * brackets, asterisks, or other special chars here.
+ */
 #if !defined(_WIN32)
-    ptm = localtime_r(&when, &tmBuf);
+  ptm = localtime_r(&when, &tmBuf);
 #else
-    ptm = localtime(&when);
+  ptm = localtime(&when);
 #endif
-    //strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", ptm);
-    strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm);
+  // strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d %H:%M:%S", ptm);
+  strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm);
 
-    /*
-     * Construct a buffer containing the log header and log message.
-     */
-    size_t prefixLen, suffixLen;
+  /*
+   * Construct a buffer containing the log header and log message.
+   */
+  size_t prefixLen, suffixLen;
 
-    switch (state->outputFormat) {
+  switch (state->outputFormat) {
     case FORMAT_TAG:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%c/%-8s: ", priChar, tag);
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
+      prefixLen =
+          snprintf(prefixBuf, sizeof(prefixBuf), "%c/%-8s: ", priChar, tag);
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
     case FORMAT_PROCESS:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%c(%5d) ", priChar, pid);
-        suffixLen = snprintf(suffixBuf, sizeof(suffixBuf),
-            "  (%s)\n", tag);
-        break;
+      prefixLen =
+          snprintf(prefixBuf, sizeof(prefixBuf), "%c(%5d) ", priChar, pid);
+      suffixLen = snprintf(suffixBuf, sizeof(suffixBuf), "  (%s)\n", tag);
+      break;
     case FORMAT_THREAD:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%c(%5d:%5d) ", priChar, pid, tid);
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
+      prefixLen = snprintf(prefixBuf, sizeof(prefixBuf), "%c(%5d:%5d) ",
+                           priChar, pid, tid);
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
     case FORMAT_RAW:
-        prefixBuf[0] = 0; prefixLen = 0;
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
+      prefixBuf[0] = 0;
+      prefixLen = 0;
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
     case FORMAT_TIME:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%s %-8s\n\t", timeBuf, tag);
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
+      prefixLen =
+          snprintf(prefixBuf, sizeof(prefixBuf), "%s %-8s\n\t", timeBuf, tag);
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
     case FORMAT_THREADTIME:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%s %5d %5d %c %-8s \n\t", timeBuf, pid, tid, priChar, tag);
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
+      prefixLen =
+          snprintf(prefixBuf, sizeof(prefixBuf), "%s %5d %5d %c %-8s \n\t",
+                   timeBuf, pid, tid, priChar, tag);
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
     case FORMAT_LONG:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "[ %s %5d:%5d %c/%-8s ]\n",
-            timeBuf, pid, tid, priChar, tag);
-        strcpy(suffixBuf, "\n\n"); suffixLen = 2;
-        break;
+      prefixLen =
+          snprintf(prefixBuf, sizeof(prefixBuf), "[ %s %5d:%5d %c/%-8s ]\n",
+                   timeBuf, pid, tid, priChar, tag);
+      strcpy(suffixBuf, "\n\n");
+      suffixLen = 2;
+      break;
     default:
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
-            "%c/%-8s(%5d): ", priChar, tag, pid);
-        strcpy(suffixBuf, "\n"); suffixLen = 1;
-        break;
-     }
+      prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
+                           "%c/%-8s(%5d): ", priChar, tag, pid);
+      strcpy(suffixBuf, "\n");
+      suffixLen = 1;
+      break;
+  }
 
-    /*
-     * Figure out how many lines there will be.
-     */
-    const char* end = msg + strlen(msg);
-    size_t numLines = 0;
-    const char* p = msg;
-    while (p < end) {
-        if (*p++ == '\n') numLines++;
+  /*
+   * Figure out how many lines there will be.
+   */
+  const char* end = msg + strlen(msg);
+  size_t numLines = 0;
+  const char* p = msg;
+  while (p < end) {
+    if (*p++ == '\n') numLines++;
+  }
+  if (p > msg && *(p - 1) != '\n') {
+    numLines++;
+  }
+
+  /*
+   * Create an array of iovecs large enough to write all of
+   * the lines with a prefix and a suffix.
+   */
+  const size_t INLINE_VECS = 64;
+  const size_t MAX_LINES = ((size_t)~0) / (3 * sizeof(struct iovec*));
+  struct iovec stackVec[INLINE_VECS];
+  struct iovec* vec = stackVec;
+  size_t numVecs;
+
+  if (numLines > MAX_LINES) numLines = MAX_LINES;
+
+  numVecs = numLines * 3;  // 3 iovecs per line.
+  if (numVecs > INLINE_VECS) {
+    vec = (struct iovec*)malloc(sizeof(struct iovec) * numVecs);
+    if (vec == NULL) {
+      msg = "LOG: write failed, no memory";
+      numVecs = INLINE_VECS;
+      numLines = numVecs / 3;
+      vec = stackVec;
     }
-    if (p > msg && *(p-1) != '\n') {
-        numLines++;
+  }
+
+  /*
+   * Fill in the iovec pointers.
+   */
+  p = msg;
+  struct iovec* v = vec;
+  int totalLen = 0;
+  while (numLines > 0 && p < end) {
+    if (prefixLen > 0) {
+      v->iov_base = prefixBuf;
+      v->iov_len = prefixLen;
+      totalLen += prefixLen;
+      v++;
     }
-
-    /*
-     * Create an array of iovecs large enough to write all of
-     * the lines with a prefix and a suffix.
-     */
-    const size_t INLINE_VECS = 64;
-    const size_t MAX_LINES   = ((size_t)~0)/(3*sizeof(struct iovec*));
-    struct iovec stackVec[INLINE_VECS];
-    struct iovec* vec = stackVec;
-    size_t numVecs;
-
-    if (numLines > MAX_LINES)
-        numLines = MAX_LINES;
-
-    numVecs = numLines * 3;  // 3 iovecs per line.
-    if (numVecs > INLINE_VECS) {
-        vec = (struct iovec*)malloc(sizeof(struct iovec)*numVecs);
-        if (vec == NULL) {
-            msg = "LOG: write failed, no memory";
-            numVecs = INLINE_VECS;
-            numLines = numVecs / 3;
-            vec = stackVec;
-        }
+    const char* start = p;
+    while (p < end && *p != '\n') {
+      p++;
     }
-
-    /*
-     * Fill in the iovec pointers.
-     */
-    p = msg;
-    struct iovec* v = vec;
-    int totalLen = 0;
-    while (numLines > 0 && p < end) {
-        if (prefixLen > 0) {
-            v->iov_base = prefixBuf;
-            v->iov_len = prefixLen;
-            totalLen += prefixLen;
-            v++;
-        }
-        const char* start = p;
-        while (p < end && *p != '\n') {
-            p++;
-        }
-        if ((p-start) > 0) {
-            v->iov_base = (void*)start;
-            v->iov_len = p-start;
-            totalLen += p-start;
-            v++;
-        }
-        if (*p == '\n') p++;
-        if (suffixLen > 0) {
-            v->iov_base = suffixBuf;
-            v->iov_len = suffixLen;
-            totalLen += suffixLen;
-            v++;
-        }
-        numLines -= 1;
+    if ((p - start) > 0) {
+      v->iov_base = (void*)start;
+      v->iov_len = p - start;
+      totalLen += p - start;
+      v++;
     }
-
-    /*
-     * Write the entire message to the log file with a single writev() call.
-     * We need to use this rather than a collection of printf()s on a FILE*
-     * because of multi-threading and multi-process issues.
-     *
-     * If the file was not opened with O_APPEND, this will produce interleaved
-     * output when called on the same file from multiple processes.
-     *
-     * If the file descriptor is actually a network socket, the writev()
-     * call may return with a partial write.  Putting the writev() call in
-     * a loop can result in interleaved data.  This can be alleviated
-     * somewhat by wrapping the writev call in the Mutex.
-     */
-
-    for(;;) {
-        int cc = writev(fileno(stderr), vec, v-vec);
-
-        if (cc == totalLen) break;
-
-        if (cc < 0) {
-            if(errno == EINTR) continue;
-
-                /* can't really log the failure; for now, throw out a stderr */
-            fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
-            break;
-        } else {
-                /* shouldn't happen when writing to file or tty */
-            fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", cc, totalLen);
-            break;
-        }
+    if (*p == '\n') p++;
+    if (suffixLen > 0) {
+      v->iov_base = suffixBuf;
+      v->iov_len = suffixLen;
+      totalLen += suffixLen;
+      v++;
     }
+    numLines -= 1;
+  }
 
-    /* if we allocated storage for the iovecs, free it */
-    if (vec != stackVec)
-        free(vec);
+  /*
+   * Write the entire message to the log file with a single writev() call.
+   * We need to use this rather than a collection of printf()s on a FILE*
+   * because of multi-threading and multi-process issues.
+   *
+   * If the file was not opened with O_APPEND, this will produce interleaved
+   * output when called on the same file from multiple processes.
+   *
+   * If the file descriptor is actually a network socket, the writev()
+   * call may return with a partial write.  Putting the writev() call in
+   * a loop can result in interleaved data.  This can be alleviated
+   * somewhat by wrapping the writev call in the Mutex.
+   */
+
+  for (;;) {
+    int cc = writev(fileno(stderr), vec, v - vec);
+
+    if (cc == totalLen) break;
+
+    if (cc < 0) {
+      if (errno == EINTR) continue;
+
+      /* can't really log the failure; for now, throw out a stderr */
+      fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
+      break;
+    } else {
+      /* shouldn't happen when writing to file or tty */
+      fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", cc, totalLen);
+      break;
+    }
+  }
+
+  /* if we allocated storage for the iovecs, free it */
+  if (vec != stackVec) free(vec);
 }
 
-
 /*
  * Receive a log message.  We happen to know that "vector" has three parts:
  *
@@ -558,142 +561,135 @@
  *  tag (N bytes -- null-terminated ASCII string)
  *  message (N bytes -- null-terminated ASCII string)
  */
-static ssize_t logWritev(int fd, const struct iovec* vector, int count)
-{
-    LogState* state;
+static ssize_t logWritev(int fd, const struct iovec* vector, int count) {
+  LogState* state;
 
-    /* Make sure that no-one frees the LogState while we're using it.
-     * Also guarantees that only one thread is in showLog() at a given
-     * time (if it matters).
-     */
-    lock();
+  /* Make sure that no-one frees the LogState while we're using it.
+   * Also guarantees that only one thread is in showLog() at a given
+   * time (if it matters).
+   */
+  lock();
 
-    state = fdToLogState(fd);
-    if (state == NULL) {
-        errno = EBADF;
-        goto error;
+  state = fdToLogState(fd);
+  if (state == NULL) {
+    errno = EBADF;
+    goto error;
+  }
+
+  if (state->isBinary) {
+    TRACE("%s: ignoring binary log\n", state->debugName);
+    goto bail;
+  }
+
+  if (count != 3) {
+    TRACE("%s: writevLog with count=%d not expected\n", state->debugName, count);
+    goto error;
+  }
+
+  /* pull out the three fields */
+  int logPrio = *(const char*)vector[0].iov_base;
+  const char* tag = (const char*)vector[1].iov_base;
+  const char* msg = (const char*)vector[2].iov_base;
+
+  /* see if this log tag is configured */
+  int i;
+  int minPrio = state->globalMinPriority;
+  for (i = 0; i < kTagSetSize; i++) {
+    if (state->tagSet[i].minPriority == ANDROID_LOG_UNKNOWN)
+      break; /* reached end of configured values */
+
+    if (strcmp(state->tagSet[i].tag, tag) == 0) {
+      // TRACE("MATCH tag '%s'\n", tag);
+      minPrio = state->tagSet[i].minPriority;
+      break;
     }
+  }
 
-    if (state->isBinary) {
-        TRACE("%s: ignoring binary log\n", state->debugName);
-        goto bail;
-    }
-
-    if (count != 3) {
-        TRACE("%s: writevLog with count=%d not expected\n",
-            state->debugName, count);
-        goto error;
-    }
-
-    /* pull out the three fields */
-    int logPrio = *(const char*)vector[0].iov_base;
-    const char* tag = (const char*) vector[1].iov_base;
-    const char* msg = (const char*) vector[2].iov_base;
-
-    /* see if this log tag is configured */
-    int i;
-    int minPrio = state->globalMinPriority;
-    for (i = 0; i < kTagSetSize; i++) {
-        if (state->tagSet[i].minPriority == ANDROID_LOG_UNKNOWN)
-            break;      /* reached end of configured values */
-
-        if (strcmp(state->tagSet[i].tag, tag) == 0) {
-            //TRACE("MATCH tag '%s'\n", tag);
-            minPrio = state->tagSet[i].minPriority;
-            break;
-        }
-    }
-
-    if (logPrio >= minPrio) {
-        showLog(state, logPrio, tag, msg);
-    } else {
-        //TRACE("+++ NOLOG(%d): %s %s", logPrio, tag, msg);
-    }
+  if (logPrio >= minPrio) {
+    showLog(state, logPrio, tag, msg);
+  } else {
+    // TRACE("+++ NOLOG(%d): %s %s", logPrio, tag, msg);
+  }
 
 bail:
-    unlock();
-    int len = 0;
-    for (i = 0; i < count; ++i) {
-       len += vector[i].iov_len;
-    }
-    return len;
+  unlock();
+  int len = 0;
+  for (i = 0; i < count; ++i) {
+    len += vector[i].iov_len;
+  }
+  return len;
 
 error:
-    unlock();
-    return -1;
+  unlock();
+  return -1;
 }
 
 /*
  * Free up our state and close the fake descriptor.
  */
-static int logClose(int fd)
-{
-    deleteFakeFd(fd);
-    return 0;
+static int logClose(int fd) {
+  deleteFakeFd(fd);
+  return 0;
 }
 
 /*
  * Open a log output device and return a fake fd.
  */
-static int logOpen(const char* pathName, int flags __unused)
-{
-    LogState *logState;
-    int fd = -1;
+static int logOpen(const char* pathName, int flags __unused) {
+  LogState* logState;
+  int fd = -1;
 
-    lock();
+  lock();
 
-    logState = createLogState();
-    if (logState != NULL) {
-        configureInitialState(pathName, logState);
-        fd = logState->fakeFd;
-    } else  {
-        errno = ENFILE;
-    }
+  logState = createLogState();
+  if (logState != NULL) {
+    configureInitialState(pathName, logState);
+    fd = logState->fakeFd;
+  } else {
+    errno = ENFILE;
+  }
 
-    unlock();
+  unlock();
 
-    return fd;
+  return fd;
 }
 
-
 /*
  * Runtime redirection.  If this binary is running in the simulator,
  * just pass log messages to the emulated device.  If it's running
  * outside of the simulator, write the log messages to stderr.
  */
 
-static int (*redirectOpen)(const char *pathName, int flags) = NULL;
+static int (*redirectOpen)(const char* pathName, int flags) = NULL;
 static int (*redirectClose)(int fd) = NULL;
-static ssize_t (*redirectWritev)(int fd, const struct iovec* vector, int count)
-        = NULL;
+static ssize_t (*redirectWritev)(int fd, const struct iovec* vector,
+                                 int count) = NULL;
 
-static void setRedirects()
-{
-    const char *ws;
+static void setRedirects() {
+  const char* ws;
 
-    /* Wrapsim sets this environment variable on children that it's
-     * created using its LD_PRELOAD wrapper.
-     */
-    ws = getenv("ANDROID_WRAPSIM");
-    if (ws != NULL && strcmp(ws, "1") == 0) {
-        /* We're running inside wrapsim, so we can just write to the device. */
-        redirectOpen = (int (*)(const char *pathName, int flags))open;
-        redirectClose = close;
-        redirectWritev = writev;
-    } else {
-        /* There's no device to delegate to; handle the logging ourselves. */
-        redirectOpen = logOpen;
-        redirectClose = logClose;
-        redirectWritev = logWritev;
-    }
+  /* Wrapsim sets this environment variable on children that it's
+   * created using its LD_PRELOAD wrapper.
+   */
+  ws = getenv("ANDROID_WRAPSIM");
+  if (ws != NULL && strcmp(ws, "1") == 0) {
+    /* We're running inside wrapsim, so we can just write to the device. */
+    redirectOpen = (int (*)(const char* pathName, int flags))open;
+    redirectClose = close;
+    redirectWritev = writev;
+  } else {
+    /* There's no device to delegate to; handle the logging ourselves. */
+    redirectOpen = logOpen;
+    redirectClose = logClose;
+    redirectWritev = logWritev;
+  }
 }
 
-LIBLOG_HIDDEN int fakeLogOpen(const char *pathName, int flags)
-{
-    if (redirectOpen == NULL) {
-        setRedirects();
-    }
-    return redirectOpen(pathName, flags);
+LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags) {
+  if (redirectOpen == NULL) {
+    setRedirects();
+  }
+  return redirectOpen(pathName, flags);
 }
 
 /*
@@ -707,43 +703,37 @@
  * call is in the exit handler. Logging can continue in the exit handler to
  * help debug HOST tools ...
  */
-LIBLOG_HIDDEN int fakeLogClose(int fd)
-{
-    /* Assume that open() was called first. */
-    return redirectClose(fd);
+LIBLOG_HIDDEN int fakeLogClose(int fd) {
+  /* Assume that open() was called first. */
+  return redirectClose(fd);
 }
 
-LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd,
-                                    const struct iovec* vector, int count)
-{
-    /* Assume that open() was called first. */
-    return redirectWritev(fd, vector, count);
+LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector,
+                                    int count) {
+  /* Assume that open() was called first. */
+  return redirectWritev(fd, vector, count);
 }
 
-LIBLOG_HIDDEN ssize_t __send_log_msg(char *buf __unused,
-                                     size_t buf_size __unused)
-{
-    return -ENODEV;
+LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf __unused,
+                                     size_t buf_size __unused) {
+  return -ENODEV;
 }
 
 LIBLOG_ABI_PUBLIC int __android_log_is_loggable(int prio,
-                                                const char *tag __unused,
-                                                int def)
-{
-    int logLevel = def;
-    return logLevel >= 0 && prio >= logLevel;
+                                                const char* tag __unused,
+                                                int def) {
+  int logLevel = def;
+  return logLevel >= 0 && prio >= logLevel;
 }
 
 LIBLOG_ABI_PUBLIC int __android_log_is_loggable_len(int prio,
-                                                    const char *tag __unused,
+                                                    const char* tag __unused,
                                                     size_t len __unused,
-                                                    int def)
-{
-    int logLevel = def;
-    return logLevel >= 0 && prio >= logLevel;
+                                                    int def) {
+  int logLevel = def;
+  return logLevel >= 0 && prio >= logLevel;
 }
 
-LIBLOG_ABI_PRIVATE int __android_log_is_debuggable()
-{
-    return 1;
+LIBLOG_ABI_PRIVATE int __android_log_is_debuggable() {
+  return 1;
 }
diff --git a/liblog/fake_log_device.h b/liblog/fake_log_device.h
index 4529b5d..462d026 100644
--- a/liblog/fake_log_device.h
+++ b/liblog/fake_log_device.h
@@ -23,9 +23,9 @@
 
 struct iovec;
 
-LIBLOG_HIDDEN int fakeLogOpen(const char *pathName, int flags);
+LIBLOG_HIDDEN int fakeLogOpen(const char* pathName, int flags);
 LIBLOG_HIDDEN int fakeLogClose(int fd);
-LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd,
-                                    const struct iovec* vector, int count);
+LIBLOG_HIDDEN ssize_t fakeLogWritev(int fd, const struct iovec* vector,
+                                    int count);
 
-#endif // _LIBLOG_FAKE_LOG_DEVICE_H
+#endif  // _LIBLOG_FAKE_LOG_DEVICE_H
diff --git a/liblog/fake_writer.c b/liblog/fake_writer.c
index 2350673..969661a 100644
--- a/liblog/fake_writer.c
+++ b/liblog/fake_writer.c
@@ -27,78 +27,77 @@
 
 static int fakeOpen();
 static void fakeClose();
-static int fakeWrite(log_id_t log_id, struct timespec *ts,
-                     struct iovec *vec, size_t nr);
+static int fakeWrite(log_id_t log_id, struct timespec* ts, struct iovec* vec,
+                     size_t nr);
 
 static int logFds[(int)LOG_ID_MAX] = { -1, -1, -1, -1, -1, -1 };
 
 LIBLOG_HIDDEN struct android_log_transport_write fakeLoggerWrite = {
-    .node = { &fakeLoggerWrite.node, &fakeLoggerWrite.node },
-    .context.private = &logFds,
-    .name = "fake",
-    .available = NULL,
-    .open = fakeOpen,
-    .close = fakeClose,
-    .write = fakeWrite,
+  .node = { &fakeLoggerWrite.node, &fakeLoggerWrite.node },
+  .context.priv = &logFds,
+  .name = "fake",
+  .available = NULL,
+  .open = fakeOpen,
+  .close = fakeClose,
+  .write = fakeWrite,
 };
 
 static int fakeOpen() {
-    int i;
+  int i;
 
-    for (i = 0; i < LOG_ID_MAX; i++) {
-        /*
-         * Known maximum size string, plus an 8 character margin to deal with
-         * possible independent changes to android_log_id_to_name().
-         */
-        char buf[sizeof("/dev/log_security") + 8];
-        if (logFds[i] >= 0) {
-            continue;
-        }
-        snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i));
-        logFds[i] = fakeLogOpen(buf, O_WRONLY);
-        if (logFds[i] < 0) {
-            fprintf(stderr, "fakeLogOpen(%s, O_WRONLY) failed\n", buf);
-        }
+  for (i = 0; i < LOG_ID_MAX; i++) {
+    /*
+     * Known maximum size string, plus an 8 character margin to deal with
+     * possible independent changes to android_log_id_to_name().
+     */
+    char buf[sizeof("/dev/log_security") + 8];
+    if (logFds[i] >= 0) {
+      continue;
     }
-    return 0;
+    snprintf(buf, sizeof(buf), "/dev/log_%s", android_log_id_to_name(i));
+    logFds[i] = fakeLogOpen(buf, O_WRONLY);
+    if (logFds[i] < 0) {
+      fprintf(stderr, "fakeLogOpen(%s, O_WRONLY) failed\n", buf);
+    }
+  }
+  return 0;
 }
 
 static void fakeClose() {
-    int i;
+  int i;
 
-    for (i = 0; i < LOG_ID_MAX; i++) {
-        fakeLogClose(logFds[i]);
-        logFds[i] = -1;
-    }
+  for (i = 0; i < LOG_ID_MAX; i++) {
+    fakeLogClose(logFds[i]);
+    logFds[i] = -1;
+  }
 }
 
-static int fakeWrite(log_id_t log_id, struct timespec *ts __unused,
-                      struct iovec *vec, size_t nr)
-{
-    ssize_t ret;
-    size_t i;
-    int logFd, len;
+static int fakeWrite(log_id_t log_id, struct timespec* ts __unused,
+                     struct iovec* vec, size_t nr) {
+  ssize_t ret;
+  size_t i;
+  int logFd, len;
 
-    if (/*(int)log_id >= 0 &&*/ (int)log_id >= (int)LOG_ID_MAX) {
-        return -EINVAL;
-    }
+  if (/*(int)log_id >= 0 &&*/ (int)log_id >= (int)LOG_ID_MAX) {
+    return -EINVAL;
+  }
 
-    len = 0;
-    for (i = 0; i < nr; ++i) {
-        len += vec[i].iov_len;
-    }
+  len = 0;
+  for (i = 0; i < nr; ++i) {
+    len += vec[i].iov_len;
+  }
 
-    if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
-        len = LOGGER_ENTRY_MAX_PAYLOAD;
-    }
+  if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
+    len = LOGGER_ENTRY_MAX_PAYLOAD;
+  }
 
-    logFd = logFds[(int)log_id];
-    ret = TEMP_FAILURE_RETRY(fakeLogWritev(logFd, vec, nr));
-    if (ret < 0) {
-        ret = -errno;
-    } else if (ret > len) {
-        ret = len;
-    }
+  logFd = logFds[(int)log_id];
+  ret = TEMP_FAILURE_RETRY(fakeLogWritev(logFd, vec, nr));
+  if (ret < 0) {
+    ret = -errno;
+  } else if (ret > len) {
+    ret = len;
+  }
 
-    return ret;
+  return ret;
 }
diff --git a/liblog/include/android/log.h b/liblog/include/android/log.h
index 9f198fe..15fba8b 100644
--- a/liblog/include/android/log.h
+++ b/liblog/include/android/log.h
@@ -50,8 +50,8 @@
  * limit (e.g. 1023 characters max).
  *
  * Note that a newline character ("\n") will be appended automatically to your
- * log message, if not already there. It is not possible to send several messages
- * and have them appear on a single line in logcat.
+ * log message, if not already there. It is not possible to send several
+ * messages and have them appear on a single line in logcat.
  *
  * PLEASE USE LOGS WITH MODERATION:
  *
@@ -77,15 +77,15 @@
  * Android log priority values, in ascending priority order.
  */
 typedef enum android_LogPriority {
-    ANDROID_LOG_UNKNOWN = 0,
-    ANDROID_LOG_DEFAULT,    /* only for SetMinPriority() */
-    ANDROID_LOG_VERBOSE,
-    ANDROID_LOG_DEBUG,
-    ANDROID_LOG_INFO,
-    ANDROID_LOG_WARN,
-    ANDROID_LOG_ERROR,
-    ANDROID_LOG_FATAL,
-    ANDROID_LOG_SILENT,     /* only for SetMinPriority(); must be last */
+  ANDROID_LOG_UNKNOWN = 0,
+  ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */
+  ANDROID_LOG_VERBOSE,
+  ANDROID_LOG_DEBUG,
+  ANDROID_LOG_INFO,
+  ANDROID_LOG_WARN,
+  ANDROID_LOG_ERROR,
+  ANDROID_LOG_FATAL,
+  ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */
 } android_LogPriority;
 
 /*
@@ -96,16 +96,16 @@
 /*
  * Send a formatted string to the log, used like printf(fmt,...)
  */
-int __android_log_print(int prio, const char* tag,  const char* fmt, ...)
+int __android_log_print(int prio, const char* tag, const char* fmt, ...)
 #if defined(__GNUC__)
 #ifdef __USE_MINGW_ANSI_STDIO
 #if __USE_MINGW_ANSI_STDIO
-    __attribute__ ((__format__(gnu_printf, 3, 4)))
+    __attribute__((__format__(gnu_printf, 3, 4)))
 #else
-    __attribute__ ((__format__(printf, 3, 4)))
+    __attribute__((__format__(printf, 3, 4)))
 #endif
 #else
-    __attribute__ ((__format__(printf, 3, 4)))
+    __attribute__((__format__(printf, 3, 4)))
 #endif
 #endif
     ;
@@ -114,17 +114,16 @@
  * A variant of __android_log_print() that takes a va_list to list
  * additional parameters.
  */
-int __android_log_vprint(int prio, const char* tag,
-                         const char* fmt, va_list ap)
+int __android_log_vprint(int prio, const char* tag, const char* fmt, va_list ap)
 #if defined(__GNUC__)
 #ifdef __USE_MINGW_ANSI_STDIO
 #if __USE_MINGW_ANSI_STDIO
-    __attribute__ ((__format__(gnu_printf, 3, 0)))
+    __attribute__((__format__(gnu_printf, 3, 0)))
 #else
-    __attribute__ ((__format__(printf, 3, 0)))
+    __attribute__((__format__(printf, 3, 0)))
 #endif
 #else
-    __attribute__ ((__format__(printf, 3, 0)))
+    __attribute__((__format__(printf, 3, 0)))
 #endif
 #endif
     ;
@@ -133,18 +132,18 @@
  * Log an assertion failure and abort the process to have a chance
  * to inspect it if a debugger is attached. This uses the FATAL priority.
  */
-void __android_log_assert(const char* cond, const char* tag,
-                          const char* fmt, ...)
+void __android_log_assert(const char* cond, const char* tag, const char* fmt,
+                          ...)
 #if defined(__GNUC__)
-    __attribute__ ((__noreturn__))
+    __attribute__((__noreturn__))
 #ifdef __USE_MINGW_ANSI_STDIO
 #if __USE_MINGW_ANSI_STDIO
-    __attribute__ ((__format__(gnu_printf, 3, 4)))
+    __attribute__((__format__(gnu_printf, 3, 4)))
 #else
-    __attribute__ ((__format__(printf, 3, 4)))
+    __attribute__((__format__(printf, 3, 4)))
 #endif
 #else
-    __attribute__ ((__format__(printf, 3, 4)))
+    __attribute__((__format__(printf, 3, 4)))
 #endif
 #endif
     ;
diff --git a/liblog/include/log/event_tag_map.h b/liblog/include/log/event_tag_map.h
index e57e47b..8dd9157 100644
--- a/liblog/include/log/event_tag_map.h
+++ b/liblog/include/log/event_tag_map.h
@@ -21,7 +21,7 @@
 extern "C" {
 #endif
 
-#define EVENT_TAG_MAP_FILE  "/system/etc/event-log-tags"
+#define EVENT_TAG_MAP_FILE "/system/etc/event-log-tags"
 
 struct EventTagMap;
 typedef struct EventTagMap EventTagMap;
@@ -42,21 +42,23 @@
  * Look up a tag by index.  Returns the tag string, or NULL if not found.
  */
 const char* android_lookupEventTag(const EventTagMap* map, unsigned int tag)
-    __attribute__((deprecated("use android_lookupEventTag_len() instead to minimize MAP_PRIVATE copy-on-write memory impact")));
+    __attribute__((
+        deprecated("use android_lookupEventTag_len() instead to minimize "
+                   "MAP_PRIVATE copy-on-write memory impact")));
 
 /*
  * Look up a tag by index.  Returns the tag string & string length, or NULL if
  * not found.  Returned string is not guaranteed to be nul terminated.
  */
-const char* android_lookupEventTag_len(const EventTagMap* map,
-                                       size_t* len, unsigned int tag);
+const char* android_lookupEventTag_len(const EventTagMap* map, size_t* len,
+                                       unsigned int tag);
 
 /*
  * Look up a format by index. Returns the format string & string length,
  * or NULL if not found. Returned string is not guaranteed to be nul terminated.
  */
-const char* android_lookupEventFormat_len(const EventTagMap* map,
-                                          size_t* len, unsigned int tag);
+const char* android_lookupEventFormat_len(const EventTagMap* map, size_t* len,
+                                          unsigned int tag);
 
 /*
  * Look up tagname, generate one if necessary, and return a tag
diff --git a/liblog/include/log/log.h b/liblog/include/log/log.h
index db22211..6758c84 100644
--- a/liblog/include/log/log.h
+++ b/liblog/include/log/log.h
@@ -21,7 +21,7 @@
 #if !defined(_WIN32)
 #include <pthread.h>
 #endif
-#include <stdint.h>  /* uint16_t, int32_t */
+#include <stdint.h> /* uint16_t, int32_t */
 #include <stdio.h>
 #include <sys/types.h>
 #include <time.h>
@@ -95,9 +95,9 @@
 int __android_log_bswrite(int32_t tag, const char* payload);
 
 #define android_bWriteLog(tag, payload, len) \
-    __android_log_bwrite(tag, payload, len)
+  __android_log_bwrite(tag, payload, len)
 #define android_btWriteLog(tag, type, payload, len) \
-    __android_log_btwrite(tag, type, payload, len)
+  __android_log_btwrite(tag, type, payload, len)
 
 /*
  * Event log entry types.
@@ -105,45 +105,46 @@
 #ifndef __AndroidEventLogType_defined
 #define __AndroidEventLogType_defined
 typedef enum {
-    /* Special markers for android_log_list_element type */
-    EVENT_TYPE_LIST_STOP = '\n', /* declare end of list  */
-    EVENT_TYPE_UNKNOWN   = '?',  /* protocol error       */
+  /* Special markers for android_log_list_element type */
+  EVENT_TYPE_LIST_STOP = '\n', /* declare end of list  */
+  EVENT_TYPE_UNKNOWN = '?',    /* protocol error       */
 
-    /* must match with declaration in java/android/android/util/EventLog.java */
-    EVENT_TYPE_INT       = 0,    /* int32_t */
-    EVENT_TYPE_LONG      = 1,    /* int64_t */
-    EVENT_TYPE_STRING    = 2,
-    EVENT_TYPE_LIST      = 3,
-    EVENT_TYPE_FLOAT     = 4,
+  /* must match with declaration in java/android/android/util/EventLog.java */
+  EVENT_TYPE_INT = 0,  /* int32_t */
+  EVENT_TYPE_LONG = 1, /* int64_t */
+  EVENT_TYPE_STRING = 2,
+  EVENT_TYPE_LIST = 3,
+  EVENT_TYPE_FLOAT = 4,
 } AndroidEventLogType;
 #endif
 #define sizeof_AndroidEventLogType sizeof(typeof_AndroidEventLogType)
 #define typeof_AndroidEventLogType unsigned char
 
 #ifndef LOG_EVENT_INT
-#define LOG_EVENT_INT(_tag, _value) {                                       \
-        int intBuf = _value;                                                \
-        (void) android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf,            \
-            sizeof(intBuf));                                                \
-    }
+#define LOG_EVENT_INT(_tag, _value)                                          \
+  {                                                                          \
+    int intBuf = _value;                                                     \
+    (void)android_btWriteLog(_tag, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)); \
+  }
 #endif
 #ifndef LOG_EVENT_LONG
-#define LOG_EVENT_LONG(_tag, _value) {                                      \
-        long long longBuf = _value;                                         \
-        (void) android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf,          \
-            sizeof(longBuf));                                               \
-    }
+#define LOG_EVENT_LONG(_tag, _value)                                            \
+  {                                                                             \
+    long long longBuf = _value;                                                 \
+    (void)android_btWriteLog(_tag, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)); \
+  }
 #endif
 #ifndef LOG_EVENT_FLOAT
-#define LOG_EVENT_FLOAT(_tag, _value) {                                     \
-        float floatBuf = _value;                                            \
-        (void) android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf,        \
-            sizeof(floatBuf));                                              \
-    }
+#define LOG_EVENT_FLOAT(_tag, _value)                           \
+  {                                                             \
+    float floatBuf = _value;                                    \
+    (void)android_btWriteLog(_tag, EVENT_TYPE_FLOAT, &floatBuf, \
+                             sizeof(floatBuf));                 \
+  }
 #endif
 #ifndef LOG_EVENT_STRING
-#define LOG_EVENT_STRING(_tag, _value)                                      \
-        (void) __android_log_bswrite(_tag, _value);
+#define LOG_EVENT_STRING(_tag, _value) \
+  (void)__android_log_bswrite(_tag, _value);
 #endif
 
 #ifdef __linux__
@@ -179,10 +180,10 @@
 #if __ANDROID_USE_LIBLOG_SAFETYNET_INTERFACE
 
 #define android_errorWriteLog(tag, subTag) \
-    __android_log_error_write(tag, subTag, -1, NULL, 0)
+  __android_log_error_write(tag, subTag, -1, NULL, 0)
 
 #define android_errorWriteWithInfoLog(tag, subTag, uid, data, dataLen) \
-    __android_log_error_write(tag, subTag, uid, data, dataLen)
+  __android_log_error_write(tag, subTag, uid, data, dataLen)
 
 int __android_log_error_write(int tag, const char* subTag, int32_t uid,
                               const char* data, uint32_t dataLen);
@@ -246,10 +247,9 @@
  *   }
  */
 
-#define IF_ALOG_RATELIMIT() \
-      if (__android_log_ratelimit(0, NULL) > 0)
+#define IF_ALOG_RATELIMIT() if (__android_log_ratelimit(0, NULL) > 0)
 #define IF_ALOG_RATELIMIT_LOCAL(seconds, state) \
-      if (__android_log_ratelimit(seconds, state) > 0)
+  if (__android_log_ratelimit(seconds, state) > 0)
 
 #else
 
diff --git a/liblog/include/log/log_event_list.h b/liblog/include/log/log_event_list.h
index 31d49b2..55953fc 100644
--- a/liblog/include/log/log_event_list.h
+++ b/liblog/include/log/log_event_list.h
@@ -61,15 +61,15 @@
 #ifndef __android_log_list_element_defined
 #define __android_log_list_element_defined
 typedef struct {
-    AndroidEventLogType type;
-    uint16_t complete;
-    uint16_t len;
-    union {
-        int32_t int32;
-        int64_t int64;
-        char* string;
-        float float32;
-    } data;
+  AndroidEventLogType type;
+  uint16_t complete;
+  uint16_t len;
+  union {
+    int32_t int32;
+    int64_t int64;
+    char* string;
+    float float32;
+  } data;
 } android_log_list_element;
 #endif
 
@@ -91,8 +91,8 @@
 int android_log_write_int32(android_log_context ctx, int32_t value);
 int android_log_write_int64(android_log_context ctx, int64_t value);
 int android_log_write_string8(android_log_context ctx, const char* value);
-int android_log_write_string8_len(android_log_context ctx,
-                                  const char* value, size_t maxlen);
+int android_log_write_string8_len(android_log_context ctx, const char* value,
+                                  size_t maxlen);
 int android_log_write_float32(android_log_context ctx, float value);
 
 /* Submit the composed list context to the specified logger id */
@@ -116,173 +116,182 @@
 /* android_log_list C++ helpers */
 extern "C++" {
 class android_log_event_list {
-friend class __android_log_event_list;
+  friend class __android_log_event_list;
 
-private:
-    android_log_context ctx;
-    int ret;
+ private:
+  android_log_context ctx;
+  int ret;
 
-    android_log_event_list(const android_log_event_list&) = delete;
-    void operator =(const android_log_event_list&) = delete;
+  android_log_event_list(const android_log_event_list&) = delete;
+  void operator=(const android_log_event_list&) = delete;
 
-public:
-    explicit android_log_event_list(int tag) : ret(0) {
-        ctx = create_android_logger(static_cast<uint32_t>(tag));
-    }
-    explicit android_log_event_list(log_msg& log_msg) : ret(0) {
-        ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
-                                        log_msg.entry.len - sizeof(uint32_t));
-    }
-    ~android_log_event_list() { android_log_destroy(&ctx); }
+ public:
+  explicit android_log_event_list(int tag) : ret(0) {
+    ctx = create_android_logger(static_cast<uint32_t>(tag));
+  }
+  explicit android_log_event_list(log_msg& log_msg) : ret(0) {
+    ctx = create_android_log_parser(log_msg.msg() + sizeof(uint32_t),
+                                    log_msg.entry.len - sizeof(uint32_t));
+  }
+  ~android_log_event_list() {
+    android_log_destroy(&ctx);
+  }
 
-    int close() {
-        int retval = android_log_destroy(&ctx);
-        if (retval < 0) ret = retval;
-        return retval;
-    }
+  int close() {
+    int retval = android_log_destroy(&ctx);
+    if (retval < 0) ret = retval;
+    return retval;
+  }
 
-    /* To allow above C calls to use this class as parameter */
-    operator android_log_context() const { return ctx; }
+  /* To allow above C calls to use this class as parameter */
+  operator android_log_context() const {
+    return ctx;
+  }
 
-    int status() const { return ret; }
+  int status() const {
+    return ret;
+  }
 
-    int begin() {
-        int retval = android_log_write_list_begin(ctx);
-        if (retval < 0) ret = retval;
-        return ret;
-    }
-    int end() {
-        int retval = android_log_write_list_end(ctx);
-        if (retval < 0) ret = retval;
-        return ret;
-    }
+  int begin() {
+    int retval = android_log_write_list_begin(ctx);
+    if (retval < 0) ret = retval;
+    return ret;
+  }
+  int end() {
+    int retval = android_log_write_list_end(ctx);
+    if (retval < 0) ret = retval;
+    return ret;
+  }
 
-    android_log_event_list& operator <<(int32_t value) {
-        int retval = android_log_write_int32(ctx, value);
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(int32_t value) {
+    int retval = android_log_write_int32(ctx, value);
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
-    android_log_event_list& operator <<(uint32_t value) {
-        int retval = android_log_write_int32(ctx, static_cast<int32_t>(value));
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(uint32_t value) {
+    int retval = android_log_write_int32(ctx, static_cast<int32_t>(value));
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
-    android_log_event_list& operator <<(int64_t value) {
-        int retval = android_log_write_int64(ctx, value);
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(int64_t value) {
+    int retval = android_log_write_int64(ctx, value);
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
-    android_log_event_list& operator <<(uint64_t value) {
-        int retval = android_log_write_int64(ctx, static_cast<int64_t>(value));
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(uint64_t value) {
+    int retval = android_log_write_int64(ctx, static_cast<int64_t>(value));
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
-    android_log_event_list& operator <<(const char* value) {
-        int retval = android_log_write_string8(ctx, value);
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(const char* value) {
+    int retval = android_log_write_string8(ctx, value);
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
 #if defined(_USING_LIBCXX)
-    android_log_event_list& operator <<(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx,
-                                                   value.data(),
-                                                   value.length());
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(const std::string& value) {
+    int retval =
+        android_log_write_string8_len(ctx, value.data(), value.length());
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 #endif
 
-    android_log_event_list& operator <<(float value) {
-        int retval = android_log_write_float32(ctx, value);
-        if (retval < 0) ret = retval;
-        return *this;
-    }
+  android_log_event_list& operator<<(float value) {
+    int retval = android_log_write_float32(ctx, value);
+    if (retval < 0) ret = retval;
+    return *this;
+  }
 
-    int write(log_id_t id = LOG_ID_EVENTS) {
-        int retval = android_log_write_list(ctx, id);
-        if (retval < 0) ret = retval;
-        return ret;
-    }
+  int write(log_id_t id = LOG_ID_EVENTS) {
+    int retval = android_log_write_list(ctx, id);
+    if (retval < 0) ret = retval;
+    return ret;
+  }
 
-    int operator <<(log_id_t id) {
-        int retval = android_log_write_list(ctx, id);
-        if (retval < 0) ret = retval;
-        android_log_destroy(&ctx);
-        return ret;
-    }
+  int operator<<(log_id_t id) {
+    int retval = android_log_write_list(ctx, id);
+    if (retval < 0) ret = retval;
+    android_log_destroy(&ctx);
+    return ret;
+  }
 
-    /*
-     * Append<Type> methods removes any integer promotion
-     * confusion, and adds access to string with length.
-     * Append methods are also added for all types for
-     * convenience.
-     */
+  /*
+   * Append<Type> methods removes any integer promotion
+   * confusion, and adds access to string with length.
+   * Append methods are also added for all types for
+   * convenience.
+   */
 
-    bool AppendInt(int32_t value) {
-        int retval = android_log_write_int32(ctx, value);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool AppendInt(int32_t value) {
+    int retval = android_log_write_int32(ctx, value);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
-    bool AppendLong(int64_t value) {
-        int retval = android_log_write_int64(ctx, value);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool AppendLong(int64_t value) {
+    int retval = android_log_write_int64(ctx, value);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
-    bool AppendString(const char* value) {
-        int retval = android_log_write_string8(ctx, value);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool AppendString(const char* value) {
+    int retval = android_log_write_string8(ctx, value);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
-    bool AppendString(const char* value, size_t len) {
-        int retval = android_log_write_string8_len(ctx, value, len);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool AppendString(const char* value, size_t len) {
+    int retval = android_log_write_string8_len(ctx, value, len);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
 #if defined(_USING_LIBCXX)
-    bool AppendString(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx,
-                                                   value.data(),
-                                                   value.length());
-        if (retval < 0) ret = retval;
-        return ret;
-    }
+  bool AppendString(const std::string& value) {
+    int retval =
+        android_log_write_string8_len(ctx, value.data(), value.length());
+    if (retval < 0) ret = retval;
+    return ret;
+  }
 
-    bool Append(const std::string& value) {
-        int retval = android_log_write_string8_len(ctx,
-                                                   value.data(),
-                                                   value.length());
-        if (retval < 0) ret = retval;
-        return ret;
-    }
+  bool Append(const std::string& value) {
+    int retval =
+        android_log_write_string8_len(ctx, value.data(), value.length());
+    if (retval < 0) ret = retval;
+    return ret;
+  }
 #endif
 
-    bool AppendFloat(float value) {
-        int retval = android_log_write_float32(ctx, value);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool AppendFloat(float value) {
+    int retval = android_log_write_float32(ctx, value);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
-    template <typename Tvalue>
-    bool Append(Tvalue value) { *this << value; return ret >= 0; }
+  template <typename Tvalue>
+  bool Append(Tvalue value) {
+    *this << value;
+    return ret >= 0;
+  }
 
-    bool Append(const char* value, size_t len) {
-        int retval = android_log_write_string8_len(ctx, value, len);
-        if (retval < 0) ret = retval;
-        return ret >= 0;
-    }
+  bool Append(const char* value, size_t len) {
+    int retval = android_log_write_string8_len(ctx, value, len);
+    if (retval < 0) ret = retval;
+    return ret >= 0;
+  }
 
-    android_log_list_element read() { return android_log_read_next(ctx); }
-    android_log_list_element peek() { return android_log_peek_next(ctx); }
-
+  android_log_list_element read() {
+    return android_log_read_next(ctx);
+  }
+  android_log_list_element peek() {
+    return android_log_peek_next(ctx);
+  }
 };
 }
 #endif
diff --git a/liblog/include/log/log_frontend.h b/liblog/include/log/log_frontend.h
deleted file mode 100644
index 9527779..0000000
--- a/liblog/include/log/log_frontend.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-**
-** Copyright 2017, The Android Open Source Project
-**
-** This file is dual licensed.  It may be redistributed and/or modified
-** under the terms of the Apache 2.0 License OR version 2 of the GNU
-** General Public License.
-*/
-
-#ifndef _LIBS_LOG_FRONTEND_H
-#define _LIBS_LOG_FRONTEND_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Logging frontends, bit mask to select features. Function returns selection.
- */
-#define LOGGER_DEFAULT 0x0
-#define LOGGER_LOGD    0x1
-#define LOGGER_KERNEL  0x2 /* Reserved/Deprecated */
-#define LOGGER_NULL    0x4 /* Does not release resources of other selections */
-#define LOGGER_LOCAL   0x8 /* logs sent to local memory */
-
-/* Both return the selected frontend flag mask, or negative errno */
-int android_set_log_frontend(int frontend_flag);
-int android_get_log_frontend();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBS_LOG_FRONTEND_H */
diff --git a/liblog/include/log/log_id.h b/liblog/include/log/log_id.h
index 3078e4e..7bfa277 100644
--- a/liblog/include/log/log_id.h
+++ b/liblog/include/log/log_id.h
@@ -24,17 +24,17 @@
 #ifndef log_id_t_defined
 #define log_id_t_defined
 typedef enum log_id {
-    LOG_ID_MIN = 0,
+  LOG_ID_MIN = 0,
 
-    LOG_ID_MAIN = 0,
-    LOG_ID_RADIO = 1,
-    LOG_ID_EVENTS = 2,
-    LOG_ID_SYSTEM = 3,
-    LOG_ID_CRASH = 4,
-    LOG_ID_SECURITY = 5,
-    LOG_ID_KERNEL = 6, /* place last, third-parties can not use it */
+  LOG_ID_MAIN = 0,
+  LOG_ID_RADIO = 1,
+  LOG_ID_EVENTS = 2,
+  LOG_ID_SYSTEM = 3,
+  LOG_ID_CRASH = 4,
+  LOG_ID_SECURITY = 5,
+  LOG_ID_KERNEL = 6, /* place last, third-parties can not use it */
 
-    LOG_ID_MAX
+  LOG_ID_MAX
 } log_id_t;
 #endif
 #define sizeof_log_id_t sizeof(typeof_log_id_t)
@@ -43,8 +43,10 @@
 /*
  * Send a simple string to the log.
  */
-int __android_log_buf_write(int bufID, int prio, const char* tag, const char* text);
-int __android_log_buf_print(int bufID, int prio, const char* tag, const char* fmt, ...)
+int __android_log_buf_write(int bufID, int prio, const char* tag,
+                            const char* text);
+int __android_log_buf_print(int bufID, int prio, const char* tag,
+                            const char* fmt, ...)
 #if defined(__GNUC__)
     __attribute__((__format__(printf, 4, 5)))
 #endif
diff --git a/liblog/include/log/log_main.h b/liblog/include/log/log_main.h
index f45397a..da16158 100644
--- a/liblog/include/log/log_main.h
+++ b/liblog/include/log/log_main.h
@@ -56,21 +56,19 @@
 #define __predict_false(exp) __builtin_expect((exp) != 0, 0)
 #endif
 
-#define android_writeLog(prio, tag, text) \
-    __android_log_write(prio, tag, text)
+#define android_writeLog(prio, tag, text) __android_log_write(prio, tag, text)
 
 #define android_printLog(prio, tag, ...) \
-    __android_log_print(prio, tag, __VA_ARGS__)
+  __android_log_print(prio, tag, __VA_ARGS__)
 
 #define android_vprintLog(prio, cond, tag, ...) \
-    __android_log_vprint(prio, tag, __VA_ARGS__)
+  __android_log_vprint(prio, tag, __VA_ARGS__)
 
 /*
  * Log macro that allows you to specify a number for the priority.
  */
 #ifndef LOG_PRI
-#define LOG_PRI(priority, tag, ...) \
-    android_printLog(priority, tag, __VA_ARGS__)
+#define LOG_PRI(priority, tag, ...) android_printLog(priority, tag, __VA_ARGS__)
 #endif
 
 /*
@@ -78,7 +76,7 @@
  */
 #ifndef LOG_PRI_VA
 #define LOG_PRI_VA(priority, tag, fmt, args) \
-    android_vprintLog(priority, NULL, tag, fmt, args)
+  android_vprintLog(priority, NULL, tag, fmt, args)
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -91,16 +89,17 @@
 /* Returns 2nd arg.  Used to substitute default value if caller's vararg list
  * is empty.
  */
-#define __android_second(dummy, second, ...)     second
+#define __android_second(dummy, second, ...) second
 
 /* If passed multiple args, returns ',' followed by all but 1st arg, otherwise
  * returns nothing.
  */
-#define __android_rest(first, ...)               , ## __VA_ARGS__
+#define __android_rest(first, ...) , ##__VA_ARGS__
 
-#define android_printAssert(cond, tag, ...) \
-    __android_log_assert(cond, tag, \
-        __android_second(0, ## __VA_ARGS__, NULL) __android_rest(__VA_ARGS__))
+#define android_printAssert(cond, tag, ...)                     \
+  __android_log_assert(cond, tag,                               \
+                       __android_second(0, ##__VA_ARGS__, NULL) \
+                           __android_rest(__VA_ARGS__))
 
 /*
  * Log a fatal error.  If the given condition fails, this stops program
@@ -109,15 +108,15 @@
  * is -inverted- from the normal assert() semantics.
  */
 #ifndef LOG_ALWAYS_FATAL_IF
-#define LOG_ALWAYS_FATAL_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
-    : (void)0 )
+#define LOG_ALWAYS_FATAL_IF(cond, ...)                              \
+  ((__predict_false(cond))                                          \
+       ? ((void)android_printAssert(#cond, LOG_TAG, ##__VA_ARGS__)) \
+       : (void)0)
 #endif
 
 #ifndef LOG_ALWAYS_FATAL
 #define LOG_ALWAYS_FATAL(...) \
-    ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
+  (((void)android_printAssert(NULL, LOG_TAG, ##__VA_ARGS__)))
 #endif
 
 /*
@@ -137,7 +136,7 @@
 #else
 
 #ifndef LOG_FATAL_IF
-#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ## __VA_ARGS__)
+#define LOG_FATAL_IF(cond, ...) LOG_ALWAYS_FATAL_IF(cond, ##__VA_ARGS__)
 #endif
 #ifndef LOG_FATAL
 #define LOG_FATAL(...) LOG_ALWAYS_FATAL(__VA_ARGS__)
@@ -150,7 +149,7 @@
  * Stripped out of release builds.  Uses the current LOG_TAG.
  */
 #ifndef ALOG_ASSERT
-#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ## __VA_ARGS__)
+#define ALOG_ASSERT(cond, ...) LOG_FATAL_IF(!(cond), ##__VA_ARGS__)
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -175,7 +174,12 @@
 #ifndef ALOGV
 #define __ALOGV(...) ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
 #if LOG_NDEBUG
-#define ALOGV(...) do { if (0) { __ALOGV(__VA_ARGS__); } } while (0)
+#define ALOGV(...)          \
+  do {                      \
+    if (0) {                \
+      __ALOGV(__VA_ARGS__); \
+    }                       \
+  } while (0)
 #else
 #define ALOGV(...) __ALOGV(__VA_ARGS__)
 #endif
@@ -183,12 +187,11 @@
 
 #ifndef ALOGV_IF
 #if LOG_NDEBUG
-#define ALOGV_IF(cond, ...)   ((void)0)
+#define ALOGV_IF(cond, ...) ((void)0)
 #else
-#define ALOGV_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define ALOGV_IF(cond, ...)                                                  \
+  ((__predict_false(cond)) ? ((void)ALOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
+                           : (void)0)
 #endif
 #endif
 
@@ -200,10 +203,9 @@
 #endif
 
 #ifndef ALOGD_IF
-#define ALOGD_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define ALOGD_IF(cond, ...)                                                \
+  ((__predict_false(cond)) ? ((void)ALOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
+                           : (void)0)
 #endif
 
 /*
@@ -214,10 +216,9 @@
 #endif
 
 #ifndef ALOGI_IF
-#define ALOGI_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define ALOGI_IF(cond, ...)                                               \
+  ((__predict_false(cond)) ? ((void)ALOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) \
+                           : (void)0)
 #endif
 
 /*
@@ -228,10 +229,9 @@
 #endif
 
 #ifndef ALOGW_IF
-#define ALOGW_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define ALOGW_IF(cond, ...)                                               \
+  ((__predict_false(cond)) ? ((void)ALOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) \
+                           : (void)0)
 #endif
 
 /*
@@ -242,10 +242,9 @@
 #endif
 
 #ifndef ALOGE_IF
-#define ALOGE_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define ALOGE_IF(cond, ...)                                                \
+  ((__predict_false(cond)) ? ((void)ALOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
+                           : (void)0)
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -305,16 +304,14 @@
  * The second argument may be NULL or "" to indicate the "global" tag.
  */
 #ifndef ALOG
-#define ALOG(priority, tag, ...) \
-    LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
+#define ALOG(priority, tag, ...) LOG_PRI(ANDROID_##priority, tag, __VA_ARGS__)
 #endif
 
 /*
  * Conditional given a desired logging priority and tag.
  */
 #ifndef IF_ALOG
-#define IF_ALOG(priority, tag) \
-    if (android_testLog(ANDROID_##priority, tag))
+#define IF_ALOG(priority, tag) if (android_testLog(ANDROID_##priority, tag))
 #endif
 
 /* --------------------------------------------------------------------- */
@@ -357,23 +354,23 @@
                                   int default_prio);
 
 #if LOG_NDEBUG /* Production */
-#define android_testLog(prio, tag) \
-    (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \
-                                   ANDROID_LOG_DEBUG) != 0)
+#define android_testLog(prio, tag)                                           \
+  (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \
+                                 ANDROID_LOG_DEBUG) != 0)
 #else
-#define android_testLog(prio, tag) \
-    (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \
-                                   ANDROID_LOG_VERBOSE) != 0)
+#define android_testLog(prio, tag)                                           \
+  (__android_log_is_loggable_len(prio, tag, (tag && *tag) ? strlen(tag) : 0, \
+                                 ANDROID_LOG_VERBOSE) != 0)
 #endif
 
 #else
 
 #if LOG_NDEBUG /* Production */
 #define android_testLog(prio, tag) \
-    (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0)
+  (__android_log_is_loggable(prio, tag, ANDROID_LOG_DEBUG) != 0)
 #else
 #define android_testLog(prio, tag) \
-    (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0)
+  (__android_log_is_loggable(prio, tag, ANDROID_LOG_VERBOSE) != 0)
 #endif
 
 #endif
diff --git a/liblog/include/log/log_radio.h b/liblog/include/log/log_radio.h
index 430e522..bd629fe 100644
--- a/liblog/include/log/log_radio.h
+++ b/liblog/include/log/log_radio.h
@@ -46,10 +46,16 @@
  * Simplified macro to send a verbose radio log message using current LOG_TAG.
  */
 #ifndef RLOGV
-#define __RLOGV(...) \
-    ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __RLOGV(...)                                                         \
+  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, \
+                                 __VA_ARGS__))
 #if LOG_NDEBUG
-#define RLOGV(...) do { if (0) { __RLOGV(__VA_ARGS__); } } while (0)
+#define RLOGV(...)          \
+  do {                      \
+    if (0) {                \
+      __RLOGV(__VA_ARGS__); \
+    }                       \
+  } while (0)
 #else
 #define RLOGV(...) __RLOGV(__VA_ARGS__)
 #endif
@@ -57,12 +63,13 @@
 
 #ifndef RLOGV_IF
 #if LOG_NDEBUG
-#define RLOGV_IF(cond, ...)   ((void)0)
+#define RLOGV_IF(cond, ...) ((void)0)
 #else
-#define RLOGV_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define RLOGV_IF(cond, ...)                                                \
+  ((__predict_false(cond))                                                 \
+       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_VERBOSE, \
+                                        LOG_TAG, __VA_ARGS__))             \
+       : (void)0)
 #endif
 #endif
 
@@ -70,60 +77,68 @@
  * Simplified macro to send a debug radio log message using  current LOG_TAG.
  */
 #ifndef RLOGD
-#define RLOGD(...) \
-    ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define RLOGD(...)                                                         \
+  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef RLOGD_IF
-#define RLOGD_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define RLOGD_IF(cond, ...)                                              \
+  ((__predict_false(cond))                                               \
+       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_DEBUG, \
+                                        LOG_TAG, __VA_ARGS__))           \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send an info radio log message using  current LOG_TAG.
  */
 #ifndef RLOGI
-#define RLOGI(...) \
-    ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define RLOGI(...)                                                        \
+  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef RLOGI_IF
-#define RLOGI_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define RLOGI_IF(cond, ...)                                             \
+  ((__predict_false(cond))                                              \
+       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO, \
+                                        LOG_TAG, __VA_ARGS__))          \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send a warning radio log message using current LOG_TAG.
  */
 #ifndef RLOGW
-#define RLOGW(...) \
-    ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define RLOGW(...)                                                        \
+  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef RLOGW_IF
-#define RLOGW_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define RLOGW_IF(cond, ...)                                             \
+  ((__predict_false(cond))                                              \
+       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_WARN, \
+                                        LOG_TAG, __VA_ARGS__))          \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send an error radio log message using current LOG_TAG.
  */
 #ifndef RLOGE
-#define RLOGE(...) \
-    ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define RLOGE(...)                                                         \
+  ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef RLOGE_IF
-#define RLOGE_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define RLOGE_IF(cond, ...)                                              \
+  ((__predict_false(cond))                                               \
+       ? ((void)__android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_ERROR, \
+                                        LOG_TAG, __VA_ARGS__))           \
+       : (void)0)
 #endif
 
 #endif /* _LIBS_LOG_LOG_RADIO_H */
diff --git a/liblog/include/log/log_read.h b/liblog/include/log/log_read.h
index 6a44b56..d118563 100644
--- a/liblog/include/log/log_read.h
+++ b/liblog/include/log/log_read.h
@@ -53,14 +53,14 @@
 #ifndef __struct_logger_entry_defined
 #define __struct_logger_entry_defined
 struct logger_entry {
-    uint16_t    len;    /* length of the payload */
-    uint16_t    __pad;  /* no matter what, we get 2 bytes of padding */
-    int32_t     pid;    /* generating process's pid */
-    int32_t     tid;    /* generating process's tid */
-    int32_t     sec;    /* seconds since Epoch */
-    int32_t     nsec;   /* nanoseconds */
+  uint16_t len;   /* length of the payload */
+  uint16_t __pad; /* no matter what, we get 2 bytes of padding */
+  int32_t pid;    /* generating process's pid */
+  int32_t tid;    /* generating process's tid */
+  int32_t sec;    /* seconds since Epoch */
+  int32_t nsec;   /* nanoseconds */
 #ifndef __cplusplus
-    char        msg[0]; /* the entry's payload */
+  char msg[0]; /* the entry's payload */
 #endif
 };
 #endif
@@ -71,15 +71,15 @@
 #ifndef __struct_logger_entry_v2_defined
 #define __struct_logger_entry_v2_defined
 struct logger_entry_v2 {
-    uint16_t    len;       /* length of the payload */
-    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v2) */
-    int32_t     pid;       /* generating process's pid */
-    int32_t     tid;       /* generating process's tid */
-    int32_t     sec;       /* seconds since Epoch */
-    int32_t     nsec;      /* nanoseconds */
-    uint32_t    euid;      /* effective UID of logger */
+  uint16_t len;      /* length of the payload */
+  uint16_t hdr_size; /* sizeof(struct logger_entry_v2) */
+  int32_t pid;       /* generating process's pid */
+  int32_t tid;       /* generating process's tid */
+  int32_t sec;       /* seconds since Epoch */
+  int32_t nsec;      /* nanoseconds */
+  uint32_t euid;     /* effective UID of logger */
 #ifndef __cplusplus
-    char        msg[0];    /* the entry's payload */
+  char msg[0]; /* the entry's payload */
 #endif
 } __attribute__((__packed__));
 #endif
@@ -90,15 +90,15 @@
 #ifndef __struct_logger_entry_v3_defined
 #define __struct_logger_entry_v3_defined
 struct logger_entry_v3 {
-    uint16_t    len;       /* length of the payload */
-    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v3) */
-    int32_t     pid;       /* generating process's pid */
-    int32_t     tid;       /* generating process's tid */
-    int32_t     sec;       /* seconds since Epoch */
-    int32_t     nsec;      /* nanoseconds */
-    uint32_t    lid;       /* log id of the payload */
+  uint16_t len;      /* length of the payload */
+  uint16_t hdr_size; /* sizeof(struct logger_entry_v3) */
+  int32_t pid;       /* generating process's pid */
+  int32_t tid;       /* generating process's tid */
+  int32_t sec;       /* seconds since Epoch */
+  int32_t nsec;      /* nanoseconds */
+  uint32_t lid;      /* log id of the payload */
 #ifndef __cplusplus
-    char        msg[0];    /* the entry's payload */
+  char msg[0]; /* the entry's payload */
 #endif
 } __attribute__((__packed__));
 #endif
@@ -109,16 +109,16 @@
 #ifndef __struct_logger_entry_v4_defined
 #define __struct_logger_entry_v4_defined
 struct logger_entry_v4 {
-    uint16_t    len;       /* length of the payload */
-    uint16_t    hdr_size;  /* sizeof(struct logger_entry_v4) */
-    int32_t     pid;       /* generating process's pid */
-    uint32_t    tid;       /* generating process's tid */
-    uint32_t    sec;       /* seconds since Epoch */
-    uint32_t    nsec;      /* nanoseconds */
-    uint32_t    lid;       /* log id of the payload, bottom 4 bits currently */
-    uint32_t    uid;       /* generating process's uid */
+  uint16_t len;      /* length of the payload */
+  uint16_t hdr_size; /* sizeof(struct logger_entry_v4) */
+  int32_t pid;       /* generating process's pid */
+  uint32_t tid;      /* generating process's tid */
+  uint32_t sec;      /* seconds since Epoch */
+  uint32_t nsec;     /* nanoseconds */
+  uint32_t lid;      /* log id of the payload, bottom 4 bits currently */
+  uint32_t uid;      /* generating process's uid */
 #ifndef __cplusplus
-    char        msg[0];    /* the entry's payload */
+  char msg[0]; /* the entry's payload */
 #endif
 };
 #endif
@@ -135,77 +135,64 @@
  * An attempt to read less than this amount may result
  * in read() returning EINVAL.
  */
-#define LOGGER_ENTRY_MAX_LEN    (5*1024)
+#define LOGGER_ENTRY_MAX_LEN (5 * 1024)
 
 #ifndef __struct_log_msg_defined
 #define __struct_log_msg_defined
 struct log_msg {
-    union {
-        unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
-        struct logger_entry_v4 entry;
-        struct logger_entry_v4 entry_v4;
-        struct logger_entry_v3 entry_v3;
-        struct logger_entry_v2 entry_v2;
-        struct logger_entry    entry_v1;
-    } __attribute__((aligned(4)));
+  union {
+    unsigned char buf[LOGGER_ENTRY_MAX_LEN + 1];
+    struct logger_entry_v4 entry;
+    struct logger_entry_v4 entry_v4;
+    struct logger_entry_v3 entry_v3;
+    struct logger_entry_v2 entry_v2;
+    struct logger_entry entry_v1;
+  } __attribute__((aligned(4)));
 #ifdef __cplusplus
-    /* Matching log_time operators */
-    bool operator== (const log_msg& T) const
-    {
-        return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec);
-    }
-    bool operator!= (const log_msg& T) const
-    {
-        return !(*this == T);
-    }
-    bool operator< (const log_msg& T) const
-    {
-        return (entry.sec < T.entry.sec)
-            || ((entry.sec == T.entry.sec)
-             && (entry.nsec < T.entry.nsec));
-    }
-    bool operator>= (const log_msg& T) const
-    {
-        return !(*this < T);
-    }
-    bool operator> (const log_msg& T) const
-    {
-        return (entry.sec > T.entry.sec)
-            || ((entry.sec == T.entry.sec)
-             && (entry.nsec > T.entry.nsec));
-    }
-    bool operator<= (const log_msg& T) const
-    {
-        return !(*this > T);
-    }
-    uint64_t nsec() const
-    {
-        return static_cast<uint64_t>(entry.sec) * NS_PER_SEC + entry.nsec;
-    }
+  /* Matching log_time operators */
+  bool operator==(const log_msg& T) const {
+    return (entry.sec == T.entry.sec) && (entry.nsec == T.entry.nsec);
+  }
+  bool operator!=(const log_msg& T) const {
+    return !(*this == T);
+  }
+  bool operator<(const log_msg& T) const {
+    return (entry.sec < T.entry.sec) ||
+           ((entry.sec == T.entry.sec) && (entry.nsec < T.entry.nsec));
+  }
+  bool operator>=(const log_msg& T) const {
+    return !(*this < T);
+  }
+  bool operator>(const log_msg& T) const {
+    return (entry.sec > T.entry.sec) ||
+           ((entry.sec == T.entry.sec) && (entry.nsec > T.entry.nsec));
+  }
+  bool operator<=(const log_msg& T) const {
+    return !(*this > T);
+  }
+  uint64_t nsec() const {
+    return static_cast<uint64_t>(entry.sec) * NS_PER_SEC + entry.nsec;
+  }
 
-    /* packet methods */
-    log_id_t id()
-    {
-        return static_cast<log_id_t>(entry.lid);
+  /* packet methods */
+  log_id_t id() {
+    return static_cast<log_id_t>(entry.lid);
+  }
+  char* msg() {
+    unsigned short hdr_size = entry.hdr_size;
+    if (!hdr_size) {
+      hdr_size = sizeof(entry_v1);
     }
-    char* msg()
-    {
-        unsigned short hdr_size = entry.hdr_size;
-        if (!hdr_size) {
-            hdr_size = sizeof(entry_v1);
-        }
-        if ((hdr_size < sizeof(entry_v1)) || (hdr_size > sizeof(entry))) {
-            return NULL;
-        }
-        return reinterpret_cast<char*>(buf) + hdr_size;
+    if ((hdr_size < sizeof(entry_v1)) || (hdr_size > sizeof(entry))) {
+      return NULL;
     }
-    unsigned int len()
-    {
-        return (entry.hdr_size ?
-                    entry.hdr_size :
-                    static_cast<uint16_t>(sizeof(entry_v1))) +
-               entry.len;
-    }
+    return reinterpret_cast<char*>(buf) + hdr_size;
+  }
+  unsigned int len() {
+    return (entry.hdr_size ? entry.hdr_size
+                           : static_cast<uint16_t>(sizeof(entry_v1))) +
+           entry.len;
+  }
 #endif
 };
 #endif
@@ -243,32 +230,30 @@
                                       char* buf, size_t len);
 ssize_t android_logger_get_prune_list(struct logger_list* logger_list,
                                       char* buf, size_t len);
-int android_logger_set_prune_list(struct logger_list* logger_list,
-                                  char* buf, size_t len);
+int android_logger_set_prune_list(struct logger_list* logger_list, char* buf,
+                                  size_t len);
 #endif
 
-#define ANDROID_LOG_RDONLY   O_RDONLY
-#define ANDROID_LOG_WRONLY   O_WRONLY
-#define ANDROID_LOG_RDWR     O_RDWR
-#define ANDROID_LOG_ACCMODE  O_ACCMODE
+#define ANDROID_LOG_RDONLY O_RDONLY
+#define ANDROID_LOG_WRONLY O_WRONLY
+#define ANDROID_LOG_RDWR O_RDWR
+#define ANDROID_LOG_ACCMODE O_ACCMODE
 #ifndef O_NONBLOCK
 #define ANDROID_LOG_NONBLOCK 0x00000800
 #else
 #define ANDROID_LOG_NONBLOCK O_NONBLOCK
 #endif
 #if __ANDROID_USE_LIBLOG_READER_INTERFACE > 2
-#define ANDROID_LOG_WRAP     0x40000000 /* Block until buffer about to wrap */
+#define ANDROID_LOG_WRAP 0x40000000 /* Block until buffer about to wrap */
 #define ANDROID_LOG_WRAP_DEFAULT_TIMEOUT 7200 /* 2 hour default */
 #endif
 #if __ANDROID_USE_LIBLOG_READER_INTERFACE > 1
-#define ANDROID_LOG_PSTORE   0x80000000
+#define ANDROID_LOG_PSTORE 0x80000000
 #endif
 
-struct logger_list* android_logger_list_alloc(int mode,
-                                              unsigned int tail,
+struct logger_list* android_logger_list_alloc(int mode, unsigned int tail,
                                               pid_t pid);
-struct logger_list* android_logger_list_alloc_time(int mode,
-                                                   log_time start,
+struct logger_list* android_logger_list_alloc_time(int mode, log_time start,
                                                    pid_t pid);
 void android_logger_list_free(struct logger_list* logger_list);
 /* In the purest sense, the following two are orthogonal interfaces */
@@ -276,14 +261,11 @@
                              struct log_msg* log_msg);
 
 /* Multiple log_id_t opens */
-struct logger* android_logger_open(struct logger_list* logger_list,
-                                   log_id_t id);
+struct logger* android_logger_open(struct logger_list* logger_list, log_id_t id);
 #define android_logger_close android_logger_free
 /* Single log_id_t open */
-struct logger_list* android_logger_list_open(log_id_t id,
-                                             int mode,
-                                             unsigned int tail,
-                                             pid_t pid);
+struct logger_list* android_logger_list_open(log_id_t id, int mode,
+                                             unsigned int tail, pid_t pid);
 #define android_logger_list_close android_logger_list_free
 
 #endif /* __ANDROID_USE_LIBLOG_READER_INTERFACE */
diff --git a/liblog/include/log/log_system.h b/liblog/include/log/log_system.h
index 394a106..3b5ae22 100644
--- a/liblog/include/log/log_system.h
+++ b/liblog/include/log/log_system.h
@@ -44,10 +44,16 @@
  * Simplified macro to send a verbose system log message using current LOG_TAG.
  */
 #ifndef SLOGV
-#define __SLOGV(...) \
-    ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__))
+#define __SLOGV(...)                                                          \
+  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, \
+                                 __VA_ARGS__))
 #if LOG_NDEBUG
-#define SLOGV(...) do { if (0) { __SLOGV(__VA_ARGS__); } } while (0)
+#define SLOGV(...)          \
+  do {                      \
+    if (0) {                \
+      __SLOGV(__VA_ARGS__); \
+    }                       \
+  } while (0)
 #else
 #define SLOGV(...) __SLOGV(__VA_ARGS__)
 #endif
@@ -55,12 +61,13 @@
 
 #ifndef SLOGV_IF
 #if LOG_NDEBUG
-#define SLOGV_IF(cond, ...)   ((void)0)
+#define SLOGV_IF(cond, ...) ((void)0)
 #else
-#define SLOGV_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define SLOGV_IF(cond, ...)                                                 \
+  ((__predict_false(cond))                                                  \
+       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_VERBOSE, \
+                                        LOG_TAG, __VA_ARGS__))              \
+       : (void)0)
 #endif
 #endif
 
@@ -68,60 +75,68 @@
  * Simplified macro to send a debug system log message using current LOG_TAG.
  */
 #ifndef SLOGD
-#define SLOGD(...) \
-    ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
+#define SLOGD(...)                                                          \
+  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef SLOGD_IF
-#define SLOGD_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define SLOGD_IF(cond, ...)                                               \
+  ((__predict_false(cond))                                                \
+       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_DEBUG, \
+                                        LOG_TAG, __VA_ARGS__))            \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send an info system log message using current LOG_TAG.
  */
 #ifndef SLOGI
-#define SLOGI(...) \
-    ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__))
+#define SLOGI(...)                                                         \
+  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef SLOGI_IF
-#define SLOGI_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define SLOGI_IF(cond, ...)                                              \
+  ((__predict_false(cond))                                               \
+       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO, \
+                                        LOG_TAG, __VA_ARGS__))           \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send a warning system log message using current LOG_TAG.
  */
 #ifndef SLOGW
-#define SLOGW(...) \
-    ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__))
+#define SLOGW(...)                                                         \
+  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef SLOGW_IF
-#define SLOGW_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define SLOGW_IF(cond, ...)                                              \
+  ((__predict_false(cond))                                               \
+       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_WARN, \
+                                        LOG_TAG, __VA_ARGS__))           \
+       : (void)0)
 #endif
 
 /*
  * Simplified macro to send an error system log message using current LOG_TAG.
  */
 #ifndef SLOGE
-#define SLOGE(...) \
-    ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
+#define SLOGE(...)                                                          \
+  ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, \
+                                 __VA_ARGS__))
 #endif
 
 #ifndef SLOGE_IF
-#define SLOGE_IF(cond, ...) \
-    ( (__predict_false(cond)) \
-    ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) \
-    : (void)0 )
+#define SLOGE_IF(cond, ...)                                               \
+  ((__predict_false(cond))                                                \
+       ? ((void)__android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_ERROR, \
+                                        LOG_TAG, __VA_ARGS__))            \
+       : (void)0)
 #endif
 
 #endif /* _LIBS_LOG_LOG_SYSTEM_H */
diff --git a/liblog/include/log/log_time.h b/liblog/include/log/log_time.h
index 900dc1b..5f70f7d 100644
--- a/liblog/include/log/log_time.h
+++ b/liblog/include/log/log_time.h
@@ -34,159 +34,135 @@
  * efficient behavior. Also, pass-by-reference breaks C/C++ ABI.
  */
 struct log_time {
-public:
-    uint32_t tv_sec; /* good to Feb 5 2106 */
-    uint32_t tv_nsec;
+ public:
+  uint32_t tv_sec; /* good to Feb 5 2106 */
+  uint32_t tv_nsec;
 
-    static const uint32_t tv_sec_max = 0xFFFFFFFFUL;
-    static const uint32_t tv_nsec_max = 999999999UL;
+  static const uint32_t tv_sec_max = 0xFFFFFFFFUL;
+  static const uint32_t tv_nsec_max = 999999999UL;
 
-    log_time(const timespec& T)
-    {
-        tv_sec = static_cast<uint32_t>(T.tv_sec);
-        tv_nsec = static_cast<uint32_t>(T.tv_nsec);
-    }
-    log_time(uint32_t sec, uint32_t nsec)
-    {
-        tv_sec = sec;
-        tv_nsec = nsec;
-    }
+  log_time(const timespec& T) {
+    tv_sec = static_cast<uint32_t>(T.tv_sec);
+    tv_nsec = static_cast<uint32_t>(T.tv_nsec);
+  }
+  log_time(uint32_t sec, uint32_t nsec) {
+    tv_sec = sec;
+    tv_nsec = nsec;
+  }
 #ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
 #define __struct_log_time_private_defined
-    static const timespec EPOCH;
+  static const timespec EPOCH;
 #endif
-    log_time()
-    {
-    }
+  log_time() {
+  }
 #ifdef __linux__
-    log_time(clockid_t id)
-    {
-        timespec T;
-        clock_gettime(id, &T);
-        tv_sec = static_cast<uint32_t>(T.tv_sec);
-        tv_nsec = static_cast<uint32_t>(T.tv_nsec);
-    }
+  log_time(clockid_t id) {
+    timespec T;
+    clock_gettime(id, &T);
+    tv_sec = static_cast<uint32_t>(T.tv_sec);
+    tv_nsec = static_cast<uint32_t>(T.tv_nsec);
+  }
 #endif
-    log_time(const char* T)
-    {
-        const uint8_t* c = reinterpret_cast<const uint8_t*>(T);
-        tv_sec = c[0] |
-                 (static_cast<uint32_t>(c[1]) << 8) |
-                 (static_cast<uint32_t>(c[2]) << 16) |
-                 (static_cast<uint32_t>(c[3]) << 24);
-        tv_nsec = c[4] |
-                  (static_cast<uint32_t>(c[5]) << 8) |
-                  (static_cast<uint32_t>(c[6]) << 16) |
-                  (static_cast<uint32_t>(c[7]) << 24);
-    }
+  log_time(const char* T) {
+    const uint8_t* c = reinterpret_cast<const uint8_t*>(T);
+    tv_sec = c[0] | (static_cast<uint32_t>(c[1]) << 8) |
+             (static_cast<uint32_t>(c[2]) << 16) |
+             (static_cast<uint32_t>(c[3]) << 24);
+    tv_nsec = c[4] | (static_cast<uint32_t>(c[5]) << 8) |
+              (static_cast<uint32_t>(c[6]) << 16) |
+              (static_cast<uint32_t>(c[7]) << 24);
+  }
 
-    /* timespec */
-    bool operator== (const timespec& T) const
-    {
-        return (tv_sec == static_cast<uint32_t>(T.tv_sec))
-            && (tv_nsec == static_cast<uint32_t>(T.tv_nsec));
-    }
-    bool operator!= (const timespec& T) const
-    {
-        return !(*this == T);
-    }
-    bool operator< (const timespec& T) const
-    {
-        return (tv_sec < static_cast<uint32_t>(T.tv_sec))
-            || ((tv_sec == static_cast<uint32_t>(T.tv_sec))
-                && (tv_nsec < static_cast<uint32_t>(T.tv_nsec)));
-    }
-    bool operator>= (const timespec& T) const
-    {
-        return !(*this < T);
-    }
-    bool operator> (const timespec& T) const
-    {
-        return (tv_sec > static_cast<uint32_t>(T.tv_sec))
-            || ((tv_sec == static_cast<uint32_t>(T.tv_sec))
-                && (tv_nsec > static_cast<uint32_t>(T.tv_nsec)));
-    }
-    bool operator<= (const timespec& T) const
-    {
-        return !(*this > T);
-    }
+  /* timespec */
+  bool operator==(const timespec& T) const {
+    return (tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
+           (tv_nsec == static_cast<uint32_t>(T.tv_nsec));
+  }
+  bool operator!=(const timespec& T) const {
+    return !(*this == T);
+  }
+  bool operator<(const timespec& T) const {
+    return (tv_sec < static_cast<uint32_t>(T.tv_sec)) ||
+           ((tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
+            (tv_nsec < static_cast<uint32_t>(T.tv_nsec)));
+  }
+  bool operator>=(const timespec& T) const {
+    return !(*this < T);
+  }
+  bool operator>(const timespec& T) const {
+    return (tv_sec > static_cast<uint32_t>(T.tv_sec)) ||
+           ((tv_sec == static_cast<uint32_t>(T.tv_sec)) &&
+            (tv_nsec > static_cast<uint32_t>(T.tv_nsec)));
+  }
+  bool operator<=(const timespec& T) const {
+    return !(*this > T);
+  }
 
 #ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
-    log_time operator-= (const timespec& T);
-    log_time operator- (const timespec& T) const
-    {
-        log_time local(*this);
-        return local -= T;
-    }
-    log_time operator+= (const timespec& T);
-    log_time operator+ (const timespec& T) const
-    {
-        log_time local(*this);
-        return local += T;
-    }
+  log_time operator-=(const timespec& T);
+  log_time operator-(const timespec& T) const {
+    log_time local(*this);
+    return local -= T;
+  }
+  log_time operator+=(const timespec& T);
+  log_time operator+(const timespec& T) const {
+    log_time local(*this);
+    return local += T;
+  }
 #endif
 
-    /* log_time */
-    bool operator== (const log_time& T) const
-    {
-        return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
-    }
-    bool operator!= (const log_time& T) const
-    {
-        return !(*this == T);
-    }
-    bool operator< (const log_time& T) const
-    {
-        return (tv_sec < T.tv_sec)
-            || ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec));
-    }
-    bool operator>= (const log_time& T) const
-    {
-        return !(*this < T);
-    }
-    bool operator> (const log_time& T) const
-    {
-        return (tv_sec > T.tv_sec)
-            || ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec));
-    }
-    bool operator<= (const log_time& T) const
-    {
-        return !(*this > T);
-    }
+  /* log_time */
+  bool operator==(const log_time& T) const {
+    return (tv_sec == T.tv_sec) && (tv_nsec == T.tv_nsec);
+  }
+  bool operator!=(const log_time& T) const {
+    return !(*this == T);
+  }
+  bool operator<(const log_time& T) const {
+    return (tv_sec < T.tv_sec) ||
+           ((tv_sec == T.tv_sec) && (tv_nsec < T.tv_nsec));
+  }
+  bool operator>=(const log_time& T) const {
+    return !(*this < T);
+  }
+  bool operator>(const log_time& T) const {
+    return (tv_sec > T.tv_sec) ||
+           ((tv_sec == T.tv_sec) && (tv_nsec > T.tv_nsec));
+  }
+  bool operator<=(const log_time& T) const {
+    return !(*this > T);
+  }
 
 #ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
-    log_time operator-= (const log_time& T);
-    log_time operator- (const log_time& T) const
-    {
-        log_time local(*this);
-        return local -= T;
-    }
-    log_time operator+= (const log_time& T);
-    log_time operator+ (const log_time& T) const
-    {
-        log_time local(*this);
-        return local += T;
-    }
+  log_time operator-=(const log_time& T);
+  log_time operator-(const log_time& T) const {
+    log_time local(*this);
+    return local -= T;
+  }
+  log_time operator+=(const log_time& T);
+  log_time operator+(const log_time& T) const {
+    log_time local(*this);
+    return local += T;
+  }
 #endif
 
-    uint64_t nsec() const
-    {
-        return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
-    }
+  uint64_t nsec() const {
+    return static_cast<uint64_t>(tv_sec) * NS_PER_SEC + tv_nsec;
+  }
 
 #ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
-    static const char default_format[];
+  static const char default_format[];
 
-    /* Add %#q for the fraction of a second to the standard library functions */
-    char* strptime(const char* s, const char* format = default_format);
+  /* Add %#q for the fraction of a second to the standard library functions */
+  char* strptime(const char* s, const char* format = default_format);
 #endif
 } __attribute__((__packed__));
 
 #else
 
 typedef struct log_time {
-    uint32_t tv_sec;
-    uint32_t tv_nsec;
+  uint32_t tv_sec;
+  uint32_t tv_nsec;
 } __attribute__((__packed__)) log_time;
 
 #endif
diff --git a/liblog/include/log/log_transport.h b/liblog/include/log/log_transport.h
new file mode 100644
index 0000000..80b30db
--- /dev/null
+++ b/liblog/include/log/log_transport.h
@@ -0,0 +1,37 @@
+/*
+**
+** Copyright 2017, The Android Open Source Project
+**
+** This file is dual licensed.  It may be redistributed and/or modified
+** under the terms of the Apache 2.0 License OR version 2 of the GNU
+** General Public License.
+*/
+
+#ifndef _LIBS_LOG_TRANSPORT_H
+#define _LIBS_LOG_TRANSPORT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Logging transports, bit mask to select features. Function returns selection.
+ */
+/* clang-format off */
+#define LOGGER_DEFAULT 0x00
+#define LOGGER_LOGD    0x01
+#define LOGGER_KERNEL  0x02 /* Reserved/Deprecated */
+#define LOGGER_NULL    0x04 /* Does not release resources of other selections */
+#define LOGGER_LOCAL   0x08 /* logs sent to local memory */
+#define LOGGER_STDERR  0x10 /* logs sent to stderr */
+/* clang-format on */
+
+/* Both return the selected transport flag mask, or negative errno */
+int android_set_log_transport(int transport_flag);
+int android_get_log_transport();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBS_LOG_TRANSPORT_H */
diff --git a/liblog/include/log/logprint.h b/liblog/include/log/logprint.h
index 5b99c3c..ca58bc7 100644
--- a/liblog/include/log/logprint.h
+++ b/liblog/include/log/logprint.h
@@ -27,43 +27,43 @@
 #endif
 
 typedef enum {
-    /* Verbs */
-    FORMAT_OFF = 0,
-    FORMAT_BRIEF,
-    FORMAT_PROCESS,
-    FORMAT_TAG,
-    FORMAT_THREAD,
-    FORMAT_RAW,
-    FORMAT_TIME,
-    FORMAT_THREADTIME,
-    FORMAT_LONG,
-    /* Adverbs. The following are modifiers to above format verbs */
-    FORMAT_MODIFIER_COLOR,     /* converts priority to color */
-    FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */
-    FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */
-    FORMAT_MODIFIER_YEAR,      /* Adds year to date */
-    FORMAT_MODIFIER_ZONE,      /* Adds zone to date, + UTC */
-    FORMAT_MODIFIER_EPOCH,     /* Print time as seconds since Jan 1 1970 */
-    FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */
-    FORMAT_MODIFIER_UID,       /* Adds uid */
-    FORMAT_MODIFIER_DESCRIPT,  /* Adds descriptive */
-    /* private, undocumented */
-    FORMAT_MODIFIER_TIME_NSEC, /* switches from msec to nsec time precision */
+  /* Verbs */
+  FORMAT_OFF = 0,
+  FORMAT_BRIEF,
+  FORMAT_PROCESS,
+  FORMAT_TAG,
+  FORMAT_THREAD,
+  FORMAT_RAW,
+  FORMAT_TIME,
+  FORMAT_THREADTIME,
+  FORMAT_LONG,
+  /* Adverbs. The following are modifiers to above format verbs */
+  FORMAT_MODIFIER_COLOR,     /* converts priority to color */
+  FORMAT_MODIFIER_TIME_USEC, /* switches from msec to usec time precision */
+  FORMAT_MODIFIER_PRINTABLE, /* converts non-printable to printable escapes */
+  FORMAT_MODIFIER_YEAR,      /* Adds year to date */
+  FORMAT_MODIFIER_ZONE,      /* Adds zone to date, + UTC */
+  FORMAT_MODIFIER_EPOCH,     /* Print time as seconds since Jan 1 1970 */
+  FORMAT_MODIFIER_MONOTONIC, /* Print cpu time as seconds since start */
+  FORMAT_MODIFIER_UID,       /* Adds uid */
+  FORMAT_MODIFIER_DESCRIPT,  /* Adds descriptive */
+  /* private, undocumented */
+  FORMAT_MODIFIER_TIME_NSEC, /* switches from msec to nsec time precision */
 } AndroidLogPrintFormat;
 
 typedef struct AndroidLogFormat_t AndroidLogFormat;
 
 typedef struct AndroidLogEntry_t {
-    time_t tv_sec;
-    long tv_nsec;
-    android_LogPriority priority;
-    int32_t uid;
-    int32_t pid;
-    int32_t tid;
-    const char* tag;
-    size_t tagLen;
-    size_t messageLen;
-    const char* message;
+  time_t tv_sec;
+  long tv_nsec;
+  android_LogPriority priority;
+  int32_t uid;
+  int32_t pid;
+  int32_t tid;
+  const char* tag;
+  size_t tagLen;
+  size_t messageLen;
+  const char* message;
 } AndroidLogEntry;
 
 AndroidLogFormat* android_log_format_new();
@@ -72,7 +72,7 @@
 
 /* currently returns 0 if format is a modifier, 1 if not */
 int android_log_setPrintFormat(AndroidLogFormat* p_format,
-        AndroidLogPrintFormat format);
+                               AndroidLogPrintFormat format);
 
 /**
  * Returns FORMAT_OFF on invalid string
@@ -90,7 +90,7 @@
  */
 
 int android_log_addFilterRule(AndroidLogFormat* p_format,
-        const char* filterExpression);
+                              const char* filterExpression);
 
 /**
  * filterString: a whitespace-separated set of filter expressions
@@ -103,14 +103,14 @@
  */
 
 int android_log_addFilterString(AndroidLogFormat* p_format,
-        const char* filterString);
+                                const char* filterString);
 
 /**
  * returns 1 if this log line should be printed based on its priority
  * and tag, and 0 if it should not
  */
-int android_log_shouldPrintLine (
-        AndroidLogFormat* p_format, const char* tag, android_LogPriority pri);
+int android_log_shouldPrintLine(AndroidLogFormat* p_format, const char* tag,
+                                android_LogPriority pri);
 
 /**
  * Splits a wire-format buffer into an AndroidLogEntry
@@ -129,8 +129,9 @@
  * into a string.
  */
 int android_log_processBinaryLogBuffer(struct logger_entry* buf,
-    AndroidLogEntry* entry, const EventTagMap* map, char* messageBuf,
-    int messageBufLen);
+                                       AndroidLogEntry* entry,
+                                       const EventTagMap* map, char* messageBuf,
+                                       int messageBufLen);
 
 /**
  * Formats a log message into a buffer
@@ -140,12 +141,10 @@
  * Returns NULL on malloc error
  */
 
-char* android_log_formatLogLine (
-    AndroidLogFormat* p_format,
-    char* defaultBuffer,
-    size_t defaultBufferSize,
-    const AndroidLogEntry* p_line,
-    size_t* p_outLength);
+char* android_log_formatLogLine(AndroidLogFormat* p_format, char* defaultBuffer,
+                                size_t defaultBufferSize,
+                                const AndroidLogEntry* p_line,
+                                size_t* p_outLength);
 
 /**
  * Either print or do not print log line, based on filter
@@ -153,10 +152,8 @@
  * Assumes single threaded execution
  *
  */
-int android_log_printLogLine(
-    AndroidLogFormat* p_format,
-    int fd,
-    const AndroidLogEntry* entry);
+int android_log_printLogLine(AndroidLogFormat* p_format, int fd,
+                             const AndroidLogEntry* entry);
 
 #ifdef __cplusplus
 }
diff --git a/liblog/include/log/uio.h b/liblog/include/log/uio.h
index 7059da5..a492bae 100644
--- a/liblog/include/log/uio.h
+++ b/liblog/include/log/uio.h
@@ -34,12 +34,12 @@
 #include <stddef.h>
 
 struct iovec {
-    void*  iov_base;
-    size_t iov_len;
+  void* iov_base;
+  size_t iov_len;
 };
 
-extern int  readv( int  fd, struct iovec*  vecs, int  count );
-extern int  writev( int  fd, const struct iovec*  vecs, int  count );
+extern int readv(int fd, struct iovec* vecs, int count);
+extern int writev(int fd, const struct iovec* vecs, int count);
 
 #ifdef __cplusplus
 }
@@ -48,4 +48,3 @@
 #endif
 
 #endif /* _LIBS_UTILS_UIO_H */
-
diff --git a/liblog/include/private/android_logger.h b/liblog/include/private/android_logger.h
index 9f81b1f..e3ccfcf 100644
--- a/liblog/include/private/android_logger.h
+++ b/liblog/include/private/android_logger.h
@@ -31,8 +31,8 @@
 }
 #endif
 
-#include <log/log_event_list.h>
 #include <log/log.h>
+#include <log/log_event_list.h>
 
 #define LOGGER_MAGIC 'l'
 
@@ -42,46 +42,46 @@
 
 /* Header Structure to pstore */
 typedef struct __attribute__((__packed__)) {
-    uint8_t magic;
-    uint16_t len;
-    uint16_t uid;
-    uint16_t pid;
+  uint8_t magic;
+  uint16_t len;
+  uint16_t uid;
+  uint16_t pid;
 } android_pmsg_log_header_t;
 
 /* Header Structure to logd, and second header for pstore */
 typedef struct __attribute__((__packed__)) {
-    typeof_log_id_t id;
-    uint16_t tid;
-    log_time realtime;
+  typeof_log_id_t id;
+  uint16_t tid;
+  log_time realtime;
 } android_log_header_t;
 
 /* Event Header Structure to logd */
 typedef struct __attribute__((__packed__)) {
-    int32_t tag;  // Little Endian Order
+  int32_t tag;  // Little Endian Order
 } android_event_header_t;
 
 /* Event payload EVENT_TYPE_INT */
 typedef struct __attribute__((__packed__)) {
-    int8_t type;  // EVENT_TYPE_INT
-    int32_t data; // Little Endian Order
+  int8_t type;   // EVENT_TYPE_INT
+  int32_t data;  // Little Endian Order
 } android_event_int_t;
 
 /* Event with single EVENT_TYPE_INT */
 typedef struct __attribute__((__packed__)) {
-    android_event_header_t header;
-    android_event_int_t payload;
+  android_event_header_t header;
+  android_event_int_t payload;
 } android_log_event_int_t;
 
 /* Event payload EVENT_TYPE_LONG */
 typedef struct __attribute__((__packed__)) {
-    int8_t type;  // EVENT_TYPE_LONG
-    int64_t data; // Little Endian Order
+  int8_t type;   // EVENT_TYPE_LONG
+  int64_t data;  // Little Endian Order
 } android_event_long_t;
 
 /* Event with single EVENT_TYPE_LONG */
 typedef struct __attribute__((__packed__)) {
-    android_event_header_t header;
-    android_event_long_t payload;
+  android_event_header_t header;
+  android_event_long_t payload;
 } android_log_event_long_t;
 
 /*
@@ -97,41 +97,39 @@
  */
 
 typedef struct __attribute__((__packed__)) {
-    int8_t type;    // EVENT_TYPE_STRING;
-    int32_t length; // Little Endian Order
-    char data[];
+  int8_t type;     // EVENT_TYPE_STRING;
+  int32_t length;  // Little Endian Order
+  char data[];
 } android_event_string_t;
 
 /* Event with single EVENT_TYPE_STRING */
 typedef struct __attribute__((__packed__)) {
-    android_event_header_t header;
-    int8_t type;    // EVENT_TYPE_STRING;
-    int32_t length; // Little Endian Order
-    char data[];
+  android_event_header_t header;
+  int8_t type;     // EVENT_TYPE_STRING;
+  int32_t length;  // Little Endian Order
+  char data[];
 } android_log_event_string_t;
 
 #define ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE 256 /* 1MB file */
-#define ANDROID_LOG_PMSG_FILE_SEQUENCE     1000
+#define ANDROID_LOG_PMSG_FILE_SEQUENCE 1000
 
-ssize_t __android_log_pmsg_file_write(
-        log_id_t logId,
-        char prio,
-        const char* filename,
-        const char* buf, size_t len);
+ssize_t __android_log_pmsg_file_write(log_id_t logId, char prio,
+                                      const char* filename, const char* buf,
+                                      size_t len);
 
-#define LOG_ID_ANY      ((log_id_t)-1)
+#define LOG_ID_ANY ((log_id_t)-1)
 #define ANDROID_LOG_ANY ANDROID_LOG_UNKNOWN
 
 /* first 5 arguments match __android_log_msg_file_write, a cast is safe */
-typedef ssize_t (*__android_log_pmsg_file_read_fn)(
-        log_id_t logId,
-        char prio,
-        const char* filename,
-        const char* buf, size_t len, void* arg);
+typedef ssize_t (*__android_log_pmsg_file_read_fn)(log_id_t logId, char prio,
+                                                   const char* filename,
+                                                   const char* buf, size_t len,
+                                                   void* arg);
 
-ssize_t __android_log_pmsg_file_read(
-        log_id_t logId, char prio, const char* prefix,
-        __android_log_pmsg_file_read_fn fn, void* arg);
+ssize_t __android_log_pmsg_file_read(log_id_t logId, char prio,
+                                     const char* prefix,
+                                     __android_log_pmsg_file_read_fn fn,
+                                     void* arg);
 
 int __android_log_security_bwrite(int32_t tag, const void* payload, size_t len);
 int __android_log_security_bswrite(int32_t tag, const char* payload);
@@ -140,14 +138,15 @@
 int __android_log_is_debuggable();
 
 #define BOOL_DEFAULT_FLAG_TRUE_FALSE 0x1
-#define BOOL_DEFAULT_FALSE       0x0     /* false if property not present   */
-#define BOOL_DEFAULT_TRUE        0x1     /* true if property not present    */
-#define BOOL_DEFAULT_FLAG_PERSIST    0x2 /* <key>, persist.<key>, ro.<key>  */
-#define BOOL_DEFAULT_FLAG_ENG        0x4 /* off for user                    */
-#define BOOL_DEFAULT_FLAG_SVELTE     0x8 /* off for low_ram                 */
+#define BOOL_DEFAULT_FALSE 0x0        /* false if property not present   */
+#define BOOL_DEFAULT_TRUE 0x1         /* true if property not present    */
+#define BOOL_DEFAULT_FLAG_PERSIST 0x2 /* <key>, persist.<key>, ro.<key>  */
+#define BOOL_DEFAULT_FLAG_ENG 0x4     /* off for user                    */
+#define BOOL_DEFAULT_FLAG_SVELTE 0x8  /* off for low_ram                 */
 bool __android_logger_property_get_bool(const char* key, int flag);
 
-#define LOG_BUFFER_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform */
+#define LOG_BUFFER_SIZE (256 * 1024) /* Tuned with ro.logd.size per-platform \
+                                      */
 #define LOG_BUFFER_MIN_SIZE (64 * 1024UL)
 #define LOG_BUFFER_MAX_SIZE (256 * 1024 * 1024UL)
 unsigned long __android_logger_get_buffer_size(log_id_t logId);
@@ -163,24 +162,26 @@
 /* android_log_context C++ helpers */
 extern "C++" {
 class __android_log_event_list : public android_log_event_list {
-    __android_log_event_list(const android_log_event_list&) = delete;
-    void operator =(const __android_log_event_list&) = delete;
+  __android_log_event_list(const android_log_event_list&) = delete;
+  void operator=(const __android_log_event_list&) = delete;
 
-public:
-    explicit __android_log_event_list(int tag) : android_log_event_list(tag) { }
-    explicit __android_log_event_list(log_msg& log_msg) : android_log_event_list(log_msg) { }
+ public:
+  explicit __android_log_event_list(int tag) : android_log_event_list(tag) {
+  }
+  explicit __android_log_event_list(log_msg& log_msg)
+      : android_log_event_list(log_msg) {
+  }
 
 #if defined(_USING_LIBCXX)
-    operator std::string() {
-        if (ret) return std::string("");
-        const char* cp = NULL;
-        ssize_t len = android_log_write_list_buffer(ctx, &cp);
-        if (len < 0) ret = len;
-        if (!cp || (len <= 0)) return std::string("");
-        return std::string(cp, len);
-    }
+  operator std::string() {
+    if (ret) return std::string("");
+    const char* cp = NULL;
+    ssize_t len = android_log_write_list_buffer(ctx, &cp);
+    if (len < 0) ret = len;
+    if (!cp || (len <= 0)) return std::string("");
+    return std::string(cp, len);
+  }
 #endif
-
 };
 }
 #endif
diff --git a/liblog/local_logger.c b/liblog/local_logger.c
index d504342..522867d 100644
--- a/liblog/local_logger.c
+++ b/liblog/local_logger.c
@@ -20,14 +20,14 @@
 #if !defined(__MINGW32__)
 #include <pwd.h>
 #endif
+#include <log/uio.h>
 #include <sched.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <log/uio.h>
 
 #include <cutils/list.h> /* template, no library dependency */
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 #include <private/android_filesystem_config.h>
 #include <private/android_logger.h>
 #include <system/thread_defs.h>
@@ -42,56 +42,54 @@
 static int writeToLocalInit();
 static int writeToLocalAvailable(log_id_t logId);
 static void writeToLocalReset();
-static int writeToLocalWrite(log_id_t logId, struct timespec *ts,
-                             struct iovec *vec, size_t nr);
+static int writeToLocalWrite(log_id_t logId, struct timespec* ts,
+                             struct iovec* vec, size_t nr);
 
 LIBLOG_HIDDEN struct android_log_transport_write localLoggerWrite = {
-    .node = { &localLoggerWrite.node, &localLoggerWrite.node },
-    .context.private = NULL,
-    .name = "local",
-    .available = writeToLocalAvailable,
-    .open = writeToLocalInit,
-    .close = writeToLocalReset,
-    .write = writeToLocalWrite,
+  .node = { &localLoggerWrite.node, &localLoggerWrite.node },
+  .context.priv = NULL,
+  .name = "local",
+  .available = writeToLocalAvailable,
+  .open = writeToLocalInit,
+  .close = writeToLocalReset,
+  .write = writeToLocalWrite,
 };
 
-static int writeToLocalVersion(struct android_log_logger *logger,
-                               struct android_log_transport_context *transp);
-static int writeToLocalRead(struct android_log_logger_list *logger_list,
-                            struct android_log_transport_context *transp,
-                            struct log_msg *log_msg);
-static int writeToLocalPoll(struct android_log_logger_list *logger_list,
-                            struct android_log_transport_context *transp);
-static void writeToLocalClose(struct android_log_logger_list *logger_list,
-                              struct android_log_transport_context *transp);
-static int writeToLocalClear(struct android_log_logger *logger,
-                             struct android_log_transport_context *transp);
-static ssize_t writeToLocalGetSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp);
+static int writeToLocalVersion(struct android_log_logger* logger,
+                               struct android_log_transport_context* transp);
+static int writeToLocalRead(struct android_log_logger_list* logger_list,
+                            struct android_log_transport_context* transp,
+                            struct log_msg* log_msg);
+static int writeToLocalPoll(struct android_log_logger_list* logger_list,
+                            struct android_log_transport_context* transp);
+static void writeToLocalClose(struct android_log_logger_list* logger_list,
+                              struct android_log_transport_context* transp);
+static int writeToLocalClear(struct android_log_logger* logger,
+                             struct android_log_transport_context* transp);
+static ssize_t writeToLocalGetSize(struct android_log_logger* logger,
+                                   struct android_log_transport_context* transp);
 static ssize_t writeToLocalSetSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp __unused,
-        size_t size);
+    struct android_log_logger* logger,
+    struct android_log_transport_context* transp __unused, size_t size);
 static ssize_t writeToLocalGetReadbleSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp);
+    struct android_log_logger* logger,
+    struct android_log_transport_context* transp);
 
 struct android_log_transport_read localLoggerRead = {
-    .node = { &localLoggerRead.node, &localLoggerRead.node },
-    .name = "local",
-    .available = writeToLocalAvailable,
-    .version = writeToLocalVersion,
-    .read = writeToLocalRead,
-    .poll = writeToLocalPoll,
-    .close = writeToLocalClose,
-    .clear = writeToLocalClear,
-    .getSize = writeToLocalGetSize,
-    .setSize = writeToLocalSetSize,
-    .getReadableSize = writeToLocalGetReadbleSize,
-    .getPrune = NULL,
-    .setPrune = NULL,
-    .getStats = NULL,
+  .node = { &localLoggerRead.node, &localLoggerRead.node },
+  .name = "local",
+  .available = writeToLocalAvailable,
+  .version = writeToLocalVersion,
+  .read = writeToLocalRead,
+  .poll = writeToLocalPoll,
+  .close = writeToLocalClose,
+  .clear = writeToLocalClear,
+  .getSize = writeToLocalGetSize,
+  .setSize = writeToLocalSetSize,
+  .getReadableSize = writeToLocalGetReadbleSize,
+  .getPrune = NULL,
+  .setPrune = NULL,
+  .getStats = NULL,
 };
 
 struct LogBufferElement {
@@ -115,53 +113,51 @@
  *
  * Confirm the following should <log/log_id.h> be adjusted in the future.
  */
-#define NUMBER_OF_LOG_BUFFERS ((LOG_ID_SECURITY == (LOG_ID_MAX - 2)) ? \
-                                  LOG_ID_SECURITY : \
-                                  LOG_ID_KERNEL)
-#define BLOCK_LOG_BUFFERS(id) (((id) == LOG_ID_SECURITY) || \
-                               ((id) == LOG_ID_KERNEL))
+#define NUMBER_OF_LOG_BUFFERS \
+  ((LOG_ID_SECURITY == (LOG_ID_MAX - 2)) ? LOG_ID_SECURITY : LOG_ID_KERNEL)
+#define BLOCK_LOG_BUFFERS(id) \
+  (((id) == LOG_ID_SECURITY) || ((id) == LOG_ID_KERNEL))
 
 static struct LogBuffer {
   struct listnode head;
   pthread_rwlock_t listLock;
-  char *serviceName; /* Also indicates ready by having a value */
+  char* serviceName; /* Also indicates ready by having a value */
   /* Order and proximity important for memset */
   size_t number[NUMBER_OF_LOG_BUFFERS];         /* clear memset          */
   size_t size[NUMBER_OF_LOG_BUFFERS];           /* clear memset          */
   size_t totalSize[NUMBER_OF_LOG_BUFFERS];      /* init memset           */
   size_t maxSize[NUMBER_OF_LOG_BUFFERS];        /* init MAX_SIZE_DEFAULT */
-  struct listnode *last[NUMBER_OF_LOG_BUFFERS]; /* init &head            */
+  struct listnode* last[NUMBER_OF_LOG_BUFFERS]; /* init &head            */
 } logbuf = {
-  .head = { &logbuf.head, &logbuf.head },
-  .listLock = PTHREAD_RWLOCK_INITIALIZER,
+  .head = { &logbuf.head, &logbuf.head }, .listLock = PTHREAD_RWLOCK_INITIALIZER,
 };
 
-static void LogBufferInit(struct LogBuffer *log) {
+static void LogBufferInit(struct LogBuffer* log) {
   size_t i;
 
   pthread_rwlock_wrlock(&log->listLock);
   list_init(&log->head);
   memset(log->number, 0,
-    sizeof(log->number) + sizeof(log->size) + sizeof(log->totalSize));
+         sizeof(log->number) + sizeof(log->size) + sizeof(log->totalSize));
   for (i = 0; i < NUMBER_OF_LOG_BUFFERS; ++i) {
     log->maxSize[i] = MAX_SIZE_DEFAULT;
     log->last[i] = &log->head;
   }
 #ifdef __BIONIC__
-  asprintf(&log->serviceName, "%s@%d:%d", baseServiceName,
-           __android_log_uid(), getpid());
+  asprintf(&log->serviceName, "%s@%d:%d", baseServiceName, __android_log_uid(),
+           getpid());
 #else
   char buffer[sizeof(baseServiceName) + 1 + 5 + 1 + 5 + 8];
   snprintf(buffer, sizeof(buffer), "%s@%d:%d", baseServiceName,
-                                   __android_log_uid(), getpid());
+           __android_log_uid(), getpid());
   log->serviceName = strdup(buffer);
 #endif
   pthread_rwlock_unlock(&log->listLock);
 }
 
-static void LogBufferClear(struct LogBuffer *log) {
+static void LogBufferClear(struct LogBuffer* log) {
   size_t i;
-  struct listnode *node;
+  struct listnode* node;
 
   pthread_rwlock_wrlock(&log->listLock);
   memset(log->number, 0, sizeof(log->number) + sizeof(log->size));
@@ -169,7 +165,7 @@
     log->last[i] = &log->head;
   }
   while ((node = list_head(&log->head)) != &log->head) {
-    struct LogBufferElement *element;
+    struct LogBufferElement* element;
 
     element = node_to_item(node, struct LogBufferElement, node);
     list_remove(node);
@@ -178,7 +174,7 @@
   pthread_rwlock_unlock(&log->listLock);
 }
 
-static inline void LogBufferFree(struct LogBuffer *log) {
+static inline void LogBufferFree(struct LogBuffer* log) {
   pthread_rwlock_wrlock(&log->listLock);
   free(log->serviceName);
   log->serviceName = NULL;
@@ -186,8 +182,8 @@
   LogBufferClear(log);
 }
 
-static int LogBufferLog(struct LogBuffer *log,
-                        struct LogBufferElement *element) {
+static int LogBufferLog(struct LogBuffer* log,
+                        struct LogBufferElement* element) {
   log_id_t logId = element->logId;
 
   pthread_rwlock_wrlock(&log->listLock);
@@ -199,16 +195,16 @@
     log->last[logId] = list_tail(&log->head);
   }
   while (log->size[logId] > log->maxSize[logId]) {
-    struct listnode *node = log->last[logId];
-    struct LogBufferElement *e;
-    struct android_log_logger_list *logger_list;
+    struct listnode* node = log->last[logId];
+    struct LogBufferElement* e;
+    struct android_log_logger_list* logger_list;
 
     e = node_to_item(node, struct LogBufferElement, node);
     log->number[logId]--;
     log->size[logId] -= e->len;
     logger_list_rdlock();
     logger_list_for_each(logger_list) {
-      struct android_log_transport_context *transp;
+      struct android_log_transport_context* transp;
 
       transport_context_for_each(transp, logger_list) {
         if ((transp->transport == &localLoggerRead) &&
@@ -243,7 +239,7 @@
  */
 static int writeToLocalInit() {
   pthread_attr_t attr;
-  struct LogBuffer *log;
+  struct LogBuffer* log;
 
   if (writeToLocalAvailable(LOG_ID_MAIN) < 0) {
     return -EPERM;
@@ -251,7 +247,7 @@
 
   log = &logbuf;
   if (!log->serviceName) {
-      LogBufferInit(log);
+    LogBufferInit(log);
   }
 
   if (!log->serviceName) {
@@ -275,9 +271,9 @@
     return -EINVAL;
   }
 
-  /* Android hard coded permitted, system goes to logd */
+/* Android hard coded permitted, system goes to logd */
 #if !defined(__MINGW32__)
-  if (__android_log_frontend == LOGGER_DEFAULT) {
+  if (__android_log_transport == LOGGER_DEFAULT) {
     uid = __android_log_uid();
     if ((uid < AID_APP) && (getpwuid(uid) != NULL)) {
       return -EPERM;
@@ -290,10 +286,10 @@
   return 0;
 }
 
-static int writeToLocalWrite(log_id_t logId, struct timespec *ts,
-                             struct iovec *vec, size_t nr) {
+static int writeToLocalWrite(log_id_t logId, struct timespec* ts,
+                             struct iovec* vec, size_t nr) {
   size_t len, i;
-  struct LogBufferElement *element;
+  struct LogBufferElement* element;
 
   if ((logId >= NUMBER_OF_LOG_BUFFERS) || BLOCK_LOG_BUFFERS(logId)) {
     return -EINVAL;
@@ -307,8 +303,8 @@
   if (len > LOGGER_ENTRY_MAX_PAYLOAD) {
     len = LOGGER_ENTRY_MAX_PAYLOAD;
   }
-  element = (struct LogBufferElement *)calloc(1,
-      sizeof(struct LogBufferElement) + len + 1);
+  element = (struct LogBufferElement*)calloc(
+      1, sizeof(struct LogBufferElement) + len + 1);
   if (!element) {
     return errno ? -errno : -ENOMEM;
   }
@@ -322,7 +318,7 @@
   element->logId = logId;
   element->len = len;
 
-  char *cp = element->msg;
+  char* cp = element->msg;
   for (i = 0; i < nr; ++i) {
     size_t iov_len = vec[i].iov_len;
     if (iov_len > len) {
@@ -339,17 +335,17 @@
   return LogBufferLog(&logbuf, element);
 }
 
-static int writeToLocalVersion(
-        struct android_log_logger *logger __unused,
-        struct android_log_transport_context *transp __unused) {
+static int writeToLocalVersion(struct android_log_logger* logger __unused,
+                               struct android_log_transport_context* transp
+                                   __unused) {
   return 3;
 }
 
 /* within reader lock, serviceName already validated */
-static struct listnode *writeToLocalNode(
-        struct android_log_logger_list *logger_list,
-        struct android_log_transport_context *transp) {
-  struct listnode *node;
+static struct listnode* writeToLocalNode(
+    struct android_log_logger_list* logger_list,
+    struct android_log_transport_context* transp) {
+  struct listnode* node;
   unsigned logMask;
   unsigned int tail;
 
@@ -366,7 +362,7 @@
   tail = logger_list->tail;
 
   for (node = list_head(&logbuf.head); node != &logbuf.head; node = node->next) {
-    struct LogBufferElement *element;
+    struct LogBufferElement* element;
     log_id_t logId;
 
     element = node_to_item(node, struct LogBufferElement, node);
@@ -380,12 +376,11 @@
   return transp->context.node = node;
 }
 
-static int writeToLocalRead(
-        struct android_log_logger_list *logger_list,
-        struct android_log_transport_context *transp,
-        struct log_msg *log_msg) {
+static int writeToLocalRead(struct android_log_logger_list* logger_list,
+                            struct android_log_transport_context* transp,
+                            struct log_msg* log_msg) {
   int ret;
-  struct listnode *node;
+  struct listnode* node;
   unsigned logMask;
 
   pthread_rwlock_rdlock(&logbuf.listLock);
@@ -401,7 +396,7 @@
   ret = 0;
 
   while (node != list_head(&logbuf.head)) {
-    struct LogBufferElement *element;
+    struct LogBufferElement* element;
     log_id_t logId;
 
     node = node->prev;
@@ -429,23 +424,22 @@
   return ret;
 }
 
-static int writeToLocalPoll(
-        struct android_log_logger_list *logger_list,
-        struct android_log_transport_context *transp) {
+static int writeToLocalPoll(struct android_log_logger_list* logger_list,
+                            struct android_log_transport_context* transp) {
   int ret = (logger_list->mode & ANDROID_LOG_NONBLOCK) ? -ENODEV : 0;
 
   pthread_rwlock_rdlock(&logbuf.listLock);
 
   if (logbuf.serviceName) {
     unsigned logMask = transp->logMask;
-    struct listnode *node = writeToLocalNode(logger_list, transp);
+    struct listnode* node = writeToLocalNode(logger_list, transp);
 
     ret = (node != list_head(&logbuf.head));
     if (ret) {
       do {
-        ret = !!(logMask & (1 << (node_to_item(node->prev,
-                                               struct LogBufferElement,
-                                               node))->logId));
+        ret = !!(logMask &
+                 (1 << (node_to_item(node->prev, struct LogBufferElement, node))
+                           ->logId));
       } while (!ret && ((node = node->prev) != list_head(&logbuf.head)));
     }
 
@@ -457,17 +451,17 @@
   return ret;
 }
 
-static void writeToLocalClose(
-        struct android_log_logger_list *logger_list __unused,
-        struct android_log_transport_context *transp) {
+static void writeToLocalClose(struct android_log_logger_list* logger_list
+                                  __unused,
+                              struct android_log_transport_context* transp) {
   pthread_rwlock_wrlock(&logbuf.listLock);
   transp->context.node = list_head(&logbuf.head);
   pthread_rwlock_unlock(&logbuf.listLock);
 }
 
-static int writeToLocalClear(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *unused __unused) {
+static int writeToLocalClear(struct android_log_logger* logger,
+                             struct android_log_transport_context* unused
+                                 __unused) {
   log_id_t logId = logger->logId;
   struct listnode *node, *n;
 
@@ -479,15 +473,15 @@
   logbuf.number[logId] = 0;
   logbuf.last[logId] = &logbuf.head;
   list_for_each_safe(node, n, &logbuf.head) {
-    struct LogBufferElement *element;
+    struct LogBufferElement* element;
     element = node_to_item(node, struct LogBufferElement, node);
 
     if (logId == element->logId) {
-      struct android_log_logger_list *logger_list;
+      struct android_log_logger_list* logger_list;
 
       logger_list_rdlock();
       logger_list_for_each(logger_list) {
-        struct android_log_transport_context *transp;
+        struct android_log_transport_context* transp;
 
         transport_context_for_each(transp, logger_list) {
           if ((transp->transport == &localLoggerRead) &&
@@ -507,9 +501,9 @@
   return 0;
 }
 
-static ssize_t writeToLocalGetSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp __unused) {
+static ssize_t writeToLocalGetSize(struct android_log_logger* logger,
+                                   struct android_log_transport_context* transp
+                                       __unused) {
   ssize_t ret = -EINVAL;
   log_id_t logId = logger->logId;
 
@@ -523,9 +517,8 @@
 }
 
 static ssize_t writeToLocalSetSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp __unused,
-        size_t size) {
+    struct android_log_logger* logger,
+    struct android_log_transport_context* transp __unused, size_t size) {
   ssize_t ret = -EINVAL;
 
   if ((size > LOGGER_ENTRY_MAX_LEN) || (size < (4 * 1024 * 1024))) {
@@ -541,8 +534,8 @@
 }
 
 static ssize_t writeToLocalGetReadbleSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp __unused) {
+    struct android_log_logger* logger,
+    struct android_log_transport_context* transp __unused) {
   ssize_t ret = -EINVAL;
   log_id_t logId = logger->logId;
 
diff --git a/liblog/log_event_list.c b/liblog/log_event_list.c
index 9ac1d30..59ea5ef 100644
--- a/liblog/log_event_list.c
+++ b/liblog/log_event_list.c
@@ -30,270 +30,266 @@
 #define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
 
 typedef struct {
-    uint32_t tag;
-    unsigned pos; /* Read/write position into buffer */
-    unsigned count[ANDROID_MAX_LIST_NEST_DEPTH + 1]; /* Number of elements   */
-    unsigned list[ANDROID_MAX_LIST_NEST_DEPTH + 1];  /* pos for list counter */
-    unsigned list_nest_depth;
-    unsigned len; /* Length or raw buffer. */
-    bool overflow;
-    bool list_stop; /* next call decrement list_nest_depth and issue a stop */
-    enum {
-        kAndroidLoggerRead = 1,
-        kAndroidLoggerWrite = 2,
-    } read_write_flag;
-    uint8_t storage[LOGGER_ENTRY_MAX_PAYLOAD];
+  uint32_t tag;
+  unsigned pos; /* Read/write position into buffer */
+  unsigned count[ANDROID_MAX_LIST_NEST_DEPTH + 1]; /* Number of elements   */
+  unsigned list[ANDROID_MAX_LIST_NEST_DEPTH + 1];  /* pos for list counter */
+  unsigned list_nest_depth;
+  unsigned len; /* Length or raw buffer. */
+  bool overflow;
+  bool list_stop; /* next call decrement list_nest_depth and issue a stop */
+  enum {
+    kAndroidLoggerRead = 1,
+    kAndroidLoggerWrite = 2,
+  } read_write_flag;
+  uint8_t storage[LOGGER_ENTRY_MAX_PAYLOAD];
 } android_log_context_internal;
 
 LIBLOG_ABI_PUBLIC android_log_context create_android_logger(uint32_t tag) {
-    size_t needed, i;
-    android_log_context_internal *context;
+  size_t needed, i;
+  android_log_context_internal* context;
 
-    context = calloc(1, sizeof(android_log_context_internal));
-    if (!context) {
-        return NULL;
-    }
-    context->tag = tag;
-    context->read_write_flag = kAndroidLoggerWrite;
-    needed = sizeof(uint8_t) + sizeof(uint8_t);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-    }
-    /* Everything is a list */
-    context->storage[context->pos + 0] = EVENT_TYPE_LIST;
-    context->list[0] = context->pos + 1;
-    context->pos += needed;
+  context = calloc(1, sizeof(android_log_context_internal));
+  if (!context) {
+    return NULL;
+  }
+  context->tag = tag;
+  context->read_write_flag = kAndroidLoggerWrite;
+  needed = sizeof(uint8_t) + sizeof(uint8_t);
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    context->overflow = true;
+  }
+  /* Everything is a list */
+  context->storage[context->pos + 0] = EVENT_TYPE_LIST;
+  context->list[0] = context->pos + 1;
+  context->pos += needed;
 
-    return (android_log_context)context;
+  return (android_log_context)context;
 }
 
-LIBLOG_ABI_PUBLIC android_log_context create_android_log_parser(
-        const char *msg,
-        size_t len) {
-    android_log_context_internal *context;
-    size_t i;
+LIBLOG_ABI_PUBLIC android_log_context create_android_log_parser(const char* msg,
+                                                                size_t len) {
+  android_log_context_internal* context;
+  size_t i;
 
-    context = calloc(1, sizeof(android_log_context_internal));
-    if (!context) {
-        return NULL;
-    }
-    len = (len <= MAX_EVENT_PAYLOAD) ? len : MAX_EVENT_PAYLOAD;
-    context->len = len;
-    memcpy(context->storage, msg, len);
-    context->read_write_flag = kAndroidLoggerRead;
+  context = calloc(1, sizeof(android_log_context_internal));
+  if (!context) {
+    return NULL;
+  }
+  len = (len <= MAX_EVENT_PAYLOAD) ? len : MAX_EVENT_PAYLOAD;
+  context->len = len;
+  memcpy(context->storage, msg, len);
+  context->read_write_flag = kAndroidLoggerRead;
 
-    return (android_log_context)context;
+  return (android_log_context)context;
 }
 
-LIBLOG_ABI_PUBLIC int android_log_destroy(android_log_context *ctx) {
-    android_log_context_internal *context;
+LIBLOG_ABI_PUBLIC int android_log_destroy(android_log_context* ctx) {
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)*ctx;
-    if (!context) {
-        return -EBADF;
-    }
-    memset(context, 0, sizeof(*context));
-    free(context);
-    *ctx = NULL;
-    return 0;
+  context = (android_log_context_internal*)*ctx;
+  if (!context) {
+    return -EBADF;
+  }
+  memset(context, 0, sizeof(*context));
+  free(context);
+  *ctx = NULL;
+  return 0;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_list_begin(android_log_context ctx) {
-    size_t needed;
-    android_log_context_internal *context;
+  size_t needed;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context ||
-            (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-        context->overflow = true;
-        return -EOVERFLOW;
-    }
-    needed = sizeof(uint8_t) + sizeof(uint8_t);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-        return -EIO;
-    }
-    context->count[context->list_nest_depth]++;
-    context->list_nest_depth++;
-    if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-        context->overflow = true;
-        return -EOVERFLOW;
-    }
-    if (context->overflow) {
-        return -EIO;
-    }
-    context->storage[context->pos + 0] = EVENT_TYPE_LIST;
-    context->storage[context->pos + 1] = 0;
-    context->list[context->list_nest_depth] = context->pos + 1;
-    context->count[context->list_nest_depth] = 0;
-    context->pos += needed;
-    return 0;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
+    context->overflow = true;
+    return -EOVERFLOW;
+  }
+  needed = sizeof(uint8_t) + sizeof(uint8_t);
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    context->overflow = true;
+    return -EIO;
+  }
+  context->count[context->list_nest_depth]++;
+  context->list_nest_depth++;
+  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
+    context->overflow = true;
+    return -EOVERFLOW;
+  }
+  if (context->overflow) {
+    return -EIO;
+  }
+  context->storage[context->pos + 0] = EVENT_TYPE_LIST;
+  context->storage[context->pos + 1] = 0;
+  context->list[context->list_nest_depth] = context->pos + 1;
+  context->count[context->list_nest_depth] = 0;
+  context->pos += needed;
+  return 0;
 }
 
-static inline void copy4LE(uint8_t *buf, uint32_t val)
-{
-    buf[0] = val & 0xFF;
-    buf[1] = (val >> 8) & 0xFF;
-    buf[2] = (val >> 16) & 0xFF;
-    buf[3] = (val >> 24) & 0xFF;
+static inline void copy4LE(uint8_t* buf, uint32_t val) {
+  buf[0] = val & 0xFF;
+  buf[1] = (val >> 8) & 0xFF;
+  buf[2] = (val >> 16) & 0xFF;
+  buf[3] = (val >> 24) & 0xFF;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_int32(android_log_context ctx,
                                               int32_t value) {
-    size_t needed;
-    android_log_context_internal *context;
+  size_t needed;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->overflow) {
-        return -EIO;
-    }
-    needed = sizeof(uint8_t) + sizeof(value);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-        return -EIO;
-    }
-    context->count[context->list_nest_depth]++;
-    context->storage[context->pos + 0] = EVENT_TYPE_INT;
-    copy4LE(&context->storage[context->pos + 1], value);
-    context->pos += needed;
-    return 0;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->overflow) {
+    return -EIO;
+  }
+  needed = sizeof(uint8_t) + sizeof(value);
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    context->overflow = true;
+    return -EIO;
+  }
+  context->count[context->list_nest_depth]++;
+  context->storage[context->pos + 0] = EVENT_TYPE_INT;
+  copy4LE(&context->storage[context->pos + 1], value);
+  context->pos += needed;
+  return 0;
 }
 
-static inline void copy8LE(uint8_t *buf, uint64_t val)
-{
-    buf[0] = val & 0xFF;
-    buf[1] = (val >> 8) & 0xFF;
-    buf[2] = (val >> 16) & 0xFF;
-    buf[3] = (val >> 24) & 0xFF;
-    buf[4] = (val >> 32) & 0xFF;
-    buf[5] = (val >> 40) & 0xFF;
-    buf[6] = (val >> 48) & 0xFF;
-    buf[7] = (val >> 56) & 0xFF;
+static inline void copy8LE(uint8_t* buf, uint64_t val) {
+  buf[0] = val & 0xFF;
+  buf[1] = (val >> 8) & 0xFF;
+  buf[2] = (val >> 16) & 0xFF;
+  buf[3] = (val >> 24) & 0xFF;
+  buf[4] = (val >> 32) & 0xFF;
+  buf[5] = (val >> 40) & 0xFF;
+  buf[6] = (val >> 48) & 0xFF;
+  buf[7] = (val >> 56) & 0xFF;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_int64(android_log_context ctx,
                                               int64_t value) {
-    size_t needed;
-    android_log_context_internal *context;
+  size_t needed;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->overflow) {
-        return -EIO;
-    }
-    needed = sizeof(uint8_t) + sizeof(value);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-        return -EIO;
-    }
-    context->count[context->list_nest_depth]++;
-    context->storage[context->pos + 0] = EVENT_TYPE_LONG;
-    copy8LE(&context->storage[context->pos + 1], value);
-    context->pos += needed;
-    return 0;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->overflow) {
+    return -EIO;
+  }
+  needed = sizeof(uint8_t) + sizeof(value);
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    context->overflow = true;
+    return -EIO;
+  }
+  context->count[context->list_nest_depth]++;
+  context->storage[context->pos + 0] = EVENT_TYPE_LONG;
+  copy8LE(&context->storage[context->pos + 1], value);
+  context->pos += needed;
+  return 0;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_string8_len(android_log_context ctx,
-                                                    const char *value,
+                                                    const char* value,
                                                     size_t maxlen) {
-    size_t needed;
-    ssize_t len;
-    android_log_context_internal *context;
+  size_t needed;
+  ssize_t len;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->overflow) {
+    return -EIO;
+  }
+  if (!value) {
+    value = "";
+  }
+  len = strnlen(value, maxlen);
+  needed = sizeof(uint8_t) + sizeof(int32_t) + len;
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    /* Truncate string for delivery */
+    len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t);
+    if (len <= 0) {
+      context->overflow = true;
+      return -EIO;
     }
-    if (context->overflow) {
-        return -EIO;
-    }
-    if (!value) {
-        value = "";
-    }
-    len = strnlen(value, maxlen);
-    needed = sizeof(uint8_t) + sizeof(int32_t) + len;
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        /* Truncate string for delivery */
-        len = MAX_EVENT_PAYLOAD - context->pos - 1 - sizeof(int32_t);
-        if (len <= 0) {
-            context->overflow = true;
-            return -EIO;
-        }
-    }
-    context->count[context->list_nest_depth]++;
-    context->storage[context->pos + 0] = EVENT_TYPE_STRING;
-    copy4LE(&context->storage[context->pos + 1], len);
-    if (len) {
-        memcpy(&context->storage[context->pos + 5], value, len);
-    }
-    context->pos += needed;
-    return len;
+  }
+  context->count[context->list_nest_depth]++;
+  context->storage[context->pos + 0] = EVENT_TYPE_STRING;
+  copy4LE(&context->storage[context->pos + 1], len);
+  if (len) {
+    memcpy(&context->storage[context->pos + 5], value, len);
+  }
+  context->pos += needed;
+  return len;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_string8(android_log_context ctx,
-                                                const char *value) {
-    return android_log_write_string8_len(ctx, value, MAX_EVENT_PAYLOAD);
+                                                const char* value) {
+  return android_log_write_string8_len(ctx, value, MAX_EVENT_PAYLOAD);
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_float32(android_log_context ctx,
                                                 float value) {
-    size_t needed;
-    uint32_t ivalue;
-    android_log_context_internal *context;
+  size_t needed;
+  uint32_t ivalue;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->overflow) {
-        return -EIO;
-    }
-    needed = sizeof(uint8_t) + sizeof(ivalue);
-    if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
-        context->overflow = true;
-        return -EIO;
-    }
-    ivalue = *(uint32_t *)&value;
-    context->count[context->list_nest_depth]++;
-    context->storage[context->pos + 0] = EVENT_TYPE_FLOAT;
-    copy4LE(&context->storage[context->pos + 1], ivalue);
-    context->pos += needed;
-    return 0;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->overflow) {
+    return -EIO;
+  }
+  needed = sizeof(uint8_t) + sizeof(ivalue);
+  if ((context->pos + needed) > MAX_EVENT_PAYLOAD) {
+    context->overflow = true;
+    return -EIO;
+  }
+  ivalue = *(uint32_t*)&value;
+  context->count[context->list_nest_depth]++;
+  context->storage[context->pos + 0] = EVENT_TYPE_FLOAT;
+  copy4LE(&context->storage[context->pos + 1], ivalue);
+  context->pos += needed;
+  return 0;
 }
 
 LIBLOG_ABI_PUBLIC int android_log_write_list_end(android_log_context ctx) {
-    android_log_context_internal *context;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
-    }
-    if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
-        context->overflow = true;
-        context->list_nest_depth--;
-        return -EOVERFLOW;
-    }
-    if (!context->list_nest_depth) {
-        context->overflow = true;
-        return -EOVERFLOW;
-    }
-    if (context->list[context->list_nest_depth] <= 0) {
-        context->list_nest_depth--;
-        context->overflow = true;
-        return -EOVERFLOW;
-    }
-    context->storage[context->list[context->list_nest_depth]] =
-        context->count[context->list_nest_depth];
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) {
+    context->overflow = true;
     context->list_nest_depth--;
-    return 0;
+    return -EOVERFLOW;
+  }
+  if (!context->list_nest_depth) {
+    context->overflow = true;
+    return -EOVERFLOW;
+  }
+  if (context->list[context->list_nest_depth] <= 0) {
+    context->list_nest_depth--;
+    context->overflow = true;
+    return -EOVERFLOW;
+  }
+  context->storage[context->list[context->list_nest_depth]] =
+      context->count[context->list_nest_depth];
+  context->list_nest_depth--;
+  return 0;
 }
 
 /*
@@ -301,86 +297,84 @@
  */
 LIBLOG_ABI_PUBLIC int android_log_write_list(android_log_context ctx,
                                              log_id_t id) {
-    android_log_context_internal *context;
-    const char *msg;
-    ssize_t len;
+  android_log_context_internal* context;
+  const char* msg;
+  ssize_t len;
 
-    if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY)) {
-        return -EINVAL;
-    }
+  if ((id != LOG_ID_EVENTS) && (id != LOG_ID_SECURITY)) {
+    return -EINVAL;
+  }
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->list_nest_depth) {
+    return -EIO;
+  }
+  /* NB: if there was overflow, then log is truncated. Nothing reported */
+  context->storage[1] = context->count[0];
+  len = context->len = context->pos;
+  msg = (const char*)context->storage;
+  /* it's not a list */
+  if (context->count[0] <= 1) {
+    len -= sizeof(uint8_t) + sizeof(uint8_t);
+    if (len < 0) {
+      len = 0;
     }
-    if (context->list_nest_depth) {
-        return -EIO;
-    }
-    /* NB: if there was overflow, then log is truncated. Nothing reported */
-    context->storage[1] = context->count[0];
-    len = context->len = context->pos;
-    msg = (const char *)context->storage;
-    /* it's not a list */
-    if (context->count[0] <= 1) {
-        len -= sizeof(uint8_t) + sizeof(uint8_t);
-        if (len < 0) {
-            len = 0;
-        }
-        msg += sizeof(uint8_t) + sizeof(uint8_t);
-    }
-    return (id == LOG_ID_EVENTS) ?
-        __android_log_bwrite(context->tag, msg, len) :
-        __android_log_security_bwrite(context->tag, msg, len);
+    msg += sizeof(uint8_t) + sizeof(uint8_t);
+  }
+  return (id == LOG_ID_EVENTS)
+             ? __android_log_bwrite(context->tag, msg, len)
+             : __android_log_security_bwrite(context->tag, msg, len);
 }
 
 LIBLOG_ABI_PRIVATE int android_log_write_list_buffer(android_log_context ctx,
-                                                     const char **buffer) {
-    android_log_context_internal *context;
-    const char *msg;
-    ssize_t len;
+                                                     const char** buffer) {
+  android_log_context_internal* context;
+  const char* msg;
+  ssize_t len;
 
-    context = (android_log_context_internal *)ctx;
-    if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
-        return -EBADF;
+  context = (android_log_context_internal*)ctx;
+  if (!context || (kAndroidLoggerWrite != context->read_write_flag)) {
+    return -EBADF;
+  }
+  if (context->list_nest_depth) {
+    return -EIO;
+  }
+  if (buffer == NULL) {
+    return -EFAULT;
+  }
+  /* NB: if there was overflow, then log is truncated. Nothing reported */
+  context->storage[1] = context->count[0];
+  len = context->len = context->pos;
+  msg = (const char*)context->storage;
+  /* it's not a list */
+  if (context->count[0] <= 1) {
+    len -= sizeof(uint8_t) + sizeof(uint8_t);
+    if (len < 0) {
+      len = 0;
     }
-    if (context->list_nest_depth) {
-        return -EIO;
-    }
-    if (buffer == NULL) {
-        return -EFAULT;
-    }
-    /* NB: if there was overflow, then log is truncated. Nothing reported */
-    context->storage[1] = context->count[0];
-    len = context->len = context->pos;
-    msg = (const char *)context->storage;
-    /* it's not a list */
-    if (context->count[0] <= 1) {
-        len -= sizeof(uint8_t) + sizeof(uint8_t);
-        if (len < 0) {
-            len = 0;
-        }
-        msg += sizeof(uint8_t) + sizeof(uint8_t);
-    }
-    *buffer = msg;
-    return len;
+    msg += sizeof(uint8_t) + sizeof(uint8_t);
+  }
+  *buffer = msg;
+  return len;
 }
 
 /*
  * Extract a 4-byte value from a byte stream.
  */
-static inline uint32_t get4LE(const uint8_t* src)
-{
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+static inline uint32_t get4LE(const uint8_t* src) {
+  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
 /*
  * Extract an 8-byte value from a byte stream.
  */
-static inline uint64_t get8LE(const uint8_t* src)
-{
-    uint32_t low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
-    uint32_t high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
-    return ((uint64_t) high << 32) | (uint64_t) low;
+static inline uint64_t get8LE(const uint8_t* src) {
+  uint32_t low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+  uint32_t high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
+  return ((uint64_t)high << 32) | (uint64_t)low;
 }
 
 /*
@@ -391,181 +385,181 @@
  * (although it won't crash).
  */
 static android_log_list_element android_log_read_next_internal(
-        android_log_context ctx, int peek) {
-    android_log_list_element elem;
-    unsigned pos;
-    android_log_context_internal *context;
+    android_log_context ctx, int peek) {
+  android_log_list_element elem;
+  unsigned pos;
+  android_log_context_internal* context;
 
-    context = (android_log_context_internal *)ctx;
+  context = (android_log_context_internal*)ctx;
 
-    memset(&elem, 0, sizeof(elem));
+  memset(&elem, 0, sizeof(elem));
 
-    /* Nothing to parse from this context, so return complete. */
-    if (!context || (kAndroidLoggerRead != context->read_write_flag) ||
-            (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) ||
-            (context->count[context->list_nest_depth] >=
-                (MAX_EVENT_PAYLOAD / (sizeof(uint8_t) + sizeof(uint8_t))))) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        if (context &&
-                (context->list_stop ||
-                ((context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) &&
-                    !context->count[context->list_nest_depth]))) {
-            elem.type = EVENT_TYPE_LIST_STOP;
+  /* Nothing to parse from this context, so return complete. */
+  if (!context || (kAndroidLoggerRead != context->read_write_flag) ||
+      (context->list_nest_depth > ANDROID_MAX_LIST_NEST_DEPTH) ||
+      (context->count[context->list_nest_depth] >=
+       (MAX_EVENT_PAYLOAD / (sizeof(uint8_t) + sizeof(uint8_t))))) {
+    elem.type = EVENT_TYPE_UNKNOWN;
+    if (context && (context->list_stop ||
+                    ((context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) &&
+                     !context->count[context->list_nest_depth]))) {
+      elem.type = EVENT_TYPE_LIST_STOP;
+    }
+    elem.complete = true;
+    return elem;
+  }
+
+  /*
+   * Use a different variable to update the position in case this
+   * operation is a "peek".
+   */
+  pos = context->pos;
+  if (context->list_stop) {
+    elem.type = EVENT_TYPE_LIST_STOP;
+    elem.complete = !context->count[0] &&
+                    (!context->list_nest_depth ||
+                     ((context->list_nest_depth == 1) && !context->count[1]));
+    if (!peek) {
+      /* Suck in superfluous stop */
+      if (context->storage[pos] == EVENT_TYPE_LIST_STOP) {
+        context->pos = pos + 1;
+      }
+      if (context->list_nest_depth) {
+        --context->list_nest_depth;
+        if (context->count[context->list_nest_depth]) {
+          context->list_stop = false;
         }
-        elem.complete = true;
-        return elem;
+      } else {
+        context->list_stop = false;
+      }
     }
+    return elem;
+  }
+  if ((pos + 1) > context->len) {
+    elem.type = EVENT_TYPE_UNKNOWN;
+    elem.complete = true;
+    return elem;
+  }
 
-    /*
-     * Use a different variable to update the position in case this
-     * operation is a "peek".
-     */
-    pos = context->pos;
-    if (context->list_stop) {
-        elem.type = EVENT_TYPE_LIST_STOP;
-        elem.complete = !context->count[0] && (!context->list_nest_depth ||
-            ((context->list_nest_depth == 1) && !context->count[1]));
-        if (!peek) {
-            /* Suck in superfluous stop */
-            if (context->storage[pos] == EVENT_TYPE_LIST_STOP) {
-                context->pos = pos + 1;
-            }
-            if (context->list_nest_depth) {
-                --context->list_nest_depth;
-                if (context->count[context->list_nest_depth]) {
-                    context->list_stop = false;
-                }
-            } else {
-                context->list_stop = false;
-            }
-        }
-        return elem;
-    }
-    if ((pos + 1) > context->len) {
-        elem.type = EVENT_TYPE_UNKNOWN;
-        elem.complete = true;
-        return elem;
-    }
-
-    elem.type = context->storage[pos++];
-    switch ((int)elem.type) {
+  elem.type = context->storage[pos++];
+  switch ((int)elem.type) {
     case EVENT_TYPE_FLOAT:
-        /* Rely on union to translate elem.data.int32 into elem.data.float32 */
-        /* FALLTHRU */
+    /* Rely on union to translate elem.data.int32 into elem.data.float32 */
+    /* FALLTHRU */
     case EVENT_TYPE_INT:
-        elem.len = sizeof(int32_t);
-        if ((pos + elem.len) > context->len) {
-            elem.type = EVENT_TYPE_UNKNOWN;
-            return elem;
-        }
-        elem.data.int32 = get4LE(&context->storage[pos]);
-        /* common tangeable object suffix */
-        pos += elem.len;
-        elem.complete = !context->list_nest_depth && !context->count[0];
-        if (!peek) {
-            if (!context->count[context->list_nest_depth] ||
-                    !--(context->count[context->list_nest_depth])) {
-                context->list_stop = true;
-            }
-            context->pos = pos;
-        }
+      elem.len = sizeof(int32_t);
+      if ((pos + elem.len) > context->len) {
+        elem.type = EVENT_TYPE_UNKNOWN;
         return elem;
+      }
+      elem.data.int32 = get4LE(&context->storage[pos]);
+      /* common tangeable object suffix */
+      pos += elem.len;
+      elem.complete = !context->list_nest_depth && !context->count[0];
+      if (!peek) {
+        if (!context->count[context->list_nest_depth] ||
+            !--(context->count[context->list_nest_depth])) {
+          context->list_stop = true;
+        }
+        context->pos = pos;
+      }
+      return elem;
 
     case EVENT_TYPE_LONG:
-        elem.len = sizeof(int64_t);
-        if ((pos + elem.len) > context->len) {
-            elem.type = EVENT_TYPE_UNKNOWN;
-            return elem;
-        }
-        elem.data.int64 = get8LE(&context->storage[pos]);
-        /* common tangeable object suffix */
-        pos += elem.len;
-        elem.complete = !context->list_nest_depth && !context->count[0];
-        if (!peek) {
-            if (!context->count[context->list_nest_depth] ||
-                    !--(context->count[context->list_nest_depth])) {
-                context->list_stop = true;
-            }
-            context->pos = pos;
-        }
+      elem.len = sizeof(int64_t);
+      if ((pos + elem.len) > context->len) {
+        elem.type = EVENT_TYPE_UNKNOWN;
         return elem;
+      }
+      elem.data.int64 = get8LE(&context->storage[pos]);
+      /* common tangeable object suffix */
+      pos += elem.len;
+      elem.complete = !context->list_nest_depth && !context->count[0];
+      if (!peek) {
+        if (!context->count[context->list_nest_depth] ||
+            !--(context->count[context->list_nest_depth])) {
+          context->list_stop = true;
+        }
+        context->pos = pos;
+      }
+      return elem;
 
     case EVENT_TYPE_STRING:
-        if ((pos + sizeof(int32_t)) > context->len) {
-            elem.type = EVENT_TYPE_UNKNOWN;
-            elem.complete = true;
-            return elem;
-        }
-        elem.len = get4LE(&context->storage[pos]);
-        pos += sizeof(int32_t);
-        if ((pos + elem.len) > context->len) {
-            elem.len = context->len - pos; /* truncate string */
-            elem.complete = true;
-            if (!elem.len) {
-                elem.type = EVENT_TYPE_UNKNOWN;
-                return elem;
-            }
-        }
-        elem.data.string = (char *)&context->storage[pos];
-        /* common tangeable object suffix */
-        pos += elem.len;
-        elem.complete = !context->list_nest_depth && !context->count[0];
-        if (!peek) {
-            if (!context->count[context->list_nest_depth] ||
-                    !--(context->count[context->list_nest_depth])) {
-                context->list_stop = true;
-            }
-            context->pos = pos;
-        }
+      if ((pos + sizeof(int32_t)) > context->len) {
+        elem.type = EVENT_TYPE_UNKNOWN;
+        elem.complete = true;
         return elem;
+      }
+      elem.len = get4LE(&context->storage[pos]);
+      pos += sizeof(int32_t);
+      if ((pos + elem.len) > context->len) {
+        elem.len = context->len - pos; /* truncate string */
+        elem.complete = true;
+        if (!elem.len) {
+          elem.type = EVENT_TYPE_UNKNOWN;
+          return elem;
+        }
+      }
+      elem.data.string = (char*)&context->storage[pos];
+      /* common tangeable object suffix */
+      pos += elem.len;
+      elem.complete = !context->list_nest_depth && !context->count[0];
+      if (!peek) {
+        if (!context->count[context->list_nest_depth] ||
+            !--(context->count[context->list_nest_depth])) {
+          context->list_stop = true;
+        }
+        context->pos = pos;
+      }
+      return elem;
 
     case EVENT_TYPE_LIST:
-        if ((pos + sizeof(uint8_t)) > context->len) {
-            elem.type = EVENT_TYPE_UNKNOWN;
-            elem.complete = true;
-            return elem;
-        }
-        elem.complete = context->list_nest_depth >= ANDROID_MAX_LIST_NEST_DEPTH;
-        if (peek) {
-            return elem;
-        }
-        if (context->count[context->list_nest_depth]) {
-            context->count[context->list_nest_depth]--;
-        }
-        context->list_stop = !context->storage[pos];
-        context->list_nest_depth++;
-        if (context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) {
-            context->count[context->list_nest_depth] = context->storage[pos];
-        }
-        context->pos = pos + sizeof(uint8_t);
+      if ((pos + sizeof(uint8_t)) > context->len) {
+        elem.type = EVENT_TYPE_UNKNOWN;
+        elem.complete = true;
         return elem;
+      }
+      elem.complete = context->list_nest_depth >= ANDROID_MAX_LIST_NEST_DEPTH;
+      if (peek) {
+        return elem;
+      }
+      if (context->count[context->list_nest_depth]) {
+        context->count[context->list_nest_depth]--;
+      }
+      context->list_stop = !context->storage[pos];
+      context->list_nest_depth++;
+      if (context->list_nest_depth <= ANDROID_MAX_LIST_NEST_DEPTH) {
+        context->count[context->list_nest_depth] = context->storage[pos];
+      }
+      context->pos = pos + sizeof(uint8_t);
+      return elem;
 
     case EVENT_TYPE_LIST_STOP: /* Suprise Newline terminates lists. */
+      if (!peek) {
+        context->pos = pos;
+      }
+      elem.type = EVENT_TYPE_UNKNOWN;
+      elem.complete = !context->list_nest_depth;
+      if (context->list_nest_depth > 0) {
+        elem.type = EVENT_TYPE_LIST_STOP;
         if (!peek) {
-            context->pos = pos;
+          context->list_nest_depth--;
         }
-        elem.type = EVENT_TYPE_UNKNOWN;
-        elem.complete = !context->list_nest_depth;
-        if (context->list_nest_depth > 0) {
-            elem.type = EVENT_TYPE_LIST_STOP;
-            if (!peek) {
-                context->list_nest_depth--;
-            }
-        }
-        return elem;
+      }
+      return elem;
 
     default:
-        elem.type = EVENT_TYPE_UNKNOWN;
-        return elem;
-    }
+      elem.type = EVENT_TYPE_UNKNOWN;
+      return elem;
+  }
 }
 
-LIBLOG_ABI_PUBLIC android_log_list_element android_log_read_next(
-        android_log_context ctx) {
-    return android_log_read_next_internal(ctx, 0);
+LIBLOG_ABI_PUBLIC android_log_list_element
+android_log_read_next(android_log_context ctx) {
+  return android_log_read_next_internal(ctx, 0);
 }
 
-LIBLOG_ABI_PUBLIC android_log_list_element android_log_peek_next(
-        android_log_context ctx) {
-    return android_log_read_next_internal(ctx, 1);
+LIBLOG_ABI_PUBLIC android_log_list_element
+android_log_peek_next(android_log_context ctx) {
+  return android_log_read_next_internal(ctx, 1);
 }
diff --git a/liblog/log_event_write.c b/liblog/log_event_write.c
index 14d6482..45a6f37 100644
--- a/liblog/log_event_write.c
+++ b/liblog/log_event_write.c
@@ -24,31 +24,28 @@
 
 #define MAX_SUBTAG_LEN 32
 
-LIBLOG_ABI_PUBLIC int __android_log_error_write(
-        int tag,
-        const char *subTag,
-        int32_t uid,
-        const char *data, uint32_t dataLen)
-{
-    int ret = -EINVAL;
+LIBLOG_ABI_PUBLIC int __android_log_error_write(int tag, const char* subTag,
+                                                int32_t uid, const char* data,
+                                                uint32_t dataLen) {
+  int ret = -EINVAL;
 
-    if (subTag && (data || !dataLen)) {
-        android_log_context ctx = create_android_logger(tag);
+  if (subTag && (data || !dataLen)) {
+    android_log_context ctx = create_android_logger(tag);
 
-        ret = -ENOMEM;
-        if (ctx) {
-            ret = android_log_write_string8_len(ctx, subTag, MAX_SUBTAG_LEN);
-            if (ret >= 0) {
-                ret = android_log_write_int32(ctx, uid);
-                if (ret >= 0) {
-                    ret = android_log_write_string8_len(ctx, data, dataLen);
-                    if (ret >= 0) {
-                        ret = android_log_write_list(ctx, LOG_ID_EVENTS);
-                    }
-                }
-            }
-            android_log_destroy(&ctx);
+    ret = -ENOMEM;
+    if (ctx) {
+      ret = android_log_write_string8_len(ctx, subTag, MAX_SUBTAG_LEN);
+      if (ret >= 0) {
+        ret = android_log_write_int32(ctx, uid);
+        if (ret >= 0) {
+          ret = android_log_write_string8_len(ctx, data, dataLen);
+          if (ret >= 0) {
+            ret = android_log_write_list(ctx, LOG_ID_EVENTS);
+          }
         }
+      }
+      android_log_destroy(&ctx);
     }
-    return ret;
+  }
+  return ret;
 }
diff --git a/liblog/log_portability.h b/liblog/log_portability.h
index 3ad2060..88805c7 100644
--- a/liblog/log_portability.h
+++ b/liblog/log_portability.h
@@ -46,7 +46,7 @@
 #if defined(_WIN32)
 #define LIBLOG_WEAK static /* Accept that it is totally private */
 #else
-#define LIBLOG_WEAK __attribute__((weak,visibility("default")))
+#define LIBLOG_WEAK __attribute__((weak, visibility("default")))
 #endif
 
 /* possible missing definitions in sys/cdefs.h */
@@ -54,8 +54,8 @@
 /* DECLS */
 #ifndef __BEGIN_DECLS
 #if defined(__cplusplus)
-#define __BEGIN_DECLS           extern "C" {
-#define __END_DECLS             }
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
 #else
 #define __BEGIN_DECLS
 #define __END_DECLS
@@ -64,19 +64,21 @@
 
 /* Unused argument. For C code only, remove symbol name for C++ */
 #ifndef __unused
-#define __unused        __attribute__((__unused__))
+#define __unused __attribute__((__unused__))
 #endif
 
 /* possible missing definitions in unistd.h */
 
 #ifndef TEMP_FAILURE_RETRY
 /* Used to retry syscalls that can return EINTR. */
-#define TEMP_FAILURE_RETRY(exp) ({         \
+#define TEMP_FAILURE_RETRY(exp)            \
+  ({                                       \
     __typeof__(exp) _rc;                   \
     do {                                   \
-        _rc = (exp);                       \
+      _rc = (exp);                         \
     } while (_rc == -1 && errno == EINTR); \
-    _rc; })
+    _rc;                                   \
+  })
 #endif
 
 #endif /* _LIBLOG_PORTABILITY_H__ */
diff --git a/liblog/log_ratelimit.cpp b/liblog/log_ratelimit.cpp
index dfd4b8f..33770dd 100644
--- a/liblog/log_ratelimit.cpp
+++ b/liblog/log_ratelimit.cpp
@@ -31,8 +31,8 @@
 // of varying the 'seconds' argument to their pleasure.
 static time_t g_last_seconds;
 static const time_t last_seconds_default = 10;
-static const time_t last_seconds_max = 24 * 60 * 60; // maximum of a day
-static const time_t last_seconds_min = 2; // granularity
+static const time_t last_seconds_max = 24 * 60 * 60;  // maximum of a day
+static const time_t last_seconds_min = 2;             // granularity
 // Lock to protect last_clock and last_seconds, but also 'last'
 // argument (not NULL) as supplied to __android_log_ratelimit.
 static pthread_mutex_t lock_ratelimit = PTHREAD_MUTEX_INITIALIZER;
@@ -43,44 +43,44 @@
 // can not acquire a lock, 0 if we are not to log a message, and 1
 // if we are ok to log a message.  Caller should check > 0 for true.
 LIBLOG_ABI_PUBLIC int __android_log_ratelimit(time_t seconds, time_t* last) {
-    int save_errno = errno;
+  int save_errno = errno;
 
-    // Two reasons for trylock failure:
-    //   1. In a signal handler. Must prevent deadlock
-    //   2. Too many threads calling __android_log_ratelimit.
-    //      Bonus to not print if they race here because that
-    //      dovetails the goal of ratelimiting. One may print
-    //      and the others will wait their turn ...
-    if (pthread_mutex_trylock(&lock_ratelimit)) {
-        if (save_errno) errno = save_errno;
-        return -1;
-    }
+  // Two reasons for trylock failure:
+  //   1. In a signal handler. Must prevent deadlock
+  //   2. Too many threads calling __android_log_ratelimit.
+  //      Bonus to not print if they race here because that
+  //      dovetails the goal of ratelimiting. One may print
+  //      and the others will wait their turn ...
+  if (pthread_mutex_trylock(&lock_ratelimit)) {
+    if (save_errno) errno = save_errno;
+    return -1;
+  }
 
-    if (seconds == 0) {
-        seconds = last_seconds_default;
-    } else if (seconds < last_seconds_min) {
-        seconds = last_seconds_min;
-    } else if (seconds > last_seconds_max) {
-        seconds = last_seconds_max;
-    }
+  if (seconds == 0) {
+    seconds = last_seconds_default;
+  } else if (seconds < last_seconds_min) {
+    seconds = last_seconds_min;
+  } else if (seconds > last_seconds_max) {
+    seconds = last_seconds_max;
+  }
 
-    if (!last) {
-        if (g_last_seconds > seconds) {
-            seconds = g_last_seconds;
-        } else if (g_last_seconds < seconds) {
-            g_last_seconds = seconds;
-        }
-        last = &g_last_clock;
+  if (!last) {
+    if (g_last_seconds > seconds) {
+      seconds = g_last_seconds;
+    } else if (g_last_seconds < seconds) {
+      g_last_seconds = seconds;
     }
+    last = &g_last_clock;
+  }
 
-    time_t now = time(NULL);
-    if ((now == (time_t)-1) || ((*last + seconds) > now)) {
-        pthread_mutex_unlock(&lock_ratelimit);
-        if (save_errno) errno = save_errno;
-        return 0;
-    }
-    *last = now;
+  time_t now = time(NULL);
+  if ((now == (time_t)-1) || ((*last + seconds) > now)) {
     pthread_mutex_unlock(&lock_ratelimit);
     if (save_errno) errno = save_errno;
-    return 1;
+    return 0;
+  }
+  *last = now;
+  pthread_mutex_unlock(&lock_ratelimit);
+  if (save_errno) errno = save_errno;
+  return 1;
 }
diff --git a/liblog/log_time.cpp b/liblog/log_time.cpp
index dfd2d44..ae376be 100644
--- a/liblog/log_time.cpp
+++ b/liblog/log_time.cpp
@@ -28,164 +28,164 @@
 
 // Add %#q for fractional seconds to standard strptime function
 
-LIBLOG_ABI_PRIVATE char *log_time::strptime(const char *s, const char *format) {
-    time_t now;
+LIBLOG_ABI_PRIVATE char* log_time::strptime(const char* s, const char* format) {
+  time_t now;
 #ifdef __linux__
-    *this = log_time(CLOCK_REALTIME);
-    now = tv_sec;
+  *this = log_time(CLOCK_REALTIME);
+  now = tv_sec;
 #else
-    time(&now);
-    tv_sec = now;
-    tv_nsec = 0;
+  time(&now);
+  tv_sec = now;
+  tv_nsec = 0;
 #endif
 
-    struct tm *ptm;
+  struct tm* ptm;
 #if !defined(_WIN32)
-    struct tm tmBuf;
-    ptm = localtime_r(&now, &tmBuf);
+  struct tm tmBuf;
+  ptm = localtime_r(&now, &tmBuf);
 #else
-    ptm = localtime(&now);
+  ptm = localtime(&now);
 #endif
 
-    char fmt[strlen(format) + 1];
-    strcpy(fmt, format);
+  char fmt[strlen(format) + 1];
+  strcpy(fmt, format);
 
-    char *ret = const_cast<char *> (s);
-    char *cp;
-    for (char *f = cp = fmt; ; ++cp) {
-        if (!*cp) {
-            if (f != cp) {
-                ret = ::strptime(ret, f, ptm);
-            }
-            break;
-        }
-        if (*cp != '%') {
-            continue;
-        }
-        char *e = cp;
-        ++e;
+  char* ret = const_cast<char*>(s);
+  char* cp;
+  for (char* f = cp = fmt;; ++cp) {
+    if (!*cp) {
+      if (f != cp) {
+        ret = ::strptime(ret, f, ptm);
+      }
+      break;
+    }
+    if (*cp != '%') {
+      continue;
+    }
+    char* e = cp;
+    ++e;
 #if (defined(__BIONIC__))
-        if (*e == 's') {
-            *cp = '\0';
-            if (*f) {
-                ret = ::strptime(ret, f, ptm);
-                if (!ret) {
-                    break;
-                }
-            }
-            tv_sec = 0;
-            while (isdigit(*ret)) {
-                tv_sec = tv_sec * 10 + *ret - '0';
-                ++ret;
-            }
-            now = tv_sec;
-#if !defined(_WIN32)
-            ptm = localtime_r(&now, &tmBuf);
-#else
-            ptm = localtime(&now);
-#endif
-        } else
-#endif
-        {
-            unsigned num = 0;
-            while (isdigit(*e)) {
-                num = num * 10 + *e - '0';
-                ++e;
-            }
-            if (*e != 'q') {
-                continue;
-            }
-            *cp = '\0';
-            if (*f) {
-                ret = ::strptime(ret, f, ptm);
-                if (!ret) {
-                    break;
-                }
-            }
-            unsigned long mul = NS_PER_SEC;
-            if (num == 0) {
-                num = INT_MAX;
-            }
-            tv_nsec = 0;
-            while (isdigit(*ret) && num && (mul > 1)) {
-                --num;
-                mul /= 10;
-                tv_nsec = tv_nsec + (*ret - '0') * mul;
-                ++ret;
-            }
+    if (*e == 's') {
+      *cp = '\0';
+      if (*f) {
+        ret = ::strptime(ret, f, ptm);
+        if (!ret) {
+          break;
         }
-        f = cp = e;
-        ++f;
-    }
-
-    if (ret) {
-        tv_sec = mktime(ptm);
-        return ret;
-    }
-
-    // Upon error, place a known value into the class, the current time.
-#ifdef __linux__
-    *this = log_time(CLOCK_REALTIME);
+      }
+      tv_sec = 0;
+      while (isdigit(*ret)) {
+        tv_sec = tv_sec * 10 + *ret - '0';
+        ++ret;
+      }
+      now = tv_sec;
+#if !defined(_WIN32)
+      ptm = localtime_r(&now, &tmBuf);
 #else
-    time(&now);
-    tv_sec = now;
-    tv_nsec = 0;
+      ptm = localtime(&now);
 #endif
+    } else
+#endif
+    {
+      unsigned num = 0;
+      while (isdigit(*e)) {
+        num = num * 10 + *e - '0';
+        ++e;
+      }
+      if (*e != 'q') {
+        continue;
+      }
+      *cp = '\0';
+      if (*f) {
+        ret = ::strptime(ret, f, ptm);
+        if (!ret) {
+          break;
+        }
+      }
+      unsigned long mul = NS_PER_SEC;
+      if (num == 0) {
+        num = INT_MAX;
+      }
+      tv_nsec = 0;
+      while (isdigit(*ret) && num && (mul > 1)) {
+        --num;
+        mul /= 10;
+        tv_nsec = tv_nsec + (*ret - '0') * mul;
+        ++ret;
+      }
+    }
+    f = cp = e;
+    ++f;
+  }
+
+  if (ret) {
+    tv_sec = mktime(ptm);
     return ret;
+  }
+
+// Upon error, place a known value into the class, the current time.
+#ifdef __linux__
+  *this = log_time(CLOCK_REALTIME);
+#else
+  time(&now);
+  tv_sec = now;
+  tv_nsec = 0;
+#endif
+  return ret;
 }
 
-LIBLOG_ABI_PRIVATE log_time log_time::operator-= (const timespec &T) {
-    // No concept of negative time, clamp to EPOCH
-    if (*this <= T) {
-        return *this = EPOCH;
-    }
+LIBLOG_ABI_PRIVATE log_time log_time::operator-=(const timespec& T) {
+  // No concept of negative time, clamp to EPOCH
+  if (*this <= T) {
+    return *this = EPOCH;
+  }
 
-    if (this->tv_nsec < (unsigned long int)T.tv_nsec) {
-        --this->tv_sec;
-        this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec;
-    } else {
-        this->tv_nsec -= T.tv_nsec;
-    }
-    this->tv_sec -= T.tv_sec;
+  if (this->tv_nsec < (unsigned long int)T.tv_nsec) {
+    --this->tv_sec;
+    this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec;
+  } else {
+    this->tv_nsec -= T.tv_nsec;
+  }
+  this->tv_sec -= T.tv_sec;
 
-    return *this;
+  return *this;
 }
 
-LIBLOG_ABI_PRIVATE log_time log_time::operator+= (const timespec &T) {
-    this->tv_nsec += (unsigned long int)T.tv_nsec;
-    if (this->tv_nsec >= NS_PER_SEC) {
-        this->tv_nsec -= NS_PER_SEC;
-        ++this->tv_sec;
-    }
-    this->tv_sec += T.tv_sec;
+LIBLOG_ABI_PRIVATE log_time log_time::operator+=(const timespec& T) {
+  this->tv_nsec += (unsigned long int)T.tv_nsec;
+  if (this->tv_nsec >= NS_PER_SEC) {
+    this->tv_nsec -= NS_PER_SEC;
+    ++this->tv_sec;
+  }
+  this->tv_sec += T.tv_sec;
 
-    return *this;
+  return *this;
 }
 
-LIBLOG_ABI_PRIVATE log_time log_time::operator-= (const log_time &T) {
-    // No concept of negative time, clamp to EPOCH
-    if (*this <= T) {
-        return *this = EPOCH;
-    }
+LIBLOG_ABI_PRIVATE log_time log_time::operator-=(const log_time& T) {
+  // No concept of negative time, clamp to EPOCH
+  if (*this <= T) {
+    return *this = EPOCH;
+  }
 
-    if (this->tv_nsec < T.tv_nsec) {
-        --this->tv_sec;
-        this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec;
-    } else {
-        this->tv_nsec -= T.tv_nsec;
-    }
-    this->tv_sec -= T.tv_sec;
+  if (this->tv_nsec < T.tv_nsec) {
+    --this->tv_sec;
+    this->tv_nsec = NS_PER_SEC + this->tv_nsec - T.tv_nsec;
+  } else {
+    this->tv_nsec -= T.tv_nsec;
+  }
+  this->tv_sec -= T.tv_sec;
 
-    return *this;
+  return *this;
 }
 
-LIBLOG_ABI_PRIVATE log_time log_time::operator+= (const log_time &T) {
-    this->tv_nsec += T.tv_nsec;
-    if (this->tv_nsec >= NS_PER_SEC) {
-        this->tv_nsec -= NS_PER_SEC;
-        ++this->tv_sec;
-    }
-    this->tv_sec += T.tv_sec;
+LIBLOG_ABI_PRIVATE log_time log_time::operator+=(const log_time& T) {
+  this->tv_nsec += T.tv_nsec;
+  if (this->tv_nsec >= NS_PER_SEC) {
+    this->tv_nsec -= NS_PER_SEC;
+    ++this->tv_sec;
+  }
+  this->tv_sec += T.tv_sec;
 
-    return *this;
+  return *this;
 }
diff --git a/liblog/logd_reader.c b/liblog/logd_reader.c
index a6c3f7a..600f4bb 100644
--- a/liblog/logd_reader.c
+++ b/liblog/logd_reader.c
@@ -24,9 +24,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <time.h>
 #include <unistd.h>
@@ -41,87 +41,86 @@
 #include "logger.h"
 
 /* branchless on many architectures. */
-#define min(x,y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
+#define min(x, y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
 
 static int logdAvailable(log_id_t LogId);
-static int logdVersion(struct android_log_logger *logger,
-                       struct android_log_transport_context *transp);
-static int logdRead(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp,
-                    struct log_msg *log_msg);
-static int logdPoll(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp);
-static void logdClose(struct android_log_logger_list *logger_list,
-                      struct android_log_transport_context *transp);
-static int logdClear(struct android_log_logger *logger,
-                     struct android_log_transport_context *transp);
-static ssize_t logdSetSize(struct android_log_logger *logger,
-                           struct android_log_transport_context *transp,
+static int logdVersion(struct android_log_logger* logger,
+                       struct android_log_transport_context* transp);
+static int logdRead(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp,
+                    struct log_msg* log_msg);
+static int logdPoll(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp);
+static void logdClose(struct android_log_logger_list* logger_list,
+                      struct android_log_transport_context* transp);
+static int logdClear(struct android_log_logger* logger,
+                     struct android_log_transport_context* transp);
+static ssize_t logdSetSize(struct android_log_logger* logger,
+                           struct android_log_transport_context* transp,
                            size_t size);
-static ssize_t logdGetSize(struct android_log_logger *logger,
-                           struct android_log_transport_context *transp);
-static ssize_t logdGetReadableSize(struct android_log_logger *logger,
-                                   struct android_log_transport_context *transp);
-static ssize_t logdGetPrune(struct android_log_logger_list *logger,
-                            struct android_log_transport_context *transp,
-                            char *buf, size_t len);
-static ssize_t logdSetPrune(struct android_log_logger_list *logger,
-                            struct android_log_transport_context *transp,
-                            char *buf, size_t len);
-static ssize_t logdGetStats(struct android_log_logger_list *logger,
-                            struct android_log_transport_context *transp,
-                            char *buf, size_t len);
+static ssize_t logdGetSize(struct android_log_logger* logger,
+                           struct android_log_transport_context* transp);
+static ssize_t logdGetReadableSize(struct android_log_logger* logger,
+                                   struct android_log_transport_context* transp);
+static ssize_t logdGetPrune(struct android_log_logger_list* logger,
+                            struct android_log_transport_context* transp,
+                            char* buf, size_t len);
+static ssize_t logdSetPrune(struct android_log_logger_list* logger,
+                            struct android_log_transport_context* transp,
+                            char* buf, size_t len);
+static ssize_t logdGetStats(struct android_log_logger_list* logger,
+                            struct android_log_transport_context* transp,
+                            char* buf, size_t len);
 
 LIBLOG_HIDDEN struct android_log_transport_read logdLoggerRead = {
-    .node = { &logdLoggerRead.node, &logdLoggerRead.node },
-    .name = "logd",
-    .available = logdAvailable,
-    .version = logdVersion,
-    .read = logdRead,
-    .poll = logdPoll,
-    .close = logdClose,
-    .clear = logdClear,
-    .getSize = logdGetSize,
-    .setSize = logdSetSize,
-    .getReadableSize = logdGetReadableSize,
-    .getPrune = logdGetPrune,
-    .setPrune = logdSetPrune,
-    .getStats = logdGetStats,
+  .node = { &logdLoggerRead.node, &logdLoggerRead.node },
+  .name = "logd",
+  .available = logdAvailable,
+  .version = logdVersion,
+  .read = logdRead,
+  .poll = logdPoll,
+  .close = logdClose,
+  .clear = logdClear,
+  .getSize = logdGetSize,
+  .setSize = logdSetSize,
+  .getReadableSize = logdGetReadableSize,
+  .getPrune = logdGetPrune,
+  .setPrune = logdSetPrune,
+  .getStats = logdGetStats,
 };
 
-static int logdAvailable(log_id_t logId)
-{
-    if (logId >= LOG_ID_MAX) {
-        return -EINVAL;
+static int logdAvailable(log_id_t logId) {
+  if (logId >= LOG_ID_MAX) {
+    return -EINVAL;
+  }
+  if (logId == LOG_ID_SECURITY) {
+    uid_t uid = __android_log_uid();
+    if (uid != AID_SYSTEM) {
+      return -EPERM;
     }
-    if (logId == LOG_ID_SECURITY) {
-        uid_t uid = __android_log_uid();
-        if (uid != AID_SYSTEM) {
-            return -EPERM;
-        }
-    }
-    if (access("/dev/socket/logdw", W_OK) == 0) {
-        return 0;
-    }
-    return -EBADF;
+  }
+  if (access("/dev/socket/logdw", W_OK) == 0) {
+    return 0;
+  }
+  return -EBADF;
 }
 
 /* Private copy of ../libcutils/socket_local_client.c prevent library loops */
 
 #if defined(_WIN32)
 
-LIBLOG_WEAK int socket_local_client(const char *name, int namespaceId, int type)
-{
-    errno = ENOSYS;
-    return -ENOSYS;
+LIBLOG_WEAK int socket_local_client(const char* name, int namespaceId,
+                                    int type) {
+  errno = ENOSYS;
+  return -ENOSYS;
 }
 
 #else /* !_WIN32 */
 
-#include <sys/socket.h>
-#include <sys/un.h>
 #include <sys/select.h>
+#include <sys/socket.h>
 #include <sys/types.h>
+#include <sys/un.h>
 
 /* Private copy of ../libcutils/socket_local.h prevent library loops */
 #define FILESYSTEM_SOCKET_PREFIX "/tmp/"
@@ -131,78 +130,77 @@
 #define LISTEN_BACKLOG 4
 
 /* Documented in header file. */
-LIBLOG_WEAK int socket_make_sockaddr_un(const char *name, int namespaceId,
-                                        struct sockaddr_un *p_addr,
-                                        socklen_t *alen)
-{
-    memset (p_addr, 0, sizeof (*p_addr));
-    size_t namelen;
+LIBLOG_WEAK int socket_make_sockaddr_un(const char* name, int namespaceId,
+                                        struct sockaddr_un* p_addr,
+                                        socklen_t* alen) {
+  memset(p_addr, 0, sizeof(*p_addr));
+  size_t namelen;
 
-    switch (namespaceId) {
+  switch (namespaceId) {
     case ANDROID_SOCKET_NAMESPACE_ABSTRACT:
 #if defined(__linux__)
-        namelen  = strlen(name);
+      namelen = strlen(name);
 
-        /* Test with length +1 for the *initial* '\0'. */
-        if ((namelen + 1) > sizeof(p_addr->sun_path)) {
-            goto error;
-        }
+      /* Test with length +1 for the *initial* '\0'. */
+      if ((namelen + 1) > sizeof(p_addr->sun_path)) {
+        goto error;
+      }
 
-        /*
-         * Note: The path in this case is *not* supposed to be
-         * '\0'-terminated. ("man 7 unix" for the gory details.)
-         */
+      /*
+       * Note: The path in this case is *not* supposed to be
+       * '\0'-terminated. ("man 7 unix" for the gory details.)
+       */
 
-        p_addr->sun_path[0] = 0;
-        memcpy(p_addr->sun_path + 1, name, namelen);
+      p_addr->sun_path[0] = 0;
+      memcpy(p_addr->sun_path + 1, name, namelen);
 #else
-        /* this OS doesn't have the Linux abstract namespace */
+      /* this OS doesn't have the Linux abstract namespace */
 
-        namelen = strlen(name) + strlen(FILESYSTEM_SOCKET_PREFIX);
-        /* unix_path_max appears to be missing on linux */
-        if (namelen > sizeof(*p_addr)
-                - offsetof(struct sockaddr_un, sun_path) - 1) {
-            goto error;
-        }
+      namelen = strlen(name) + strlen(FILESYSTEM_SOCKET_PREFIX);
+      /* unix_path_max appears to be missing on linux */
+      if (namelen >
+          sizeof(*p_addr) - offsetof(struct sockaddr_un, sun_path) - 1) {
+        goto error;
+      }
 
-        strcpy(p_addr->sun_path, FILESYSTEM_SOCKET_PREFIX);
-        strcat(p_addr->sun_path, name);
+      strcpy(p_addr->sun_path, FILESYSTEM_SOCKET_PREFIX);
+      strcat(p_addr->sun_path, name);
 #endif
-        break;
+      break;
 
     case ANDROID_SOCKET_NAMESPACE_RESERVED:
-        namelen = strlen(name) + strlen(ANDROID_RESERVED_SOCKET_PREFIX);
-        /* unix_path_max appears to be missing on linux */
-        if (namelen > sizeof(*p_addr)
-                - offsetof(struct sockaddr_un, sun_path) - 1) {
-            goto error;
-        }
+      namelen = strlen(name) + strlen(ANDROID_RESERVED_SOCKET_PREFIX);
+      /* unix_path_max appears to be missing on linux */
+      if (namelen >
+          sizeof(*p_addr) - offsetof(struct sockaddr_un, sun_path) - 1) {
+        goto error;
+      }
 
-        strcpy(p_addr->sun_path, ANDROID_RESERVED_SOCKET_PREFIX);
-        strcat(p_addr->sun_path, name);
-        break;
+      strcpy(p_addr->sun_path, ANDROID_RESERVED_SOCKET_PREFIX);
+      strcat(p_addr->sun_path, name);
+      break;
 
     case ANDROID_SOCKET_NAMESPACE_FILESYSTEM:
-        namelen = strlen(name);
-        /* unix_path_max appears to be missing on linux */
-        if (namelen > sizeof(*p_addr)
-                - offsetof(struct sockaddr_un, sun_path) - 1) {
-            goto error;
-        }
+      namelen = strlen(name);
+      /* unix_path_max appears to be missing on linux */
+      if (namelen >
+          sizeof(*p_addr) - offsetof(struct sockaddr_un, sun_path) - 1) {
+        goto error;
+      }
 
-        strcpy(p_addr->sun_path, name);
-        break;
+      strcpy(p_addr->sun_path, name);
+      break;
 
     default:
-        /* invalid namespace id */
-        return -1;
-    }
+      /* invalid namespace id */
+      return -1;
+  }
 
-    p_addr->sun_family = AF_LOCAL;
-    *alen = namelen + offsetof(struct sockaddr_un, sun_path) + 1;
-    return 0;
+  p_addr->sun_family = AF_LOCAL;
+  *alen = namelen + offsetof(struct sockaddr_un, sun_path) + 1;
+  return 0;
 error:
-    return -1;
+  return -1;
 }
 
 /**
@@ -212,466 +210,441 @@
  *
  * Used by AndroidSocketImpl
  */
-LIBLOG_WEAK int socket_local_client_connect(int fd, const char *name,
-                                            int namespaceId, int type __unused)
-{
-    struct sockaddr_un addr;
-    socklen_t alen;
-    int err;
+LIBLOG_WEAK int socket_local_client_connect(int fd, const char* name,
+                                            int namespaceId, int type __unused) {
+  struct sockaddr_un addr;
+  socklen_t alen;
+  int err;
 
-    err = socket_make_sockaddr_un(name, namespaceId, &addr, &alen);
+  err = socket_make_sockaddr_un(name, namespaceId, &addr, &alen);
 
-    if (err < 0) {
-        goto error;
-    }
+  if (err < 0) {
+    goto error;
+  }
 
-    if(connect(fd, (struct sockaddr *) &addr, alen) < 0) {
-        goto error;
-    }
+  if (connect(fd, (struct sockaddr*)&addr, alen) < 0) {
+    goto error;
+  }
 
-    return fd;
+  return fd;
 
 error:
-    return -1;
+  return -1;
 }
 
 /**
  * connect to peer named "name"
  * returns fd or -1 on error
  */
-LIBLOG_WEAK int socket_local_client(const char *name, int namespaceId, int type)
-{
-    int s;
+LIBLOG_WEAK int socket_local_client(const char* name, int namespaceId,
+                                    int type) {
+  int s;
 
-    s = socket(AF_LOCAL, type, 0);
-    if(s < 0) return -1;
+  s = socket(AF_LOCAL, type, 0);
+  if (s < 0) return -1;
 
-    if ( 0 > socket_local_client_connect(s, name, namespaceId, type)) {
-        close(s);
-        return -1;
-    }
+  if (0 > socket_local_client_connect(s, name, namespaceId, type)) {
+    close(s);
+    return -1;
+  }
 
-    return s;
+  return s;
 }
 
 #endif /* !_WIN32 */
 /* End of ../libcutils/socket_local_client.c */
 
 /* worker for sending the command to the logger */
-static ssize_t send_log_msg(struct android_log_logger *logger,
-                            const char *msg, char *buf, size_t buf_size)
-{
-    ssize_t ret;
-    size_t len;
-    char *cp;
-    int errno_save = 0;
-    int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_STREAM);
-    if (sock < 0) {
-        return sock;
+static ssize_t send_log_msg(struct android_log_logger* logger, const char* msg,
+                            char* buf, size_t buf_size) {
+  ssize_t ret;
+  size_t len;
+  char* cp;
+  int errno_save = 0;
+  int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED,
+                                 SOCK_STREAM);
+  if (sock < 0) {
+    return sock;
+  }
+
+  if (msg) {
+    snprintf(buf, buf_size, msg, logger ? logger->logId : (unsigned)-1);
+  }
+
+  len = strlen(buf) + 1;
+  ret = TEMP_FAILURE_RETRY(write(sock, buf, len));
+  if (ret <= 0) {
+    goto done;
+  }
+
+  len = buf_size;
+  cp = buf;
+  while ((ret = TEMP_FAILURE_RETRY(read(sock, cp, len))) > 0) {
+    struct pollfd p;
+
+    if (((size_t)ret == len) || (buf_size < PAGE_SIZE)) {
+      break;
     }
 
-    if (msg) {
-        snprintf(buf, buf_size, msg, logger ? logger->logId : (unsigned) -1);
-    }
+    len -= ret;
+    cp += ret;
 
-    len = strlen(buf) + 1;
-    ret = TEMP_FAILURE_RETRY(write(sock, buf, len));
+    memset(&p, 0, sizeof(p));
+    p.fd = sock;
+    p.events = POLLIN;
+
+    /* Give other side 20ms to refill pipe */
+    ret = TEMP_FAILURE_RETRY(poll(&p, 1, 20));
+
     if (ret <= 0) {
-        goto done;
+      break;
     }
 
-    len = buf_size;
-    cp = buf;
-    while ((ret = TEMP_FAILURE_RETRY(read(sock, cp, len))) > 0) {
-        struct pollfd p;
-
-        if (((size_t)ret == len) || (buf_size < PAGE_SIZE)) {
-            break;
-        }
-
-        len -= ret;
-        cp += ret;
-
-        memset(&p, 0, sizeof(p));
-        p.fd = sock;
-        p.events = POLLIN;
-
-        /* Give other side 20ms to refill pipe */
-        ret = TEMP_FAILURE_RETRY(poll(&p, 1, 20));
-
-        if (ret <= 0) {
-            break;
-        }
-
-        if (!(p.revents & POLLIN)) {
-            ret = 0;
-            break;
-        }
+    if (!(p.revents & POLLIN)) {
+      ret = 0;
+      break;
     }
+  }
 
-    if (ret >= 0) {
-        ret += buf_size - len;
-    }
+  if (ret >= 0) {
+    ret += buf_size - len;
+  }
 
 done:
-    if ((ret == -1) && errno) {
-        errno_save = errno;
-    }
-    close(sock);
-    if (errno_save) {
-        errno = errno_save;
-    }
+  if ((ret == -1) && errno) {
+    errno_save = errno;
+  }
+  close(sock);
+  if (errno_save) {
+    errno = errno_save;
+  }
+  return ret;
+}
+
+LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf, size_t buf_size) {
+  return send_log_msg(NULL, NULL, buf, buf_size);
+}
+
+static int check_log_success(char* buf, ssize_t ret) {
+  if (ret < 0) {
     return ret;
+  }
+
+  if (strncmp(buf, "success", 7)) {
+    errno = EINVAL;
+    return -1;
+  }
+
+  return 0;
 }
 
-LIBLOG_HIDDEN ssize_t __send_log_msg(char *buf, size_t buf_size)
-{
-    return send_log_msg(NULL, NULL, buf, buf_size);
-}
+static int logdClear(struct android_log_logger* logger,
+                     struct android_log_transport_context* transp __unused) {
+  char buf[512];
 
-static int check_log_success(char *buf, ssize_t ret)
-{
-    if (ret < 0) {
-        return ret;
-    }
-
-    if (strncmp(buf, "success", 7)) {
-        errno = EINVAL;
-        return -1;
-    }
-
-    return 0;
-}
-
-static int logdClear(struct android_log_logger *logger,
-                     struct android_log_transport_context *transp __unused)
-{
-    char buf[512];
-
-    return check_log_success(buf,
-        send_log_msg(logger, "clear %d", buf, sizeof(buf)));
+  return check_log_success(buf,
+                           send_log_msg(logger, "clear %d", buf, sizeof(buf)));
 }
 
 /* returns the total size of the log's ring buffer */
-static ssize_t logdGetSize(struct android_log_logger *logger,
-                           struct android_log_transport_context *transp __unused)
-{
-    char buf[512];
+static ssize_t logdGetSize(struct android_log_logger* logger,
+                           struct android_log_transport_context* transp __unused) {
+  char buf[512];
 
-    ssize_t ret = send_log_msg(logger, "getLogSize %d", buf, sizeof(buf));
-    if (ret < 0) {
-        return ret;
-    }
+  ssize_t ret = send_log_msg(logger, "getLogSize %d", buf, sizeof(buf));
+  if (ret < 0) {
+    return ret;
+  }
 
-    if ((buf[0] < '0') || ('9' < buf[0])) {
-        return -1;
-    }
+  if ((buf[0] < '0') || ('9' < buf[0])) {
+    return -1;
+  }
 
-    return atol(buf);
+  return atol(buf);
 }
 
-static ssize_t logdSetSize(
-        struct android_log_logger *logger,
-        struct android_log_transport_context *transp __unused,
-        size_t size)
-{
-    char buf[512];
+static ssize_t logdSetSize(struct android_log_logger* logger,
+                           struct android_log_transport_context* transp __unused,
+                           size_t size) {
+  char buf[512];
 
-    snprintf(buf, sizeof(buf), "setLogSize %d %zu", logger->logId, size);
+  snprintf(buf, sizeof(buf), "setLogSize %d %zu", logger->logId, size);
 
-    return check_log_success(buf, send_log_msg(NULL, NULL, buf, sizeof(buf)));
+  return check_log_success(buf, send_log_msg(NULL, NULL, buf, sizeof(buf)));
 }
 
 /*
  * returns the readable size of the log's ring buffer (that is, amount of the
  * log consumed)
  */
-static ssize_t logdGetReadableSize(
-       struct android_log_logger *logger,
-       struct android_log_transport_context *transp __unused)
-{
-    char buf[512];
+static ssize_t logdGetReadableSize(struct android_log_logger* logger,
+                                   struct android_log_transport_context* transp
+                                       __unused) {
+  char buf[512];
 
-    ssize_t ret = send_log_msg(logger, "getLogSizeUsed %d", buf, sizeof(buf));
-    if (ret < 0) {
-        return ret;
-    }
+  ssize_t ret = send_log_msg(logger, "getLogSizeUsed %d", buf, sizeof(buf));
+  if (ret < 0) {
+    return ret;
+  }
 
-    if ((buf[0] < '0') || ('9' < buf[0])) {
-        return -1;
-    }
+  if ((buf[0] < '0') || ('9' < buf[0])) {
+    return -1;
+  }
 
-    return atol(buf);
+  return atol(buf);
 }
 
 /*
  * returns the logger version
  */
-static int logdVersion(
-        struct android_log_logger *logger __unused,
-        struct android_log_transport_context *transp __unused)
-{
-    uid_t uid = __android_log_uid();
-    return ((uid != AID_ROOT) && (uid != AID_LOG) && (uid != AID_SYSTEM)) ? 3 : 4;
+static int logdVersion(struct android_log_logger* logger __unused,
+                       struct android_log_transport_context* transp __unused) {
+  uid_t uid = __android_log_uid();
+  return ((uid != AID_ROOT) && (uid != AID_LOG) && (uid != AID_SYSTEM)) ? 3 : 4;
 }
 
 /*
  * returns statistics
  */
-static ssize_t logdGetStats(struct android_log_logger_list *logger_list,
-                            struct android_log_transport_context *transp __unused,
-                            char *buf, size_t len)
-{
-    struct android_log_logger *logger;
-    char *cp = buf;
-    size_t remaining = len;
-    size_t n;
+static ssize_t logdGetStats(struct android_log_logger_list* logger_list,
+                            struct android_log_transport_context* transp __unused,
+                            char* buf, size_t len) {
+  struct android_log_logger* logger;
+  char* cp = buf;
+  size_t remaining = len;
+  size_t n;
 
-    n = snprintf(cp, remaining, "getStatistics");
+  n = snprintf(cp, remaining, "getStatistics");
+  n = min(n, remaining);
+  remaining -= n;
+  cp += n;
+
+  logger_for_each(logger, logger_list) {
+    n = snprintf(cp, remaining, " %d", logger->logId);
     n = min(n, remaining);
     remaining -= n;
     cp += n;
+  }
 
-    logger_for_each(logger, logger_list) {
-        n = snprintf(cp, remaining, " %d", logger->logId);
-        n = min(n, remaining);
-        remaining -= n;
-        cp += n;
-    }
+  if (logger_list->pid) {
+    snprintf(cp, remaining, " pid=%u", logger_list->pid);
+  }
 
-    if (logger_list->pid) {
-        snprintf(cp, remaining, " pid=%u", logger_list->pid);
-    }
-
-    return send_log_msg(NULL, NULL, buf, len);
+  return send_log_msg(NULL, NULL, buf, len);
 }
 
-static ssize_t logdGetPrune(
-        struct android_log_logger_list *logger_list __unused,
-        struct android_log_transport_context *transp __unused,
-        char *buf, size_t len)
-{
-    return send_log_msg(NULL, "getPruneList", buf, len);
+static ssize_t logdGetPrune(struct android_log_logger_list* logger_list __unused,
+                            struct android_log_transport_context* transp __unused,
+                            char* buf, size_t len) {
+  return send_log_msg(NULL, "getPruneList", buf, len);
 }
 
-static ssize_t logdSetPrune(
-        struct android_log_logger_list *logger_list __unused,
-        struct android_log_transport_context *transp __unused,
-        char *buf, size_t len)
-{
-    const char cmd[] = "setPruneList ";
-    const size_t cmdlen = sizeof(cmd) - 1;
+static ssize_t logdSetPrune(struct android_log_logger_list* logger_list __unused,
+                            struct android_log_transport_context* transp __unused,
+                            char* buf, size_t len) {
+  const char cmd[] = "setPruneList ";
+  const size_t cmdlen = sizeof(cmd) - 1;
 
-    if (strlen(buf) > (len - cmdlen)) {
-        return -ENOMEM; /* KISS */
-    }
-    memmove(buf + cmdlen, buf, len - cmdlen);
-    buf[len - 1] = '\0';
-    memcpy(buf, cmd, cmdlen);
+  if (strlen(buf) > (len - cmdlen)) {
+    return -ENOMEM; /* KISS */
+  }
+  memmove(buf + cmdlen, buf, len - cmdlen);
+  buf[len - 1] = '\0';
+  memcpy(buf, cmd, cmdlen);
 
-    return check_log_success(buf, send_log_msg(NULL, NULL, buf, len));
+  return check_log_success(buf, send_log_msg(NULL, NULL, buf, len));
 }
 
-
-static void caught_signal(int signum __unused)
-{
+static void caught_signal(int signum __unused) {
 }
 
-static int logdOpen(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp)
-{
-    struct android_log_logger *logger;
-    struct sigaction ignore;
-    struct sigaction old_sigaction;
-    unsigned int old_alarm = 0;
-    char buffer[256], *cp, c;
-    int e, ret, remaining, sock;
+static int logdOpen(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp) {
+  struct android_log_logger* logger;
+  struct sigaction ignore;
+  struct sigaction old_sigaction;
+  unsigned int old_alarm = 0;
+  char buffer[256], *cp, c;
+  int e, ret, remaining, sock;
 
-    if (!logger_list) {
-        return -EINVAL;
-    }
+  if (!logger_list) {
+    return -EINVAL;
+  }
 
-    sock = atomic_load(&transp->context.sock);
-    if (sock > 0) {
-        return sock;
-    }
+  sock = atomic_load(&transp->context.sock);
+  if (sock > 0) {
+    return sock;
+  }
 
-    sock = socket_local_client("logdr",
-                               ANDROID_SOCKET_NAMESPACE_RESERVED,
-                               SOCK_SEQPACKET);
-    if (sock == 0) {
-        /* Guarantee not file descriptor zero */
-        int newsock = socket_local_client("logdr",
-                                   ANDROID_SOCKET_NAMESPACE_RESERVED,
-                                   SOCK_SEQPACKET);
-        close(sock);
-        sock = newsock;
-    }
-    if (sock <= 0) {
-        if ((sock == -1) && errno) {
-            return -errno;
-        }
-        return sock;
-    }
-
-    strcpy(buffer, (logger_list->mode & ANDROID_LOG_NONBLOCK) ?
-            "dumpAndClose" : "stream");
-    cp = buffer + strlen(buffer);
-
-    strcpy(cp, " lids");
-    cp += 5;
-    c = '=';
-    remaining = sizeof(buffer) - (cp - buffer);
-    logger_for_each(logger, logger_list) {
-        ret = snprintf(cp, remaining, "%c%u", c, logger->logId);
-        ret = min(ret, remaining);
-        remaining -= ret;
-        cp += ret;
-        c = ',';
-    }
-
-    if (logger_list->tail) {
-        ret = snprintf(cp, remaining, " tail=%u", logger_list->tail);
-        ret = min(ret, remaining);
-        remaining -= ret;
-        cp += ret;
-    }
-
-    if (logger_list->start.tv_sec || logger_list->start.tv_nsec) {
-        if (logger_list->mode & ANDROID_LOG_WRAP) {
-            // ToDo: alternate API to allow timeout to be adjusted.
-            ret = snprintf(cp, remaining, " timeout=%u",
-                           ANDROID_LOG_WRAP_DEFAULT_TIMEOUT);
-            ret = min(ret, remaining);
-            remaining -= ret;
-            cp += ret;
-        }
-        ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32,
-                       logger_list->start.tv_sec,
-                       logger_list->start.tv_nsec);
-        ret = min(ret, remaining);
-        remaining -= ret;
-        cp += ret;
-    }
-
-    if (logger_list->pid) {
-        ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
-        ret = min(ret, remaining);
-        cp += ret;
-    }
-
-    if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
-        /* Deal with an unresponsive logd */
-        memset(&ignore, 0, sizeof(ignore));
-        ignore.sa_handler = caught_signal;
-        sigemptyset(&ignore.sa_mask);
-        /* particularily useful if tombstone is reporting for logd */
-        sigaction(SIGALRM, &ignore, &old_sigaction);
-        old_alarm = alarm(30);
-    }
-    ret = write(sock, buffer, cp - buffer);
-    e = errno;
-    if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
-        if (e == EINTR) {
-            e = ETIMEDOUT;
-        }
-        alarm(old_alarm);
-        sigaction(SIGALRM, &old_sigaction, NULL);
-    }
-
-    if (ret <= 0) {
-        close(sock);
-        if ((ret == -1) && e) {
-            return -e;
-        }
-        if (ret == 0) {
-            return -EIO;
-        }
-        return ret;
-    }
-
-    ret = atomic_exchange(&transp->context.sock, sock);
-    if ((ret > 0) && (ret != sock)) {
-        close(ret);
+  sock = socket_local_client("logdr", ANDROID_SOCKET_NAMESPACE_RESERVED,
+                             SOCK_SEQPACKET);
+  if (sock == 0) {
+    /* Guarantee not file descriptor zero */
+    int newsock = socket_local_client(
+        "logdr", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_SEQPACKET);
+    close(sock);
+    sock = newsock;
+  }
+  if (sock <= 0) {
+    if ((sock == -1) && errno) {
+      return -errno;
     }
     return sock;
+  }
+
+  strcpy(buffer, (logger_list->mode & ANDROID_LOG_NONBLOCK) ? "dumpAndClose"
+                                                            : "stream");
+  cp = buffer + strlen(buffer);
+
+  strcpy(cp, " lids");
+  cp += 5;
+  c = '=';
+  remaining = sizeof(buffer) - (cp - buffer);
+  logger_for_each(logger, logger_list) {
+    ret = snprintf(cp, remaining, "%c%u", c, logger->logId);
+    ret = min(ret, remaining);
+    remaining -= ret;
+    cp += ret;
+    c = ',';
+  }
+
+  if (logger_list->tail) {
+    ret = snprintf(cp, remaining, " tail=%u", logger_list->tail);
+    ret = min(ret, remaining);
+    remaining -= ret;
+    cp += ret;
+  }
+
+  if (logger_list->start.tv_sec || logger_list->start.tv_nsec) {
+    if (logger_list->mode & ANDROID_LOG_WRAP) {
+      // ToDo: alternate API to allow timeout to be adjusted.
+      ret = snprintf(cp, remaining, " timeout=%u",
+                     ANDROID_LOG_WRAP_DEFAULT_TIMEOUT);
+      ret = min(ret, remaining);
+      remaining -= ret;
+      cp += ret;
+    }
+    ret = snprintf(cp, remaining, " start=%" PRIu32 ".%09" PRIu32,
+                   logger_list->start.tv_sec, logger_list->start.tv_nsec);
+    ret = min(ret, remaining);
+    remaining -= ret;
+    cp += ret;
+  }
+
+  if (logger_list->pid) {
+    ret = snprintf(cp, remaining, " pid=%u", logger_list->pid);
+    ret = min(ret, remaining);
+    cp += ret;
+  }
+
+  if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
+    /* Deal with an unresponsive logd */
+    memset(&ignore, 0, sizeof(ignore));
+    ignore.sa_handler = caught_signal;
+    sigemptyset(&ignore.sa_mask);
+    /* particularily useful if tombstone is reporting for logd */
+    sigaction(SIGALRM, &ignore, &old_sigaction);
+    old_alarm = alarm(30);
+  }
+  ret = write(sock, buffer, cp - buffer);
+  e = errno;
+  if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
+    if (e == EINTR) {
+      e = ETIMEDOUT;
+    }
+    alarm(old_alarm);
+    sigaction(SIGALRM, &old_sigaction, NULL);
+  }
+
+  if (ret <= 0) {
+    close(sock);
+    if ((ret == -1) && e) {
+      return -e;
+    }
+    if (ret == 0) {
+      return -EIO;
+    }
+    return ret;
+  }
+
+  ret = atomic_exchange(&transp->context.sock, sock);
+  if ((ret > 0) && (ret != sock)) {
+    close(ret);
+  }
+  return sock;
 }
 
 /* Read from the selected logs */
-static int logdRead(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp,
-                    struct log_msg *log_msg)
-{
-    int ret, e;
-    struct sigaction ignore;
-    struct sigaction old_sigaction;
-    unsigned int old_alarm = 0;
+static int logdRead(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp,
+                    struct log_msg* log_msg) {
+  int ret, e;
+  struct sigaction ignore;
+  struct sigaction old_sigaction;
+  unsigned int old_alarm = 0;
 
-    ret = logdOpen(logger_list, transp);
-    if (ret < 0) {
-        return ret;
-    }
-
-    memset(log_msg, 0, sizeof(*log_msg));
-
-    if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
-        memset(&ignore, 0, sizeof(ignore));
-        ignore.sa_handler = caught_signal;
-        sigemptyset(&ignore.sa_mask);
-        /* particularily useful if tombstone is reporting for logd */
-        sigaction(SIGALRM, &ignore, &old_sigaction);
-        old_alarm = alarm(30);
-    }
-
-    /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */
-    ret = recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0);
-    e = errno;
-
-    if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
-        if ((ret == 0) || (e == EINTR)) {
-            e = EAGAIN;
-            ret = -1;
-        }
-        alarm(old_alarm);
-        sigaction(SIGALRM, &old_sigaction, NULL);
-    }
-
-    if ((ret == -1) && e) {
-        return -e;
-    }
+  ret = logdOpen(logger_list, transp);
+  if (ret < 0) {
     return ret;
+  }
+
+  memset(log_msg, 0, sizeof(*log_msg));
+
+  if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
+    memset(&ignore, 0, sizeof(ignore));
+    ignore.sa_handler = caught_signal;
+    sigemptyset(&ignore.sa_mask);
+    /* particularily useful if tombstone is reporting for logd */
+    sigaction(SIGALRM, &ignore, &old_sigaction);
+    old_alarm = alarm(30);
+  }
+
+  /* NOTE: SOCK_SEQPACKET guarantees we read exactly one full entry */
+  ret = recv(ret, log_msg, LOGGER_ENTRY_MAX_LEN, 0);
+  e = errno;
+
+  if (logger_list->mode & ANDROID_LOG_NONBLOCK) {
+    if ((ret == 0) || (e == EINTR)) {
+      e = EAGAIN;
+      ret = -1;
+    }
+    alarm(old_alarm);
+    sigaction(SIGALRM, &old_sigaction, NULL);
+  }
+
+  if ((ret == -1) && e) {
+    return -e;
+  }
+  return ret;
 }
 
-static int logdPoll(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp)
-{
-    struct pollfd p;
+static int logdPoll(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp) {
+  struct pollfd p;
 
-    int ret = logdOpen(logger_list, transp);
-    if (ret < 0) {
-        return ret;
-    }
-
-    memset(&p, 0, sizeof(p));
-    p.fd = ret;
-    p.events = POLLIN;
-    ret = poll(&p, 1, 20);
-    if ((ret > 0) && !(p.revents & POLLIN)) {
-        ret = 0;
-    }
-    if ((ret == -1) && errno) {
-        return -errno;
-    }
+  int ret = logdOpen(logger_list, transp);
+  if (ret < 0) {
     return ret;
+  }
+
+  memset(&p, 0, sizeof(p));
+  p.fd = ret;
+  p.events = POLLIN;
+  ret = poll(&p, 1, 20);
+  if ((ret > 0) && !(p.revents & POLLIN)) {
+    ret = 0;
+  }
+  if ((ret == -1) && errno) {
+    return -errno;
+  }
+  return ret;
 }
 
 /* Close all the logs */
-static void logdClose(struct android_log_logger_list *logger_list __unused,
-                      struct android_log_transport_context *transp)
-{
-    int sock = atomic_exchange(&transp->context.sock, -1);
-    if (sock > 0) {
-        close (sock);
-    }
+static void logdClose(struct android_log_logger_list* logger_list __unused,
+                      struct android_log_transport_context* transp) {
+  int sock = atomic_exchange(&transp->context.sock, -1);
+  if (sock > 0) {
+    close(sock);
+  }
 }
diff --git a/liblog/logd_reader.h b/liblog/logd_reader.h
index 04c2cf2..8ebb1ae 100644
--- a/liblog/logd_reader.h
+++ b/liblog/logd_reader.h
@@ -23,7 +23,7 @@
 
 __BEGIN_DECLS
 
-LIBLOG_HIDDEN ssize_t __send_log_msg(char *buf, size_t buf_size);
+LIBLOG_HIDDEN ssize_t __send_log_msg(char* buf, size_t buf_size);
 
 __END_DECLS
 
diff --git a/liblog/logd_writer.c b/liblog/logd_writer.c
index 12b797d..e0e3eca 100644
--- a/liblog/logd_writer.c
+++ b/liblog/logd_writer.c
@@ -24,9 +24,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/socket.h>
 #include <sys/un.h>
 #include <time.h>
 #include <unistd.h>
@@ -40,260 +40,251 @@
 #include "logger.h"
 
 /* branchless on many architectures. */
-#define min(x,y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
+#define min(x, y) ((y) ^ (((x) ^ (y)) & -((x) < (y))))
 
 static int logdAvailable(log_id_t LogId);
 static int logdOpen();
 static void logdClose();
-static int logdWrite(log_id_t logId, struct timespec *ts,
-                     struct iovec *vec, size_t nr);
+static int logdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                     size_t nr);
 
 LIBLOG_HIDDEN struct android_log_transport_write logdLoggerWrite = {
-    .node = { &logdLoggerWrite.node, &logdLoggerWrite.node },
-    .context.sock = -EBADF,
-    .name = "logd",
-    .available = logdAvailable,
-    .open = logdOpen,
-    .close = logdClose,
-    .write = logdWrite,
+  .node = { &logdLoggerWrite.node, &logdLoggerWrite.node },
+  .context.sock = -EBADF,
+  .name = "logd",
+  .available = logdAvailable,
+  .open = logdOpen,
+  .close = logdClose,
+  .write = logdWrite,
 };
 
 /* log_init_lock assumed */
-static int logdOpen()
-{
-    int i, ret = 0;
+static int logdOpen() {
+  int i, ret = 0;
 
-    i = atomic_load(&logdLoggerWrite.context.sock);
-    if (i < 0) {
-        int sock = TEMP_FAILURE_RETRY(socket(PF_UNIX, SOCK_DGRAM |
-                                                      SOCK_CLOEXEC |
-                                                      SOCK_NONBLOCK, 0));
-        if (sock < 0) {
-            ret = -errno;
-        } else {
-            struct sockaddr_un un;
-            memset(&un, 0, sizeof(struct sockaddr_un));
-            un.sun_family = AF_UNIX;
-            strcpy(un.sun_path, "/dev/socket/logdw");
+  i = atomic_load(&logdLoggerWrite.context.sock);
+  if (i < 0) {
+    int sock = TEMP_FAILURE_RETRY(
+        socket(PF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0));
+    if (sock < 0) {
+      ret = -errno;
+    } else {
+      struct sockaddr_un un;
+      memset(&un, 0, sizeof(struct sockaddr_un));
+      un.sun_family = AF_UNIX;
+      strcpy(un.sun_path, "/dev/socket/logdw");
 
-            if (TEMP_FAILURE_RETRY(connect(sock, (struct sockaddr *)&un,
-                                           sizeof(struct sockaddr_un))) < 0) {
-                ret = -errno;
-                switch (ret) {
-                case -ENOTCONN:
-                case -ECONNREFUSED:
-                case -ENOENT:
-                    i = atomic_exchange(&logdLoggerWrite.context.sock, ret);
-                    /* FALLTHRU */
-                default:
-                    break;
-                }
-                close(sock);
-            } else {
-                ret = atomic_exchange(&logdLoggerWrite.context.sock, sock);
-                if ((ret >= 0) && (ret != sock)) {
-                    close(ret);
-                }
-                ret = 0;
-            }
-        }
-    }
-
-    return ret;
-}
-
-static void __logdClose(int negative_errno)
-{
-    int sock = atomic_exchange(&logdLoggerWrite.context.sock, negative_errno);
-    if (sock >= 0) {
-        close(sock);
-    }
-}
-
-static void logdClose()
-{
-    __logdClose(-EBADF);
-}
-
-static int logdAvailable(log_id_t logId)
-{
-    if (logId >= LOG_ID_MAX || logId == LOG_ID_KERNEL) {
-        return -EINVAL;
-    }
-    if (atomic_load(&logdLoggerWrite.context.sock) < 0) {
-        if (access("/dev/socket/logdw", W_OK) == 0) {
-            return 0;
-        }
-        return -EBADF;
-    }
-    return 1;
-}
-
-static int logdWrite(log_id_t logId, struct timespec *ts,
-                     struct iovec *vec, size_t nr)
-{
-    ssize_t ret;
-    int sock;
-    static const unsigned headerLength = 1;
-    struct iovec newVec[nr + headerLength];
-    android_log_header_t header;
-    size_t i, payloadSize;
-    static atomic_int_fast32_t dropped;
-    static atomic_int_fast32_t droppedSecurity;
-
-    sock = atomic_load(&logdLoggerWrite.context.sock);
-    if (sock < 0) switch (sock) {
-    case -ENOTCONN:
-    case -ECONNREFUSED:
-    case -ENOENT:
-        break;
-    default:
-        return -EBADF;
-    }
-
-    /* logd, after initialization and priv drop */
-    if (__android_log_uid() == AID_LOGD) {
-        /*
-         * ignore log messages we send to ourself (logd).
-         * Such log messages are often generated by libraries we depend on
-         * which use standard Android logging.
-         */
-        return 0;
-    }
-
-    /*
-     *  struct {
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
-
-    header.tid = gettid();
-    header.realtime.tv_sec = ts->tv_sec;
-    header.realtime.tv_nsec = ts->tv_nsec;
-
-    newVec[0].iov_base = (unsigned char *)&header;
-    newVec[0].iov_len  = sizeof(header);
-
-    if (sock >= 0) {
-        int32_t snapshot = atomic_exchange_explicit(&droppedSecurity, 0,
-                                                    memory_order_relaxed);
-        if (snapshot) {
-            android_log_event_int_t buffer;
-
-            header.id = LOG_ID_SECURITY;
-            buffer.header.tag = htole32(LIBLOG_LOG_TAG);
-            buffer.payload.type = EVENT_TYPE_INT;
-            buffer.payload.data = htole32(snapshot);
-
-            newVec[headerLength].iov_base = &buffer;
-            newVec[headerLength].iov_len  = sizeof(buffer);
-
-            ret = TEMP_FAILURE_RETRY(writev(sock, newVec, 2));
-            if (ret != (ssize_t)(sizeof(header) + sizeof(buffer))) {
-                atomic_fetch_add_explicit(&droppedSecurity, snapshot,
-                                          memory_order_relaxed);
-            }
-        }
-        snapshot = atomic_exchange_explicit(&dropped, 0, memory_order_relaxed);
-        if (snapshot && __android_log_is_loggable_len(ANDROID_LOG_INFO,
-                                                      "liblog",
-                                                      strlen("liblog"),
-                                                      ANDROID_LOG_VERBOSE)) {
-            android_log_event_int_t buffer;
-
-            header.id = LOG_ID_EVENTS;
-            buffer.header.tag = htole32(LIBLOG_LOG_TAG);
-            buffer.payload.type = EVENT_TYPE_INT;
-            buffer.payload.data = htole32(snapshot);
-
-            newVec[headerLength].iov_base = &buffer;
-            newVec[headerLength].iov_len  = sizeof(buffer);
-
-            ret = TEMP_FAILURE_RETRY(writev(sock, newVec, 2));
-            if (ret != (ssize_t)(sizeof(header) + sizeof(buffer))) {
-                atomic_fetch_add_explicit(&dropped, snapshot,
-                                          memory_order_relaxed);
-            }
-        }
-    }
-
-    header.id = logId;
-
-    for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
-        newVec[i].iov_base = vec[i - headerLength].iov_base;
-        payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
-
-        if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
-            newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
-            if (newVec[i].iov_len) {
-                ++i;
-            }
+      if (TEMP_FAILURE_RETRY(connect(sock, (struct sockaddr*)&un,
+                                     sizeof(struct sockaddr_un))) < 0) {
+        ret = -errno;
+        switch (ret) {
+          case -ENOTCONN:
+          case -ECONNREFUSED:
+          case -ENOENT:
+            i = atomic_exchange(&logdLoggerWrite.context.sock, ret);
+          /* FALLTHRU */
+          default:
             break;
         }
+        close(sock);
+      } else {
+        ret = atomic_exchange(&logdLoggerWrite.context.sock, sock);
+        if ((ret >= 0) && (ret != sock)) {
+          close(ret);
+        }
+        ret = 0;
+      }
+    }
+  }
+
+  return ret;
+}
+
+static void __logdClose(int negative_errno) {
+  int sock = atomic_exchange(&logdLoggerWrite.context.sock, negative_errno);
+  if (sock >= 0) {
+    close(sock);
+  }
+}
+
+static void logdClose() {
+  __logdClose(-EBADF);
+}
+
+static int logdAvailable(log_id_t logId) {
+  if (logId >= LOG_ID_MAX || logId == LOG_ID_KERNEL) {
+    return -EINVAL;
+  }
+  if (atomic_load(&logdLoggerWrite.context.sock) < 0) {
+    if (access("/dev/socket/logdw", W_OK) == 0) {
+      return 0;
+    }
+    return -EBADF;
+  }
+  return 1;
+}
+
+static int logdWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                     size_t nr) {
+  ssize_t ret;
+  int sock;
+  static const unsigned headerLength = 1;
+  struct iovec newVec[nr + headerLength];
+  android_log_header_t header;
+  size_t i, payloadSize;
+  static atomic_int_fast32_t dropped;
+  static atomic_int_fast32_t droppedSecurity;
+
+  sock = atomic_load(&logdLoggerWrite.context.sock);
+  if (sock < 0) switch (sock) {
+      case -ENOTCONN:
+      case -ECONNREFUSED:
+      case -ENOENT:
+        break;
+      default:
+        return -EBADF;
     }
 
+  /* logd, after initialization and priv drop */
+  if (__android_log_uid() == AID_LOGD) {
     /*
-     * The write below could be lost, but will never block.
-     *
-     * ENOTCONN occurs if logd has died.
-     * ENOENT occurs if logd is not running and socket is missing.
-     * ECONNREFUSED occurs if we can not reconnect to logd.
-     * EAGAIN occurs if logd is overloaded.
+     * ignore log messages we send to ourself (logd).
+     * Such log messages are often generated by libraries we depend on
+     * which use standard Android logging.
      */
-    if (sock < 0) {
-        ret = sock;
-    } else {
-        ret = TEMP_FAILURE_RETRY(writev(sock, newVec, i));
-        if (ret < 0) {
-            ret = -errno;
-        }
+    return 0;
+  }
+
+  /*
+   *  struct {
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
+
+  header.tid = gettid();
+  header.realtime.tv_sec = ts->tv_sec;
+  header.realtime.tv_nsec = ts->tv_nsec;
+
+  newVec[0].iov_base = (unsigned char*)&header;
+  newVec[0].iov_len = sizeof(header);
+
+  if (sock >= 0) {
+    int32_t snapshot =
+        atomic_exchange_explicit(&droppedSecurity, 0, memory_order_relaxed);
+    if (snapshot) {
+      android_log_event_int_t buffer;
+
+      header.id = LOG_ID_SECURITY;
+      buffer.header.tag = htole32(LIBLOG_LOG_TAG);
+      buffer.payload.type = EVENT_TYPE_INT;
+      buffer.payload.data = htole32(snapshot);
+
+      newVec[headerLength].iov_base = &buffer;
+      newVec[headerLength].iov_len = sizeof(buffer);
+
+      ret = TEMP_FAILURE_RETRY(writev(sock, newVec, 2));
+      if (ret != (ssize_t)(sizeof(header) + sizeof(buffer))) {
+        atomic_fetch_add_explicit(&droppedSecurity, snapshot,
+                                  memory_order_relaxed);
+      }
     }
-    switch(ret) {
+    snapshot = atomic_exchange_explicit(&dropped, 0, memory_order_relaxed);
+    if (snapshot &&
+        __android_log_is_loggable_len(ANDROID_LOG_INFO, "liblog",
+                                      strlen("liblog"), ANDROID_LOG_VERBOSE)) {
+      android_log_event_int_t buffer;
+
+      header.id = LOG_ID_EVENTS;
+      buffer.header.tag = htole32(LIBLOG_LOG_TAG);
+      buffer.payload.type = EVENT_TYPE_INT;
+      buffer.payload.data = htole32(snapshot);
+
+      newVec[headerLength].iov_base = &buffer;
+      newVec[headerLength].iov_len = sizeof(buffer);
+
+      ret = TEMP_FAILURE_RETRY(writev(sock, newVec, 2));
+      if (ret != (ssize_t)(sizeof(header) + sizeof(buffer))) {
+        atomic_fetch_add_explicit(&dropped, snapshot, memory_order_relaxed);
+      }
+    }
+  }
+
+  header.id = logId;
+
+  for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
+    newVec[i].iov_base = vec[i - headerLength].iov_base;
+    payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
+
+    if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
+      newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
+      if (newVec[i].iov_len) {
+        ++i;
+      }
+      break;
+    }
+  }
+
+  /*
+   * The write below could be lost, but will never block.
+   *
+   * ENOTCONN occurs if logd has died.
+   * ENOENT occurs if logd is not running and socket is missing.
+   * ECONNREFUSED occurs if we can not reconnect to logd.
+   * EAGAIN occurs if logd is overloaded.
+   */
+  if (sock < 0) {
+    ret = sock;
+  } else {
+    ret = TEMP_FAILURE_RETRY(writev(sock, newVec, i));
+    if (ret < 0) {
+      ret = -errno;
+    }
+  }
+  switch (ret) {
     case -ENOTCONN:
     case -ECONNREFUSED:
     case -ENOENT:
-        if (__android_log_trylock()) {
-            return ret; /* in a signal handler? try again when less stressed */
-        }
-        __logdClose(ret);
-        ret = logdOpen();
-        __android_log_unlock();
+      if (__android_log_trylock()) {
+        return ret; /* in a signal handler? try again when less stressed */
+      }
+      __logdClose(ret);
+      ret = logdOpen();
+      __android_log_unlock();
 
-        if (ret < 0) {
-            return ret;
-        }
+      if (ret < 0) {
+        return ret;
+      }
 
-        ret = TEMP_FAILURE_RETRY(writev(
-                atomic_load(&logdLoggerWrite.context.sock), newVec, i));
-        if (ret < 0) {
-            ret = -errno;
-        }
-        /* FALLTHRU */
+      ret = TEMP_FAILURE_RETRY(
+          writev(atomic_load(&logdLoggerWrite.context.sock), newVec, i));
+      if (ret < 0) {
+        ret = -errno;
+      }
+    /* FALLTHRU */
     default:
-        break;
-    }
+      break;
+  }
 
-    if (ret > (ssize_t)sizeof(header)) {
-        ret -= sizeof(header);
-    } else if (ret == -EAGAIN) {
-        atomic_fetch_add_explicit(&dropped, 1, memory_order_relaxed);
-        if (logId == LOG_ID_SECURITY) {
-            atomic_fetch_add_explicit(&droppedSecurity, 1,
-                                      memory_order_relaxed);
-        }
+  if (ret > (ssize_t)sizeof(header)) {
+    ret -= sizeof(header);
+  } else if (ret == -EAGAIN) {
+    atomic_fetch_add_explicit(&dropped, 1, memory_order_relaxed);
+    if (logId == LOG_ID_SECURITY) {
+      atomic_fetch_add_explicit(&droppedSecurity, 1, memory_order_relaxed);
     }
+  }
 
-    return ret;
+  return ret;
 }
diff --git a/liblog/logger.h b/liblog/logger.h
index d94cd14..246b33c 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -30,25 +30,25 @@
 
 /* Union, sock or fd of zero is not allowed unless static initialized */
 union android_log_context {
-  void *private;
+  void* priv;
   atomic_int sock;
   atomic_int fd;
-  struct listnode *node;
+  struct listnode* node;
   atomic_uintptr_t atomic_pointer;
 };
 
 struct android_log_transport_write {
   struct listnode node;
-  const char *name; /* human name to describe the transport */
-  unsigned logMask; /* mask cache of available() success */
+  const char* name;                  /* human name to describe the transport */
+  unsigned logMask;                  /* mask cache of available() success */
   union android_log_context context; /* Initialized by static allocation */
 
   int (*available)(log_id_t logId); /* Does not cause resources to be taken */
   int (*open)();   /* can be called multiple times, reusing current resources */
   void (*close)(); /* free up resources */
   /* write log to transport, returns number of bytes propagated, or -errno */
-  int (*write)(log_id_t logId, struct timespec *ts,
-               struct iovec *vec, size_t nr);
+  int (*write)(log_id_t logId, struct timespec* ts, struct iovec* vec,
+               size_t nr);
 };
 
 struct android_log_logger_list;
@@ -57,45 +57,44 @@
 
 struct android_log_transport_read {
   struct listnode node;
-  const char *name; /* human name to describe the transport */
+  const char* name; /* human name to describe the transport */
 
   /* Does not cause resources to be taken */
   int (*available)(log_id_t logId);
-  int (*version)(struct android_log_logger *logger,
-                 struct android_log_transport_context *transp);
+  int (*version)(struct android_log_logger* logger,
+                 struct android_log_transport_context* transp);
   /* Release resources taken by the following interfaces */
-  void (*close)(struct android_log_logger_list *logger_list,
-                struct android_log_transport_context *transp);
+  void (*close)(struct android_log_logger_list* logger_list,
+                struct android_log_transport_context* transp);
   /*
    * Expect all to instantiate open automagically on any call,
    * so we do not have an explicit open call.
    */
-  int (*read)(struct android_log_logger_list *logger_list,
-              struct android_log_transport_context *transp,
-              struct log_msg *log_msg);
+  int (*read)(struct android_log_logger_list* logger_list,
+              struct android_log_transport_context* transp,
+              struct log_msg* log_msg);
   /* Must only be called if not ANDROID_LOG_NONBLOCK (blocking) */
-  int (*poll)(struct android_log_logger_list *logger_list,
-              struct android_log_transport_context *transp);
+  int (*poll)(struct android_log_logger_list* logger_list,
+              struct android_log_transport_context* transp);
 
-  int (*clear)(struct android_log_logger *logger,
-               struct android_log_transport_context *transp);
-  ssize_t (*setSize)(struct android_log_logger *logger,
-                     struct android_log_transport_context *transp,
-                     size_t size);
-  ssize_t (*getSize)(struct android_log_logger *logger,
-                     struct android_log_transport_context *transp);
-  ssize_t (*getReadableSize)(struct android_log_logger *logger,
-                             struct android_log_transport_context *transp);
+  int (*clear)(struct android_log_logger* logger,
+               struct android_log_transport_context* transp);
+  ssize_t (*setSize)(struct android_log_logger* logger,
+                     struct android_log_transport_context* transp, size_t size);
+  ssize_t (*getSize)(struct android_log_logger* logger,
+                     struct android_log_transport_context* transp);
+  ssize_t (*getReadableSize)(struct android_log_logger* logger,
+                             struct android_log_transport_context* transp);
 
-  ssize_t (*getPrune)(struct android_log_logger_list *logger_list,
-                      struct android_log_transport_context *transp,
-                      char *buf, size_t len);
-  ssize_t (*setPrune)(struct android_log_logger_list *logger_list,
-                      struct android_log_transport_context *transp,
-                      char *buf, size_t len);
-  ssize_t (*getStats)(struct android_log_logger_list *logger_list,
-                      struct android_log_transport_context *transp,
-                      char *buf, size_t len);
+  ssize_t (*getPrune)(struct android_log_logger_list* logger_list,
+                      struct android_log_transport_context* transp, char* buf,
+                      size_t len);
+  ssize_t (*setPrune)(struct android_log_logger_list* logger_list,
+                      struct android_log_transport_context* transp, char* buf,
+                      size_t len);
+  ssize_t (*getStats)(struct android_log_logger_list* logger_list,
+                      struct android_log_transport_context* transp, char* buf,
+                      size_t len);
 };
 
 struct android_log_logger_list {
@@ -110,7 +109,7 @@
 
 struct android_log_logger {
   struct listnode node;
-  struct android_log_logger_list *parent;
+  struct android_log_logger_list* parent;
 
   log_id_t logId;
 };
@@ -118,34 +117,32 @@
 struct android_log_transport_context {
   struct listnode node;
   union android_log_context context; /* zero init per-transport context */
-  struct android_log_logger_list *parent;
+  struct android_log_logger_list* parent;
 
-  struct android_log_transport_read *transport;
+  struct android_log_transport_read* transport;
   unsigned logMask;      /* mask of requested log buffers */
   int ret;               /* return value associated with following data */
   struct log_msg logMsg; /* peek at upcoming data, valid if logMsg.len != 0 */
 };
 
 /* assumes caller has structures read-locked, single threaded, or fenced */
-#define transport_context_for_each(transp, logger_list)              \
-  for ((transp) = node_to_item((logger_list)->transport.next,        \
-                             struct android_log_transport_context,   \
-                             node);                                  \
-       ((transp) != node_to_item(&(logger_list)->transport,          \
-                               struct android_log_transport_context, \
-                               node)) &&                             \
-           ((transp)->parent == (logger_list));                      \
-       (transp) = node_to_item((transp)->node.next,                  \
-                             struct android_log_transport_context, node))
+#define transport_context_for_each(transp, logger_list)                          \
+  for ((transp) = node_to_item((logger_list)->transport.next,                    \
+                               struct android_log_transport_context, node);      \
+       ((transp) != node_to_item(&(logger_list)->transport,                      \
+                                 struct android_log_transport_context, node)) && \
+       ((transp)->parent == (logger_list));                                      \
+       (transp) = node_to_item((transp)->node.next,                              \
+                               struct android_log_transport_context, node))
 
 #define logger_for_each(logp, logger_list)                          \
-    for ((logp) = node_to_item((logger_list)->logger.next,          \
+  for ((logp) = node_to_item((logger_list)->logger.next,            \
                              struct android_log_logger, node);      \
-         ((logp) != node_to_item(&(logger_list)->logger,            \
+       ((logp) != node_to_item(&(logger_list)->logger,              \
                                struct android_log_logger, node)) && \
-             ((logp)->parent == (logger_list));                     \
-         (logp) = node_to_item((logp)->node.next,                   \
-                             struct android_log_logger, node))
+       ((logp)->parent == (logger_list));                           \
+       (logp) =                                                     \
+           node_to_item((logp)->node.next, struct android_log_logger, node))
 
 /*
  *    Global list of log readers.
@@ -168,35 +165,35 @@
 #endif
 
 /* Must be called with logger_list_rdlock() or logger_list_wrlock() held */
-#define logger_list_for_each(logger_list)                              \
-    for ((logger_list) = node_to_item(&__android_log_readers,          \
-                                      struct android_log_logger_list,  \
-                                      node);                           \
-         (logger_list) != node_to_item(&__android_log_readers,         \
-                                       struct android_log_logger_list, \
-                                       node) &&                        \
-         (logger_list) != node_to_item((logger_list)->node.next,       \
-                                       struct android_log_logger_list, \
-                                       node);                          \
-         (logger_list) = node_to_item((logger_list)->node.next,        \
-                                      struct android_log_logger_list,  \
-                                      node))
+#define logger_list_for_each(logger_list)                                     \
+  for ((logger_list) = node_to_item(&__android_log_readers,                   \
+                                    struct android_log_logger_list, node);    \
+       (logger_list) != node_to_item(&__android_log_readers,                  \
+                                     struct android_log_logger_list, node) && \
+       (logger_list) != node_to_item((logger_list)->node.next,                \
+                                     struct android_log_logger_list, node);   \
+       (logger_list) = node_to_item((logger_list)->node.next,                 \
+                                    struct android_log_logger_list, node))
 
 /* OS specific dribs and drabs */
 
 #if defined(_WIN32)
 #include <private/android_filesystem_config.h>
 typedef uint32_t uid_t;
-static inline uid_t __android_log_uid() { return AID_SYSTEM; }
+static inline uid_t __android_log_uid() {
+  return AID_SYSTEM;
+}
 #else
-static inline uid_t __android_log_uid() { return getuid(); }
+static inline uid_t __android_log_uid() {
+  return getuid();
+}
 #endif
 
 LIBLOG_HIDDEN void __android_log_lock();
 LIBLOG_HIDDEN int __android_log_trylock();
 LIBLOG_HIDDEN void __android_log_unlock();
 
-LIBLOG_HIDDEN int __android_log_frontend;
+LIBLOG_HIDDEN int __android_log_transport;
 
 __END_DECLS
 
diff --git a/liblog/logger_lock.c b/liblog/logger_lock.c
index 14feee0..d4e3a75 100644
--- a/liblog/logger_lock.c
+++ b/liblog/logger_lock.c
@@ -28,29 +28,26 @@
 static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER;
 #endif
 
-LIBLOG_HIDDEN void __android_log_lock()
-{
+LIBLOG_HIDDEN void __android_log_lock() {
 #if !defined(_WIN32)
-    /*
-     * If we trigger a signal handler in the middle of locked activity and the
-     * signal handler logs a message, we could get into a deadlock state.
-     */
-    pthread_mutex_lock(&log_init_lock);
+  /*
+   * If we trigger a signal handler in the middle of locked activity and the
+   * signal handler logs a message, we could get into a deadlock state.
+   */
+  pthread_mutex_lock(&log_init_lock);
 #endif
 }
 
-LIBLOG_HIDDEN int __android_log_trylock()
-{
+LIBLOG_HIDDEN int __android_log_trylock() {
 #if !defined(_WIN32)
-    return pthread_mutex_trylock(&log_init_lock);
+  return pthread_mutex_trylock(&log_init_lock);
 #else
-    return 0;
+  return 0;
 #endif
 }
 
-LIBLOG_HIDDEN void __android_log_unlock()
-{
+LIBLOG_HIDDEN void __android_log_unlock() {
 #if !defined(_WIN32)
-    pthread_mutex_unlock(&log_init_lock);
+  pthread_mutex_unlock(&log_init_lock);
 #endif
 }
diff --git a/liblog/logger_name.c b/liblog/logger_name.c
index 5c4feaf..a5a83e0 100644
--- a/liblog/logger_name.c
+++ b/liblog/logger_name.c
@@ -21,44 +21,44 @@
 #include "log_portability.h"
 
 /* In the future, we would like to make this list extensible */
-static const char *LOG_NAME[LOG_ID_MAX] = {
-    [LOG_ID_MAIN] = "main",
-    [LOG_ID_RADIO] = "radio",
-    [LOG_ID_EVENTS] = "events",
-    [LOG_ID_SYSTEM] = "system",
-    [LOG_ID_CRASH] = "crash",
-    [LOG_ID_SECURITY] = "security",
-    [LOG_ID_KERNEL] = "kernel",
+static const char* LOG_NAME[LOG_ID_MAX] = {
+  /* clang-format off */
+  [LOG_ID_MAIN] = "main",
+  [LOG_ID_RADIO] = "radio",
+  [LOG_ID_EVENTS] = "events",
+  [LOG_ID_SYSTEM] = "system",
+  [LOG_ID_CRASH] = "crash",
+  [LOG_ID_SECURITY] = "security",
+  [LOG_ID_KERNEL] = "kernel",
+  /* clang-format on */
 };
 
-LIBLOG_ABI_PUBLIC const char *android_log_id_to_name(log_id_t log_id)
-{
-    if (log_id >= LOG_ID_MAX) {
-        log_id = LOG_ID_MAIN;
-    }
-    return LOG_NAME[log_id];
+LIBLOG_ABI_PUBLIC const char* android_log_id_to_name(log_id_t log_id) {
+  if (log_id >= LOG_ID_MAX) {
+    log_id = LOG_ID_MAIN;
+  }
+  return LOG_NAME[log_id];
 }
 
-LIBLOG_ABI_PUBLIC log_id_t android_name_to_log_id(const char *logName)
-{
-    const char *b;
-    int ret;
+LIBLOG_ABI_PUBLIC log_id_t android_name_to_log_id(const char* logName) {
+  const char* b;
+  int ret;
 
-    if (!logName) {
-        return -1; /* NB: log_id_t is unsigned */
-    }
-    b = strrchr(logName, '/');
-    if (!b) {
-        b = logName;
-    } else {
-        ++b;
-    }
+  if (!logName) {
+    return -1; /* NB: log_id_t is unsigned */
+  }
+  b = strrchr(logName, '/');
+  if (!b) {
+    b = logName;
+  } else {
+    ++b;
+  }
 
-    for(ret = LOG_ID_MIN; ret < LOG_ID_MAX; ++ret) {
-        const char *l = LOG_NAME[ret];
-        if (l && !strcmp(b, l)) {
-            return ret;
-        }
+  for (ret = LOG_ID_MIN; ret < LOG_ID_MAX; ++ret) {
+    const char* l = LOG_NAME[ret];
+    if (l && !strcmp(b, l)) {
+      return ret;
     }
-    return -1;   /* should never happen */
+  }
+  return -1; /* should never happen */
 }
diff --git a/liblog/logger_read.c b/liblog/logger_read.c
index 7e50a23..0fd6efa 100644
--- a/liblog/logger_read.c
+++ b/liblog/logger_read.c
@@ -33,135 +33,128 @@
 
 /* android_logger_alloc unimplemented, no use case */
 /* android_logger_free not exported */
-static void android_logger_free(struct logger *logger)
-{
-    struct android_log_logger *logger_internal =
-            (struct android_log_logger *)logger;
+static void android_logger_free(struct logger* logger) {
+  struct android_log_logger* logger_internal =
+      (struct android_log_logger*)logger;
 
-    if (!logger_internal) {
-        return;
-    }
+  if (!logger_internal) {
+    return;
+  }
 
-    list_remove(&logger_internal->node);
+  list_remove(&logger_internal->node);
 
-    free(logger_internal);
+  free(logger_internal);
 }
 
 /* android_logger_alloc unimplemented, no use case */
 
 /* method for getting the associated sublog id */
-LIBLOG_ABI_PUBLIC log_id_t android_logger_get_id(struct logger *logger)
-{
-    return ((struct android_log_logger *)logger)->logId;
+LIBLOG_ABI_PUBLIC log_id_t android_logger_get_id(struct logger* logger) {
+  return ((struct android_log_logger*)logger)->logId;
 }
 
-static int init_transport_context(struct android_log_logger_list *logger_list)
-{
-    struct android_log_transport_read *transport;
-    struct listnode *node;
+static int init_transport_context(struct android_log_logger_list* logger_list) {
+  struct android_log_transport_read* transport;
+  struct listnode* node;
 
-    if (!logger_list) {
-        return -EINVAL;
-    }
+  if (!logger_list) {
+    return -EINVAL;
+  }
 
-    if (list_empty(&logger_list->logger)) {
-        return -EINVAL;
-    }
+  if (list_empty(&logger_list->logger)) {
+    return -EINVAL;
+  }
 
-    if (!list_empty(&logger_list->transport)) {
-        return 0;
-    }
-
-    __android_log_lock();
-    /* mini __write_to_log_initialize() to populate transports */
-    if (list_empty(&__android_log_transport_read) &&
-            list_empty(&__android_log_persist_read)) {
-        __android_log_config_read();
-    }
-    __android_log_unlock();
-
-    node = (logger_list->mode & ANDROID_LOG_PSTORE) ?
-            &__android_log_persist_read : &__android_log_transport_read;
-
-    read_transport_for_each(transport, node) {
-        struct android_log_transport_context *transp;
-        struct android_log_logger *logger;
-        unsigned logMask = 0;
-
-        logger_for_each(logger, logger_list) {
-            log_id_t logId = logger->logId;
-
-            if ((logId == LOG_ID_SECURITY) &&
-                    (__android_log_uid() != AID_SYSTEM)) {
-                continue;
-            }
-            if (transport->read &&
-                    (!transport->available ||
-                        (transport->available(logId) >= 0))) {
-                logMask |= 1 << logId;
-            }
-        }
-        if (!logMask) {
-            continue;
-        }
-        transp = calloc(1, sizeof(*transp));
-        if (!transp) {
-            return -ENOMEM;
-        }
-        transp->parent = logger_list;
-        transp->transport = transport;
-        transp->logMask = logMask;
-        transp->ret = 1;
-        list_add_tail(&logger_list->transport, &transp->node);
-    }
-    if (list_empty(&logger_list->transport)) {
-        return -ENODEV;
-    }
+  if (!list_empty(&logger_list->transport)) {
     return 0;
+  }
+
+  __android_log_lock();
+  /* mini __write_to_log_initialize() to populate transports */
+  if (list_empty(&__android_log_transport_read) &&
+      list_empty(&__android_log_persist_read)) {
+    __android_log_config_read();
+  }
+  __android_log_unlock();
+
+  node = (logger_list->mode & ANDROID_LOG_PSTORE)
+             ? &__android_log_persist_read
+             : &__android_log_transport_read;
+
+  read_transport_for_each(transport, node) {
+    struct android_log_transport_context* transp;
+    struct android_log_logger* logger;
+    unsigned logMask = 0;
+
+    logger_for_each(logger, logger_list) {
+      log_id_t logId = logger->logId;
+
+      if ((logId == LOG_ID_SECURITY) && (__android_log_uid() != AID_SYSTEM)) {
+        continue;
+      }
+      if (transport->read &&
+          (!transport->available || (transport->available(logId) >= 0))) {
+        logMask |= 1 << logId;
+      }
+    }
+    if (!logMask) {
+      continue;
+    }
+    transp = calloc(1, sizeof(*transp));
+    if (!transp) {
+      return -ENOMEM;
+    }
+    transp->parent = logger_list;
+    transp->transport = transport;
+    transp->logMask = logMask;
+    transp->ret = 1;
+    list_add_tail(&logger_list->transport, &transp->node);
+  }
+  if (list_empty(&logger_list->transport)) {
+    return -ENODEV;
+  }
+  return 0;
 }
 
-#define LOGGER_FUNCTION(logger, def, func, args...)                           \
-    ssize_t ret = -EINVAL;                                                    \
-    struct android_log_transport_context *transp;                             \
-    struct android_log_logger *logger_internal =                              \
-            (struct android_log_logger *)(logger);                            \
-                                                                              \
-    if (!logger_internal) {                                                   \
-        return ret;                                                           \
-    }                                                                         \
-    ret = init_transport_context(logger_internal->parent);                    \
-    if (ret < 0) {                                                            \
-        return ret;                                                           \
-    }                                                                         \
-                                                                              \
-    ret = (def);                                                              \
-    transport_context_for_each(transp, logger_internal->parent) {             \
-        if ((transp->logMask & (1 << logger_internal->logId)) &&              \
-                transp->transport && transp->transport->func) {               \
-            ssize_t retval = (transp->transport->func)(logger_internal,       \
-                                                       transp, ## args);      \
-            if ((ret >= 0) || (ret == (def))) {                               \
-                ret = retval;                                                 \
-            }                                                                 \
-        }                                                                     \
-    }                                                                         \
-    return ret
+#define LOGGER_FUNCTION(logger, def, func, args...)                   \
+  ssize_t ret = -EINVAL;                                              \
+  struct android_log_transport_context* transp;                       \
+  struct android_log_logger* logger_internal =                        \
+      (struct android_log_logger*)(logger);                           \
+                                                                      \
+  if (!logger_internal) {                                             \
+    return ret;                                                       \
+  }                                                                   \
+  ret = init_transport_context(logger_internal->parent);              \
+  if (ret < 0) {                                                      \
+    return ret;                                                       \
+  }                                                                   \
+                                                                      \
+  ret = (def);                                                        \
+  transport_context_for_each(transp, logger_internal->parent) {       \
+    if ((transp->logMask & (1 << logger_internal->logId)) &&          \
+        transp->transport && transp->transport->func) {               \
+      ssize_t retval =                                                \
+          (transp->transport->func)(logger_internal, transp, ##args); \
+      if ((ret >= 0) || (ret == (def))) {                             \
+        ret = retval;                                                 \
+      }                                                               \
+    }                                                                 \
+  }                                                                   \
+  return ret
 
-LIBLOG_ABI_PUBLIC int android_logger_clear(struct logger *logger)
-{
-    LOGGER_FUNCTION(logger, -ENODEV, clear);
+LIBLOG_ABI_PUBLIC int android_logger_clear(struct logger* logger) {
+  LOGGER_FUNCTION(logger, -ENODEV, clear);
 }
 
 /* returns the total size of the log's ring buffer */
-LIBLOG_ABI_PUBLIC long android_logger_get_log_size(struct logger *logger)
-{
-    LOGGER_FUNCTION(logger, -ENODEV, getSize);
+LIBLOG_ABI_PUBLIC long android_logger_get_log_size(struct logger* logger) {
+  LOGGER_FUNCTION(logger, -ENODEV, getSize);
 }
 
-LIBLOG_ABI_PUBLIC int android_logger_set_log_size(struct logger *logger,
-                                                  unsigned long size)
-{
-    LOGGER_FUNCTION(logger, -ENODEV, setSize, size);
+LIBLOG_ABI_PUBLIC int android_logger_set_log_size(struct logger* logger,
+                                                  unsigned long size) {
+  LOGGER_FUNCTION(logger, -ENODEV, setSize, size);
 }
 
 /*
@@ -169,376 +162,338 @@
  * log consumed)
  */
 LIBLOG_ABI_PUBLIC long android_logger_get_log_readable_size(
-        struct logger *logger)
-{
-    LOGGER_FUNCTION(logger, -ENODEV, getReadableSize);
+    struct logger* logger) {
+  LOGGER_FUNCTION(logger, -ENODEV, getReadableSize);
 }
 
 /*
  * returns the logger version
  */
-LIBLOG_ABI_PUBLIC int android_logger_get_log_version(struct logger *logger)
-{
-    LOGGER_FUNCTION(logger, 4, version);
+LIBLOG_ABI_PUBLIC int android_logger_get_log_version(struct logger* logger) {
+  LOGGER_FUNCTION(logger, 4, version);
 }
 
-#define LOGGER_LIST_FUNCTION(logger_list, def, func, args...)                 \
-    struct android_log_transport_context *transp;                             \
-    struct android_log_logger_list *logger_list_internal =                    \
-            (struct android_log_logger_list *)(logger_list);                  \
-                                                                              \
-    ssize_t ret = init_transport_context(logger_list_internal);               \
-    if (ret < 0) {                                                            \
-        return ret;                                                           \
-    }                                                                         \
-                                                                              \
-    ret = (def);                                                              \
-    transport_context_for_each(transp, logger_list_internal) {                \
-        if (transp->transport && (transp->transport->func)) {                 \
-            ssize_t retval = (transp->transport->func)(logger_list_internal,  \
-                                                       transp, ## args);      \
-            if ((ret >= 0) || (ret == (def))) {                               \
-                ret = retval;                                                 \
-            }                                                                 \
-        }                                                                     \
-    }                                                                         \
-    return ret
+#define LOGGER_LIST_FUNCTION(logger_list, def, func, args...)              \
+  struct android_log_transport_context* transp;                            \
+  struct android_log_logger_list* logger_list_internal =                   \
+      (struct android_log_logger_list*)(logger_list);                      \
+                                                                           \
+  ssize_t ret = init_transport_context(logger_list_internal);              \
+  if (ret < 0) {                                                           \
+    return ret;                                                            \
+  }                                                                        \
+                                                                           \
+  ret = (def);                                                             \
+  transport_context_for_each(transp, logger_list_internal) {               \
+    if (transp->transport && (transp->transport->func)) {                  \
+      ssize_t retval =                                                     \
+          (transp->transport->func)(logger_list_internal, transp, ##args); \
+      if ((ret >= 0) || (ret == (def))) {                                  \
+        ret = retval;                                                      \
+      }                                                                    \
+    }                                                                      \
+  }                                                                        \
+  return ret
 
 /*
  * returns statistics
  */
 LIBLOG_ABI_PUBLIC ssize_t android_logger_get_statistics(
-        struct logger_list *logger_list,
-        char *buf, size_t len)
-{
-    LOGGER_LIST_FUNCTION(logger_list, -ENODEV, getStats, buf, len);
+    struct logger_list* logger_list, char* buf, size_t len) {
+  LOGGER_LIST_FUNCTION(logger_list, -ENODEV, getStats, buf, len);
 }
 
 LIBLOG_ABI_PUBLIC ssize_t android_logger_get_prune_list(
-        struct logger_list *logger_list,
-        char *buf, size_t len)
-{
-    LOGGER_LIST_FUNCTION(logger_list, -ENODEV, getPrune, buf, len);
+    struct logger_list* logger_list, char* buf, size_t len) {
+  LOGGER_LIST_FUNCTION(logger_list, -ENODEV, getPrune, buf, len);
 }
 
 LIBLOG_ABI_PUBLIC int android_logger_set_prune_list(
-        struct logger_list *logger_list,
-        char *buf, size_t len)
-{
-    LOGGER_LIST_FUNCTION(logger_list, -ENODEV, setPrune, buf, len);
+    struct logger_list* logger_list, char* buf, size_t len) {
+  LOGGER_LIST_FUNCTION(logger_list, -ENODEV, setPrune, buf, len);
 }
 
-LIBLOG_HIDDEN struct listnode __android_log_readers =
-    { &__android_log_readers, &__android_log_readers };
+LIBLOG_HIDDEN struct listnode __android_log_readers = { &__android_log_readers,
+                                                        &__android_log_readers };
 #if !defined(_WIN32)
 LIBLOG_HIDDEN pthread_rwlock_t __android_log_readers_lock =
     PTHREAD_RWLOCK_INITIALIZER;
 #endif
 
-LIBLOG_ABI_PUBLIC struct logger_list *android_logger_list_alloc(
-        int mode,
-        unsigned int tail,
-        pid_t pid)
-{
-    struct android_log_logger_list *logger_list;
+LIBLOG_ABI_PUBLIC struct logger_list* android_logger_list_alloc(
+    int mode, unsigned int tail, pid_t pid) {
+  struct android_log_logger_list* logger_list;
 
-    logger_list = calloc(1, sizeof(*logger_list));
-    if (!logger_list) {
-        return NULL;
-    }
+  logger_list = calloc(1, sizeof(*logger_list));
+  if (!logger_list) {
+    return NULL;
+  }
 
-    list_init(&logger_list->logger);
-    list_init(&logger_list->transport);
-    logger_list->mode = mode;
-    logger_list->tail = tail;
-    logger_list->pid = pid;
+  list_init(&logger_list->logger);
+  list_init(&logger_list->transport);
+  logger_list->mode = mode;
+  logger_list->tail = tail;
+  logger_list->pid = pid;
 
-    logger_list_wrlock();
-    list_add_tail(&__android_log_readers, &logger_list->node);
-    logger_list_unlock();
+  logger_list_wrlock();
+  list_add_tail(&__android_log_readers, &logger_list->node);
+  logger_list_unlock();
 
-    return (struct logger_list *)logger_list;
+  return (struct logger_list*)logger_list;
 }
 
-LIBLOG_ABI_PUBLIC struct logger_list *android_logger_list_alloc_time(
-        int mode,
-        log_time start,
-        pid_t pid)
-{
-    struct android_log_logger_list *logger_list;
+LIBLOG_ABI_PUBLIC struct logger_list* android_logger_list_alloc_time(
+    int mode, log_time start, pid_t pid) {
+  struct android_log_logger_list* logger_list;
 
-    logger_list = calloc(1, sizeof(*logger_list));
-    if (!logger_list) {
-        return NULL;
-    }
+  logger_list = calloc(1, sizeof(*logger_list));
+  if (!logger_list) {
+    return NULL;
+  }
 
-    list_init(&logger_list->logger);
-    list_init(&logger_list->transport);
-    logger_list->mode = mode;
-    logger_list->start = start;
-    logger_list->pid = pid;
+  list_init(&logger_list->logger);
+  list_init(&logger_list->transport);
+  logger_list->mode = mode;
+  logger_list->start = start;
+  logger_list->pid = pid;
 
-    logger_list_wrlock();
-    list_add_tail(&__android_log_readers, &logger_list->node);
-    logger_list_unlock();
+  logger_list_wrlock();
+  list_add_tail(&__android_log_readers, &logger_list->node);
+  logger_list_unlock();
 
-    return (struct logger_list *)logger_list;
+  return (struct logger_list*)logger_list;
 }
 
 /* android_logger_list_register unimplemented, no use case */
 /* android_logger_list_unregister unimplemented, no use case */
 
 /* Open the named log and add it to the logger list */
-LIBLOG_ABI_PUBLIC struct logger *android_logger_open(
-        struct logger_list *logger_list,
-        log_id_t logId)
-{
-    struct android_log_logger_list *logger_list_internal =
-            (struct android_log_logger_list *)logger_list;
-    struct android_log_logger *logger;
+LIBLOG_ABI_PUBLIC struct logger* android_logger_open(
+    struct logger_list* logger_list, log_id_t logId) {
+  struct android_log_logger_list* logger_list_internal =
+      (struct android_log_logger_list*)logger_list;
+  struct android_log_logger* logger;
 
-    if (!logger_list_internal || (logId >= LOG_ID_MAX)) {
-        goto err;
+  if (!logger_list_internal || (logId >= LOG_ID_MAX)) {
+    goto err;
+  }
+
+  logger_for_each(logger, logger_list_internal) {
+    if (logger->logId == logId) {
+      goto ok;
     }
+  }
 
-    logger_for_each(logger, logger_list_internal) {
-        if (logger->logId == logId) {
-            goto ok;
-        }
-    }
+  logger = calloc(1, sizeof(*logger));
+  if (!logger) {
+    goto err;
+  }
 
-    logger = calloc(1, sizeof(*logger));
-    if (!logger) {
-        goto err;
-    }
+  logger->logId = logId;
+  list_add_tail(&logger_list_internal->logger, &logger->node);
+  logger->parent = logger_list_internal;
 
-    logger->logId = logId;
-    list_add_tail(&logger_list_internal->logger, &logger->node);
-    logger->parent = logger_list_internal;
+  /* Reset known transports to re-evaluate, we just added one */
+  while (!list_empty(&logger_list_internal->transport)) {
+    struct listnode* node = list_head(&logger_list_internal->transport);
+    struct android_log_transport_context* transp =
+        node_to_item(node, struct android_log_transport_context, node);
 
-    /* Reset known transports to re-evaluate, we just added one */
-    while (!list_empty(&logger_list_internal->transport)) {
-        struct listnode *node = list_head(&logger_list_internal->transport);
-        struct android_log_transport_context *transp =
-                node_to_item(node, struct android_log_transport_context, node);
-
-        list_remove(&transp->node);
-        free(transp);
-    }
-    goto ok;
+    list_remove(&transp->node);
+    free(transp);
+  }
+  goto ok;
 
 err:
-    logger = NULL;
+  logger = NULL;
 ok:
-    return (struct logger *)logger;
+  return (struct logger*)logger;
 }
 
 /* Open the single named log and make it part of a new logger list */
-LIBLOG_ABI_PUBLIC struct logger_list *android_logger_list_open(
-        log_id_t logId,
-        int mode,
-        unsigned int tail,
-        pid_t pid)
-{
-    struct logger_list *logger_list =
-            android_logger_list_alloc(mode, tail, pid);
+LIBLOG_ABI_PUBLIC struct logger_list* android_logger_list_open(
+    log_id_t logId, int mode, unsigned int tail, pid_t pid) {
+  struct logger_list* logger_list = android_logger_list_alloc(mode, tail, pid);
 
-    if (!logger_list) {
-        return NULL;
-    }
+  if (!logger_list) {
+    return NULL;
+  }
 
-    if (!android_logger_open(logger_list, logId)) {
-        android_logger_list_free(logger_list);
-        return NULL;
-    }
+  if (!android_logger_open(logger_list, logId)) {
+    android_logger_list_free(logger_list);
+    return NULL;
+  }
 
-    return logger_list;
+  return logger_list;
 }
 
 /* Validate log_msg packet, read function has already been null checked */
-static int android_transport_read(struct android_log_logger_list *logger_list,
-                                  struct android_log_transport_context *transp,
-                                  struct log_msg *log_msg)
-{
-    int ret = (*transp->transport->read)(logger_list, transp, log_msg);
+static int android_transport_read(struct android_log_logger_list* logger_list,
+                                  struct android_log_transport_context* transp,
+                                  struct log_msg* log_msg) {
+  int ret = (*transp->transport->read)(logger_list, transp, log_msg);
 
-    if (ret > (int)sizeof(*log_msg)) {
-        ret = sizeof(*log_msg);
+  if (ret > (int)sizeof(*log_msg)) {
+    ret = sizeof(*log_msg);
+  }
+
+  transp->ret = ret;
+
+  /* propagate errors, or make sure len & hdr_size members visible */
+  if (ret < (int)(sizeof(log_msg->entry.len) + sizeof(log_msg->entry.hdr_size))) {
+    if (ret >= (int)sizeof(log_msg->entry.len)) {
+      log_msg->entry.len = 0;
     }
-
-    transp->ret = ret;
-
-    /* propagate errors, or make sure len & hdr_size members visible */
-    if (ret < (int)(sizeof(log_msg->entry.len) +
-                    sizeof(log_msg->entry.hdr_size))) {
-        if (ret >= (int)sizeof(log_msg->entry.len)) {
-            log_msg->entry.len = 0;
-        }
-        return ret;
-    }
-
-    /* hdr_size correction (logger_entry -> logger_entry_v2+ conversion) */
-    if (log_msg->entry_v2.hdr_size == 0) {
-        log_msg->entry_v2.hdr_size = sizeof(struct logger_entry);
-    }
-    if ((log_msg->entry_v2.hdr_size < sizeof(log_msg->entry_v1)) ||
-            (log_msg->entry_v2.hdr_size > sizeof(log_msg->entry))) {
-        return -EINVAL;
-    }
-
-    /* len validation */
-    if (ret <= log_msg->entry_v2.hdr_size) {
-        log_msg->entry.len = 0;
-    } else {
-        log_msg->entry.len = ret - log_msg->entry_v2.hdr_size;
-    }
-
     return ret;
+  }
+
+  /* hdr_size correction (logger_entry -> logger_entry_v2+ conversion) */
+  if (log_msg->entry_v2.hdr_size == 0) {
+    log_msg->entry_v2.hdr_size = sizeof(struct logger_entry);
+  }
+  if ((log_msg->entry_v2.hdr_size < sizeof(log_msg->entry_v1)) ||
+      (log_msg->entry_v2.hdr_size > sizeof(log_msg->entry))) {
+    return -EINVAL;
+  }
+
+  /* len validation */
+  if (ret <= log_msg->entry_v2.hdr_size) {
+    log_msg->entry.len = 0;
+  } else {
+    log_msg->entry.len = ret - log_msg->entry_v2.hdr_size;
+  }
+
+  return ret;
 }
 
 /* Read from the selected logs */
-LIBLOG_ABI_PUBLIC int android_logger_list_read(struct logger_list *logger_list,
-                                               struct log_msg *log_msg)
-{
-    struct android_log_transport_context *transp;
-    struct android_log_logger_list *logger_list_internal =
-            (struct android_log_logger_list *)logger_list;
+LIBLOG_ABI_PUBLIC int android_logger_list_read(struct logger_list* logger_list,
+                                               struct log_msg* log_msg) {
+  struct android_log_transport_context* transp;
+  struct android_log_logger_list* logger_list_internal =
+      (struct android_log_logger_list*)logger_list;
 
-    int ret = init_transport_context(logger_list_internal);
-    if (ret < 0) {
-        return ret;
-    }
+  int ret = init_transport_context(logger_list_internal);
+  if (ret < 0) {
+    return ret;
+  }
 
-    /* at least one transport */
-    transp = node_to_item(logger_list_internal->transport.next,
-                          struct android_log_transport_context, node);
+  /* at least one transport */
+  transp = node_to_item(logger_list_internal->transport.next,
+                        struct android_log_transport_context, node);
 
-    /* more than one transport? */
-    if (transp->node.next != &logger_list_internal->transport) {
-        /* Poll and merge sort the entries if from multiple transports */
-        struct android_log_transport_context *oldest = NULL;
-        int ret;
-        int polled = 0;
-        do {
-            if (polled) {
-                sched_yield();
+  /* more than one transport? */
+  if (transp->node.next != &logger_list_internal->transport) {
+    /* Poll and merge sort the entries if from multiple transports */
+    struct android_log_transport_context* oldest = NULL;
+    int ret;
+    int polled = 0;
+    do {
+      if (polled) {
+        sched_yield();
+      }
+      ret = -1000;
+      polled = 0;
+      do {
+        int retval = transp->ret;
+        if ((retval > 0) && !transp->logMsg.entry.len) {
+          if (!transp->transport->read) {
+            retval = transp->ret = 0;
+          } else if ((logger_list_internal->mode & ANDROID_LOG_NONBLOCK) ||
+                     !transp->transport->poll) {
+            retval = android_transport_read(logger_list_internal, transp,
+                                            &transp->logMsg);
+          } else {
+            int pollval =
+                (*transp->transport->poll)(logger_list_internal, transp);
+            if (pollval <= 0) {
+              sched_yield();
+              pollval = (*transp->transport->poll)(logger_list_internal, transp);
             }
-            ret = -1000;
-            polled = 0;
-            do {
-                int retval = transp->ret;
-                if ((retval > 0) && !transp->logMsg.entry.len) {
-                    if (!transp->transport->read) {
-                        retval = transp->ret = 0;
-                    } else if ((logger_list_internal->mode &
-                                ANDROID_LOG_NONBLOCK) ||
-                            !transp->transport->poll) {
-                        retval = android_transport_read(
-                                logger_list_internal,
-                                transp,
-                                &transp->logMsg);
-                    } else {
-                        int pollval = (*transp->transport->poll)(
-                                logger_list_internal, transp);
-                        if (pollval <= 0) {
-                            sched_yield();
-                            pollval = (*transp->transport->poll)(
-                                    logger_list_internal, transp);
-                        }
-                        polled = 1;
-                        if (pollval < 0) {
-                            if ((pollval == -EINTR) || (pollval == -EAGAIN)) {
-                                return -EAGAIN;
-                            }
-                            retval = transp->ret = pollval;
-                        } else if (pollval > 0) {
-                            retval = android_transport_read(
-                                    logger_list_internal,
-                                    transp,
-                                    &transp->logMsg);
-                        }
-                    }
-                }
-                if (ret < retval) {
-                    ret = retval;
-                }
-                if ((transp->ret > 0) && transp->logMsg.entry.len &&
-                        (!oldest ||
-                            (oldest->logMsg.entry.sec >
-                                transp->logMsg.entry.sec) ||
-                            ((oldest->logMsg.entry.sec ==
-                                    transp->logMsg.entry.sec) &&
-                                (oldest->logMsg.entry.nsec >
-                                    transp->logMsg.entry.nsec)))) {
-                    oldest = transp;
-                }
-                transp = node_to_item(transp->node.next,
+            polled = 1;
+            if (pollval < 0) {
+              if ((pollval == -EINTR) || (pollval == -EAGAIN)) {
+                return -EAGAIN;
+              }
+              retval = transp->ret = pollval;
+            } else if (pollval > 0) {
+              retval = android_transport_read(logger_list_internal, transp,
+                                              &transp->logMsg);
+            }
+          }
+        }
+        if (ret < retval) {
+          ret = retval;
+        }
+        if ((transp->ret > 0) && transp->logMsg.entry.len &&
+            (!oldest || (oldest->logMsg.entry.sec > transp->logMsg.entry.sec) ||
+             ((oldest->logMsg.entry.sec == transp->logMsg.entry.sec) &&
+              (oldest->logMsg.entry.nsec > transp->logMsg.entry.nsec)))) {
+          oldest = transp;
+        }
+        transp = node_to_item(transp->node.next,
+                              struct android_log_transport_context, node);
+      } while (transp != node_to_item(&logger_list_internal->transport,
                                       struct android_log_transport_context,
-                                      node);
-            } while (transp != node_to_item(
-                    &logger_list_internal->transport,
-                    struct android_log_transport_context,
-                    node));
-            if (!oldest &&
-                    (logger_list_internal->mode & ANDROID_LOG_NONBLOCK)) {
-                return (ret < 0) ? ret : -EAGAIN;
-            }
-            transp = node_to_item(logger_list_internal->transport.next,
-                                  struct android_log_transport_context, node);
-        } while (!oldest && (ret > 0));
-        if (!oldest) {
-            return ret;
-        }
-        // ret is a positive value less than sizeof(struct log_msg)
-        ret = oldest->ret;
-        if (ret < oldest->logMsg.entry.hdr_size) {
-            // zero truncated header fields.
-            memset(log_msg, 0,
-                   (oldest->logMsg.entry.hdr_size > sizeof(oldest->logMsg) ?
-                       sizeof(oldest->logMsg) :
-                       oldest->logMsg.entry.hdr_size));
-        }
-        memcpy(log_msg, &oldest->logMsg, ret);
-        oldest->logMsg.entry.len = 0; /* Mark it as copied */
-        return ret;
+                                      node));
+      if (!oldest && (logger_list_internal->mode & ANDROID_LOG_NONBLOCK)) {
+        return (ret < 0) ? ret : -EAGAIN;
+      }
+      transp = node_to_item(logger_list_internal->transport.next,
+                            struct android_log_transport_context, node);
+    } while (!oldest && (ret > 0));
+    if (!oldest) {
+      return ret;
     }
+    // ret is a positive value less than sizeof(struct log_msg)
+    ret = oldest->ret;
+    if (ret < oldest->logMsg.entry.hdr_size) {
+      // zero truncated header fields.
+      memset(log_msg, 0,
+             (oldest->logMsg.entry.hdr_size > sizeof(oldest->logMsg)
+                  ? sizeof(oldest->logMsg)
+                  : oldest->logMsg.entry.hdr_size));
+    }
+    memcpy(log_msg, &oldest->logMsg, ret);
+    oldest->logMsg.entry.len = 0; /* Mark it as copied */
+    return ret;
+  }
 
-    /* if only one, no need to copy into transport_context and merge-sort */
-    return android_transport_read(logger_list_internal, transp, log_msg);
+  /* if only one, no need to copy into transport_context and merge-sort */
+  return android_transport_read(logger_list_internal, transp, log_msg);
 }
 
 /* Close all the logs */
-LIBLOG_ABI_PUBLIC void android_logger_list_free(struct logger_list *logger_list)
-{
-    struct android_log_logger_list *logger_list_internal =
-            (struct android_log_logger_list *)logger_list;
+LIBLOG_ABI_PUBLIC void android_logger_list_free(struct logger_list* logger_list) {
+  struct android_log_logger_list* logger_list_internal =
+      (struct android_log_logger_list*)logger_list;
 
-    if (logger_list_internal == NULL) {
-        return;
+  if (logger_list_internal == NULL) {
+    return;
+  }
+
+  logger_list_wrlock();
+  list_remove(&logger_list_internal->node);
+  logger_list_unlock();
+
+  while (!list_empty(&logger_list_internal->transport)) {
+    struct listnode* node = list_head(&logger_list_internal->transport);
+    struct android_log_transport_context* transp =
+        node_to_item(node, struct android_log_transport_context, node);
+
+    if (transp->transport && transp->transport->close) {
+      (*transp->transport->close)(logger_list_internal, transp);
     }
+    list_remove(&transp->node);
+    free(transp);
+  }
 
-    logger_list_wrlock();
-    list_remove(&logger_list_internal->node);
-    logger_list_unlock();
+  while (!list_empty(&logger_list_internal->logger)) {
+    struct listnode* node = list_head(&logger_list_internal->logger);
+    struct android_log_logger* logger =
+        node_to_item(node, struct android_log_logger, node);
+    android_logger_free((struct logger*)logger);
+  }
 
-    while (!list_empty(&logger_list_internal->transport)) {
-        struct listnode *node = list_head(&logger_list_internal->transport);
-        struct android_log_transport_context *transp =
-                node_to_item(node, struct android_log_transport_context, node);
-
-        if (transp->transport && transp->transport->close) {
-            (*transp->transport->close)(logger_list_internal, transp);
-        }
-        list_remove(&transp->node);
-        free(transp);
-    }
-
-    while (!list_empty(&logger_list_internal->logger)) {
-        struct listnode *node = list_head(&logger_list_internal->logger);
-        struct android_log_logger *logger =
-                node_to_item(node, struct android_log_logger, node);
-        android_logger_free((struct logger *)logger);
-    }
-
-    free(logger_list_internal);
+  free(logger_list_internal);
 }
diff --git a/liblog/logger_write.c b/liblog/logger_write.c
index e149e68..d322c0f 100644
--- a/liblog/logger_write.c
+++ b/liblog/logger_write.c
@@ -25,7 +25,7 @@
 #endif
 
 #include <log/event_tag_map.h>
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 #include <private/android_filesystem_config.h>
 #include <private/android_logger.h>
 
@@ -36,8 +36,9 @@
 
 #define LOG_BUF_SIZE 1024
 
-static int __write_to_log_init(log_id_t, struct iovec *vec, size_t nr);
-static int (*write_to_log)(log_id_t, struct iovec *vec, size_t nr) = __write_to_log_init;
+static int __write_to_log_init(log_id_t, struct iovec* vec, size_t nr);
+static int (*write_to_log)(log_id_t, struct iovec* vec,
+                           size_t nr) = __write_to_log_init;
 
 /*
  * This is used by the C++ code to decide if it should write logs through
@@ -45,91 +46,84 @@
  * the simulator rather than a desktop tool and want to use the device.
  */
 static enum {
-    kLogUninitialized, kLogNotAvailable, kLogAvailable
+  kLogUninitialized,
+  kLogNotAvailable,
+  kLogAvailable
 } g_log_status = kLogUninitialized;
 
-static int check_log_uid_permissions()
-{
+static int check_log_uid_permissions() {
 #if defined(__ANDROID__)
-    uid_t uid = __android_log_uid();
+  uid_t uid = __android_log_uid();
 
-    /* Matches clientHasLogCredentials() in logd */
+  /* Matches clientHasLogCredentials() in logd */
+  if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
+    uid = geteuid();
     if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
-        uid = geteuid();
-        if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)) {
-            gid_t gid = getgid();
-            if ((gid != AID_SYSTEM) &&
-                    (gid != AID_ROOT) &&
-                    (gid != AID_LOG)) {
-                gid = getegid();
-                if ((gid != AID_SYSTEM) &&
-                        (gid != AID_ROOT) &&
-                        (gid != AID_LOG)) {
-                    int num_groups;
-                    gid_t *groups;
+      gid_t gid = getgid();
+      if ((gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
+        gid = getegid();
+        if ((gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
+          int num_groups;
+          gid_t* groups;
 
-                    num_groups = getgroups(0, NULL);
-                    if (num_groups <= 0) {
-                        return -EPERM;
-                    }
-                    groups = calloc(num_groups, sizeof(gid_t));
-                    if (!groups) {
-                        return -ENOMEM;
-                    }
-                    num_groups = getgroups(num_groups, groups);
-                    while (num_groups > 0) {
-                        if (groups[num_groups - 1] == AID_LOG) {
-                            break;
-                        }
-                        --num_groups;
-                    }
-                    free(groups);
-                    if (num_groups <= 0) {
-                        return -EPERM;
-                    }
-                }
+          num_groups = getgroups(0, NULL);
+          if (num_groups <= 0) {
+            return -EPERM;
+          }
+          groups = calloc(num_groups, sizeof(gid_t));
+          if (!groups) {
+            return -ENOMEM;
+          }
+          num_groups = getgroups(num_groups, groups);
+          while (num_groups > 0) {
+            if (groups[num_groups - 1] == AID_LOG) {
+              break;
             }
+            --num_groups;
+          }
+          free(groups);
+          if (num_groups <= 0) {
+            return -EPERM;
+          }
         }
+      }
     }
+  }
 #endif
-    return 0;
+  return 0;
 }
 
 static void __android_log_cache_available(
-        struct android_log_transport_write *node)
-{
-    size_t i;
+    struct android_log_transport_write* node) {
+  size_t i;
 
-    if (node->logMask) {
-        return;
-    }
+  if (node->logMask) {
+    return;
+  }
 
-    for (i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-        if (node->write &&
-                (i != LOG_ID_KERNEL) &&
-                ((i != LOG_ID_SECURITY) ||
-                    (check_log_uid_permissions() == 0)) &&
-                (!node->available || ((*node->available)(i) >= 0))) {
-            node->logMask |= 1 << i;
-        }
+  for (i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
+    if (node->write && (i != LOG_ID_KERNEL) &&
+        ((i != LOG_ID_SECURITY) || (check_log_uid_permissions() == 0)) &&
+        (!node->available || ((*node->available)(i) >= 0))) {
+      node->logMask |= 1 << i;
     }
+  }
 }
 
-LIBLOG_ABI_PUBLIC int __android_log_dev_available()
-{
-    struct android_log_transport_write *node;
+LIBLOG_ABI_PUBLIC int __android_log_dev_available() {
+  struct android_log_transport_write* node;
 
-    if (list_empty(&__android_log_transport_write)) {
-        return kLogUninitialized;
-    }
+  if (list_empty(&__android_log_transport_write)) {
+    return kLogUninitialized;
+  }
 
-    write_transport_for_each(node, &__android_log_transport_write) {
-        __android_log_cache_available(node);
-        if (node->logMask) {
-            return kLogAvailable;
-        }
+  write_transport_for_each(node, &__android_log_transport_write) {
+    __android_log_cache_available(node);
+    if (node->logMask) {
+      return kLogAvailable;
     }
-    return kLogNotAvailable;
+  }
+  return kLogNotAvailable;
 }
 
 #if defined(__ANDROID__)
@@ -139,423 +133,400 @@
 /*
  * Release any logger resources. A new log write will immediately re-acquire.
  */
-LIBLOG_ABI_PUBLIC void __android_log_close()
-{
-    struct android_log_transport_write *transport;
+LIBLOG_ABI_PUBLIC void __android_log_close() {
+  struct android_log_transport_write* transport;
 #if defined(__ANDROID__)
-    EventTagMap *m;
+  EventTagMap* m;
 #endif
 
-    __android_log_lock();
+  __android_log_lock();
 
-    write_to_log = __write_to_log_init;
+  write_to_log = __write_to_log_init;
 
-    /*
-     * Threads that are actively writing at this point are not held back
-     * by a lock and are at risk of dropping the messages with a return code
-     * -EBADF. Prefer to return error code than add the overhead of a lock to
-     * each log writing call to guarantee delivery. In addition, anyone
-     * calling this is doing so to release the logging resources and shut down,
-     * for them to do so with outstanding log requests in other threads is a
-     * disengenuous use of this function.
-     */
+  /*
+   * Threads that are actively writing at this point are not held back
+   * by a lock and are at risk of dropping the messages with a return code
+   * -EBADF. Prefer to return error code than add the overhead of a lock to
+   * each log writing call to guarantee delivery. In addition, anyone
+   * calling this is doing so to release the logging resources and shut down,
+   * for them to do so with outstanding log requests in other threads is a
+   * disengenuous use of this function.
+   */
 
-    write_transport_for_each(transport, &__android_log_persist_write) {
-        if (transport->close) {
-            (*transport->close)();
-        }
+  write_transport_for_each(transport, &__android_log_persist_write) {
+    if (transport->close) {
+      (*transport->close)();
     }
+  }
 
-    write_transport_for_each(transport, &__android_log_transport_write) {
-        if (transport->close) {
-            (*transport->close)();
-        }
+  write_transport_for_each(transport, &__android_log_transport_write) {
+    if (transport->close) {
+      (*transport->close)();
     }
+  }
 
-    __android_log_config_write_close();
+  __android_log_config_write_close();
 
 #if defined(__ANDROID__)
-    /*
-     * Additional risk here somewhat mitigated by immediately unlock flushing
-     * the processor cache. The multi-threaded race that we choose to accept,
-     * to minimize locking, is an atomic_load in a writer picking up a value
-     * just prior to entering this routine. There will be an use after free.
-     *
-     * Again, anyone calling this is doing so to release the logging resources
-     * is most probably going to quiesce then shut down; or to restart after
-     * a fork so the risk should be non-existent. For this reason we
-     * choose a mitigation stance for efficiency instead of incuring the cost
-     * of a lock for every log write.
-     */
-    m = (EventTagMap *)atomic_exchange(&tagMap, (uintptr_t)0);
+  /*
+   * Additional risk here somewhat mitigated by immediately unlock flushing
+   * the processor cache. The multi-threaded race that we choose to accept,
+   * to minimize locking, is an atomic_load in a writer picking up a value
+   * just prior to entering this routine. There will be an use after free.
+   *
+   * Again, anyone calling this is doing so to release the logging resources
+   * is most probably going to quiesce then shut down; or to restart after
+   * a fork so the risk should be non-existent. For this reason we
+   * choose a mitigation stance for efficiency instead of incuring the cost
+   * of a lock for every log write.
+   */
+  m = (EventTagMap*)atomic_exchange(&tagMap, (uintptr_t)0);
 #endif
 
-    __android_log_unlock();
+  __android_log_unlock();
 
 #if defined(__ANDROID__)
-    if (m != (EventTagMap *)(uintptr_t)-1LL) android_closeEventTagMap(m);
+  if (m != (EventTagMap*)(uintptr_t)-1LL) android_closeEventTagMap(m);
 #endif
-
 }
 
 /* log_init_lock assumed */
-static int __write_to_log_initialize()
-{
-    struct android_log_transport_write *transport;
-    struct listnode *n;
-    int i = 0, ret = 0;
+static int __write_to_log_initialize() {
+  struct android_log_transport_write* transport;
+  struct listnode* n;
+  int i = 0, ret = 0;
 
-    __android_log_config_write();
-    write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
-        __android_log_cache_available(transport);
-        if (!transport->logMask) {
-            list_remove(&transport->node);
-            continue;
-        }
-        if (!transport->open || ((*transport->open)() < 0)) {
-            if (transport->close) {
-                (*transport->close)();
-            }
-            list_remove(&transport->node);
-            continue;
-        }
-        ++ret;
+  __android_log_config_write();
+  write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
+    __android_log_cache_available(transport);
+    if (!transport->logMask) {
+      list_remove(&transport->node);
+      continue;
     }
-    write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
-        __android_log_cache_available(transport);
-        if (!transport->logMask) {
-            list_remove(&transport->node);
-            continue;
-        }
-        if (!transport->open || ((*transport->open)() < 0)) {
-            if (transport->close) {
-                (*transport->close)();
-            }
-            list_remove(&transport->node);
-            continue;
-        }
-        ++i;
+    if (!transport->open || ((*transport->open)() < 0)) {
+      if (transport->close) {
+        (*transport->close)();
+      }
+      list_remove(&transport->node);
+      continue;
     }
-    if (!ret && !i) {
-        return -ENODEV;
+    ++ret;
+  }
+  write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
+    __android_log_cache_available(transport);
+    if (!transport->logMask) {
+      list_remove(&transport->node);
+      continue;
     }
+    if (!transport->open || ((*transport->open)() < 0)) {
+      if (transport->close) {
+        (*transport->close)();
+      }
+      list_remove(&transport->node);
+      continue;
+    }
+    ++i;
+  }
+  if (!ret && !i) {
+    return -ENODEV;
+  }
 
-    return ret;
+  return ret;
 }
 
 /*
  * Extract a 4-byte value from a byte stream. le32toh open coded
  */
-static inline uint32_t get4LE(const uint8_t* src)
-{
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+static inline uint32_t get4LE(const uint8_t* src) {
+  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
-static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr)
-{
-    struct android_log_transport_write *node;
-    int ret;
-    struct timespec ts;
-    size_t len, i;
+static int __write_to_log_daemon(log_id_t log_id, struct iovec* vec, size_t nr) {
+  struct android_log_transport_write* node;
+  int ret;
+  struct timespec ts;
+  size_t len, i;
 
-    for (len = i = 0; i < nr; ++i) {
-        len += vec[i].iov_len;
-    }
-    if (!len) {
-        return -EINVAL;
-    }
+  for (len = i = 0; i < nr; ++i) {
+    len += vec[i].iov_len;
+  }
+  if (!len) {
+    return -EINVAL;
+  }
 
 #if defined(__ANDROID__)
-    clock_gettime(android_log_clockid(), &ts);
+  clock_gettime(android_log_clockid(), &ts);
 
-    if (log_id == LOG_ID_SECURITY) {
-        if (vec[0].iov_len < 4) {
-            return -EINVAL;
-        }
+  if (log_id == LOG_ID_SECURITY) {
+    if (vec[0].iov_len < 4) {
+      return -EINVAL;
+    }
 
-        ret = check_log_uid_permissions();
-        if (ret < 0) {
-            return ret;
-        }
-        if (!__android_log_security()) {
-            /* If only we could reset downstream logd counter */
-            return -EPERM;
-        }
-    } else if (log_id == LOG_ID_EVENTS) {
-        const char *tag;
-        size_t len;
-        EventTagMap *m, *f;
+    ret = check_log_uid_permissions();
+    if (ret < 0) {
+      return ret;
+    }
+    if (!__android_log_security()) {
+      /* If only we could reset downstream logd counter */
+      return -EPERM;
+    }
+  } else if (log_id == LOG_ID_EVENTS) {
+    const char* tag;
+    size_t len;
+    EventTagMap *m, *f;
 
-        if (vec[0].iov_len < 4) {
-            return -EINVAL;
-        }
+    if (vec[0].iov_len < 4) {
+      return -EINVAL;
+    }
 
-        tag = NULL;
-        len = 0;
-        f = NULL;
-        m = (EventTagMap *)atomic_load(&tagMap);
+    tag = NULL;
+    len = 0;
+    f = NULL;
+    m = (EventTagMap*)atomic_load(&tagMap);
 
-        if (!m) {
-            ret = __android_log_trylock();
-            m = (EventTagMap *)atomic_load(&tagMap); /* trylock flush cache */
-            if (!m) {
-                m = android_openEventTagMap(NULL);
-                if (ret) { /* trylock failed, use local copy, mark for close */
-                    f = m;
-                } else {
-                    if (!m) { /* One chance to open map file */
-                        m = (EventTagMap *)(uintptr_t)-1LL;
-                    }
-                    atomic_store(&tagMap, (uintptr_t)m);
-                }
-            }
-            if (!ret) { /* trylock succeeded, unlock */
-                __android_log_unlock();
-            }
+    if (!m) {
+      ret = __android_log_trylock();
+      m = (EventTagMap*)atomic_load(&tagMap); /* trylock flush cache */
+      if (!m) {
+        m = android_openEventTagMap(NULL);
+        if (ret) { /* trylock failed, use local copy, mark for close */
+          f = m;
+        } else {
+          if (!m) { /* One chance to open map file */
+            m = (EventTagMap*)(uintptr_t)-1LL;
+          }
+          atomic_store(&tagMap, (uintptr_t)m);
         }
-        if (m && (m != (EventTagMap *)(uintptr_t)-1LL)) {
-            tag = android_lookupEventTag_len(m, &len, get4LE(vec[0].iov_base));
-        }
-        ret = __android_log_is_loggable_len(ANDROID_LOG_INFO,
-                                            tag, len,
-                                            ANDROID_LOG_VERBOSE);
-        if (f) { /* local copy marked for close */
-            android_closeEventTagMap(f);
-        }
-        if (!ret) {
-            return -EPERM;
-        }
-    } else {
-        /* Validate the incoming tag, tag content can not split across iovec */
-        char prio = ANDROID_LOG_VERBOSE;
-        const char *tag = vec[0].iov_base;
-        size_t len = vec[0].iov_len;
+      }
+      if (!ret) { /* trylock succeeded, unlock */
+        __android_log_unlock();
+      }
+    }
+    if (m && (m != (EventTagMap*)(uintptr_t)-1LL)) {
+      tag = android_lookupEventTag_len(m, &len, get4LE(vec[0].iov_base));
+    }
+    ret = __android_log_is_loggable_len(ANDROID_LOG_INFO, tag, len,
+                                        ANDROID_LOG_VERBOSE);
+    if (f) { /* local copy marked for close */
+      android_closeEventTagMap(f);
+    }
+    if (!ret) {
+      return -EPERM;
+    }
+  } else {
+    /* Validate the incoming tag, tag content can not split across iovec */
+    char prio = ANDROID_LOG_VERBOSE;
+    const char* tag = vec[0].iov_base;
+    size_t len = vec[0].iov_len;
+    if (!tag) {
+      len = 0;
+    }
+    if (len > 0) {
+      prio = *tag;
+      if (len > 1) {
+        --len;
+        ++tag;
+      } else {
+        len = vec[1].iov_len;
+        tag = ((const char*)vec[1].iov_base);
         if (!tag) {
-            len = 0;
+          len = 0;
         }
-        if (len > 0) {
-            prio = *tag;
-            if (len > 1) {
-                --len;
-                ++tag;
-            } else {
-                len = vec[1].iov_len;
-                tag = ((const char *)vec[1].iov_base);
-                if (!tag) {
-                    len = 0;
-                }
-            }
-        }
-        /* tag must be nul terminated */
-        if (tag && strnlen(tag, len) >= len) {
-            tag = NULL;
-        }
+      }
+    }
+    /* tag must be nul terminated */
+    if (tag && strnlen(tag, len) >= len) {
+      tag = NULL;
+    }
 
-        if (!__android_log_is_loggable_len(prio,
-                                           tag, len - 1,
-                                           ANDROID_LOG_VERBOSE)) {
-            return -EPERM;
-        }
+    if (!__android_log_is_loggable_len(prio, tag, len - 1, ANDROID_LOG_VERBOSE)) {
+      return -EPERM;
     }
+  }
 #else
-    /* simulate clock_gettime(CLOCK_REALTIME, &ts); */
-    {
-        struct timeval tv;
-        gettimeofday(&tv, NULL);
-        ts.tv_sec = tv.tv_sec;
-        ts.tv_nsec = tv.tv_usec * 1000;
-    }
+  /* simulate clock_gettime(CLOCK_REALTIME, &ts); */
+  {
+    struct timeval tv;
+    gettimeofday(&tv, NULL);
+    ts.tv_sec = tv.tv_sec;
+    ts.tv_nsec = tv.tv_usec * 1000;
+  }
 #endif
 
-    ret = 0;
-    i = 1 << log_id;
-    write_transport_for_each(node, &__android_log_transport_write) {
-        if (node->logMask & i) {
-            ssize_t retval;
-            retval = (*node->write)(log_id, &ts, vec, nr);
-            if (ret >= 0) {
-                ret = retval;
-            }
-        }
+  ret = 0;
+  i = 1 << log_id;
+  write_transport_for_each(node, &__android_log_transport_write) {
+    if (node->logMask & i) {
+      ssize_t retval;
+      retval = (*node->write)(log_id, &ts, vec, nr);
+      if (ret >= 0) {
+        ret = retval;
+      }
     }
+  }
 
-    write_transport_for_each(node, &__android_log_persist_write) {
-        if (node->logMask & i) {
-            (void)(*node->write)(log_id, &ts, vec, nr);
-        }
+  write_transport_for_each(node, &__android_log_persist_write) {
+    if (node->logMask & i) {
+      (void)(*node->write)(log_id, &ts, vec, nr);
     }
+  }
 
-    return ret;
+  return ret;
 }
 
-static int __write_to_log_init(log_id_t log_id, struct iovec *vec, size_t nr)
-{
-    __android_log_lock();
+static int __write_to_log_init(log_id_t log_id, struct iovec* vec, size_t nr) {
+  __android_log_lock();
 
-    if (write_to_log == __write_to_log_init) {
-        int ret;
+  if (write_to_log == __write_to_log_init) {
+    int ret;
 
-        ret = __write_to_log_initialize();
-        if (ret < 0) {
-            __android_log_unlock();
-            if (!list_empty(&__android_log_persist_write)) {
-                __write_to_log_daemon(log_id, vec, nr);
-            }
-            return ret;
-        }
-
-        write_to_log = __write_to_log_daemon;
+    ret = __write_to_log_initialize();
+    if (ret < 0) {
+      __android_log_unlock();
+      if (!list_empty(&__android_log_persist_write)) {
+        __write_to_log_daemon(log_id, vec, nr);
+      }
+      return ret;
     }
 
-    __android_log_unlock();
+    write_to_log = __write_to_log_daemon;
+  }
 
-    return write_to_log(log_id, vec, nr);
+  __android_log_unlock();
+
+  return write_to_log(log_id, vec, nr);
 }
 
-LIBLOG_ABI_PUBLIC int __android_log_write(int prio, const char *tag,
-                                          const char *msg)
-{
-    return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg);
+LIBLOG_ABI_PUBLIC int __android_log_write(int prio, const char* tag,
+                                          const char* msg) {
+  return __android_log_buf_write(LOG_ID_MAIN, prio, tag, msg);
 }
 
 LIBLOG_ABI_PUBLIC int __android_log_buf_write(int bufID, int prio,
-                                              const char *tag, const char *msg)
-{
-    struct iovec vec[3];
-    char tmp_tag[32];
+                                              const char* tag, const char* msg) {
+  struct iovec vec[3];
+  char tmp_tag[32];
 
-    if (!tag)
-        tag = "";
+  if (!tag) tag = "";
 
-    /* XXX: This needs to go! */
-    if ((bufID != LOG_ID_RADIO) &&
-         (!strcmp(tag, "HTC_RIL") ||
-        !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */
-        !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */
-        !strcmp(tag, "AT") ||
-        !strcmp(tag, "GSM") ||
-        !strcmp(tag, "STK") ||
-        !strcmp(tag, "CDMA") ||
-        !strcmp(tag, "PHONE") ||
-        !strcmp(tag, "SMS"))) {
-            bufID = LOG_ID_RADIO;
-            /* Inform third party apps/ril/radio.. to use Rlog or RLOG */
-            snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag);
-            tag = tmp_tag;
-    }
+  /* XXX: This needs to go! */
+  if ((bufID != LOG_ID_RADIO) &&
+      (!strcmp(tag, "HTC_RIL") ||
+       !strncmp(tag, "RIL", 3) || /* Any log tag with "RIL" as the prefix */
+       !strncmp(tag, "IMS", 3) || /* Any log tag with "IMS" as the prefix */
+       !strcmp(tag, "AT") || !strcmp(tag, "GSM") || !strcmp(tag, "STK") ||
+       !strcmp(tag, "CDMA") || !strcmp(tag, "PHONE") || !strcmp(tag, "SMS"))) {
+    bufID = LOG_ID_RADIO;
+    /* Inform third party apps/ril/radio.. to use Rlog or RLOG */
+    snprintf(tmp_tag, sizeof(tmp_tag), "use-Rlog/RLOG-%s", tag);
+    tag = tmp_tag;
+  }
 
 #if __BIONIC__
-    if (prio == ANDROID_LOG_FATAL) {
-        android_set_abort_message(msg);
-    }
+  if (prio == ANDROID_LOG_FATAL) {
+    android_set_abort_message(msg);
+  }
 #endif
 
-    vec[0].iov_base = (unsigned char *)&prio;
-    vec[0].iov_len  = 1;
-    vec[1].iov_base = (void *)tag;
-    vec[1].iov_len  = strlen(tag) + 1;
-    vec[2].iov_base = (void *)msg;
-    vec[2].iov_len  = strlen(msg) + 1;
+  vec[0].iov_base = (unsigned char*)&prio;
+  vec[0].iov_len = 1;
+  vec[1].iov_base = (void*)tag;
+  vec[1].iov_len = strlen(tag) + 1;
+  vec[2].iov_base = (void*)msg;
+  vec[2].iov_len = strlen(msg) + 1;
 
-    return write_to_log(bufID, vec, 3);
+  return write_to_log(bufID, vec, 3);
 }
 
-LIBLOG_ABI_PUBLIC int __android_log_vprint(int prio, const char *tag,
-                                           const char *fmt, va_list ap)
-{
-    char buf[LOG_BUF_SIZE];
+LIBLOG_ABI_PUBLIC int __android_log_vprint(int prio, const char* tag,
+                                           const char* fmt, va_list ap) {
+  char buf[LOG_BUF_SIZE];
 
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
+  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
 
-    return __android_log_write(prio, tag, buf);
+  return __android_log_write(prio, tag, buf);
 }
 
-LIBLOG_ABI_PUBLIC int __android_log_print(int prio, const char *tag,
-                                          const char *fmt, ...)
-{
-    va_list ap;
-    char buf[LOG_BUF_SIZE];
+LIBLOG_ABI_PUBLIC int __android_log_print(int prio, const char* tag,
+                                          const char* fmt, ...) {
+  va_list ap;
+  char buf[LOG_BUF_SIZE];
 
-    va_start(ap, fmt);
-    vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-    va_end(ap);
+  va_start(ap, fmt);
+  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
+  va_end(ap);
 
-    return __android_log_write(prio, tag, buf);
+  return __android_log_write(prio, tag, buf);
 }
 
 LIBLOG_ABI_PUBLIC int __android_log_buf_print(int bufID, int prio,
-                                              const char *tag,
-                                              const char *fmt, ...)
-{
-    va_list ap;
-    char buf[LOG_BUF_SIZE];
+                                              const char* tag, const char* fmt,
+                                              ...) {
+  va_list ap;
+  char buf[LOG_BUF_SIZE];
 
+  va_start(ap, fmt);
+  vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
+  va_end(ap);
+
+  return __android_log_buf_write(bufID, prio, tag, buf);
+}
+
+LIBLOG_ABI_PUBLIC void __android_log_assert(const char* cond, const char* tag,
+                                            const char* fmt, ...) {
+  char buf[LOG_BUF_SIZE];
+
+  if (fmt) {
+    va_list ap;
     va_start(ap, fmt);
     vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
     va_end(ap);
+  } else {
+    /* Msg not provided, log condition.  N.B. Do not use cond directly as
+     * format string as it could contain spurious '%' syntax (e.g.
+     * "%d" in "blocks%devs == 0").
+     */
+    if (cond)
+      snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond);
+    else
+      strcpy(buf, "Unspecified assertion failed");
+  }
 
-    return __android_log_buf_write(bufID, prio, tag, buf);
+  // Log assertion failures to stderr for the benefit of "adb shell" users
+  // and gtests (http://b/23675822).
+  struct iovec iov[2] = {
+    { buf, strlen(buf) }, { (char*)"\n", 1 },
+  };
+  TEMP_FAILURE_RETRY(writev(2, iov, 2));
+
+  __android_log_write(ANDROID_LOG_FATAL, tag, buf);
+  abort(); /* abort so we have a chance to debug the situation */
+           /* NOTREACHED */
 }
 
-LIBLOG_ABI_PUBLIC void __android_log_assert(const char *cond, const char *tag,
-                                            const char *fmt, ...)
-{
-    char buf[LOG_BUF_SIZE];
+LIBLOG_ABI_PUBLIC int __android_log_bwrite(int32_t tag, const void* payload,
+                                           size_t len) {
+  struct iovec vec[2];
 
-    if (fmt) {
-        va_list ap;
-        va_start(ap, fmt);
-        vsnprintf(buf, LOG_BUF_SIZE, fmt, ap);
-        va_end(ap);
-    } else {
-        /* Msg not provided, log condition.  N.B. Do not use cond directly as
-         * format string as it could contain spurious '%' syntax (e.g.
-         * "%d" in "blocks%devs == 0").
-         */
-        if (cond)
-            snprintf(buf, LOG_BUF_SIZE, "Assertion failed: %s", cond);
-        else
-            strcpy(buf, "Unspecified assertion failed");
-    }
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = (void*)payload;
+  vec[1].iov_len = len;
 
-    // Log assertion failures to stderr for the benefit of "adb shell" users
-    // and gtests (http://b/23675822).
-    struct iovec iov[2] = {
-        { buf, strlen(buf) },
-        { (char*) "\n", 1 },
-    };
-    TEMP_FAILURE_RETRY(writev(2, iov, 2));
-
-    __android_log_write(ANDROID_LOG_FATAL, tag, buf);
-    abort(); /* abort so we have a chance to debug the situation */
-    /* NOTREACHED */
-}
-
-LIBLOG_ABI_PUBLIC int __android_log_bwrite(int32_t tag,
-                                           const void *payload, size_t len)
-{
-    struct iovec vec[2];
-
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = (void*)payload;
-    vec[1].iov_len = len;
-
-    return write_to_log(LOG_ID_EVENTS, vec, 2);
+  return write_to_log(LOG_ID_EVENTS, vec, 2);
 }
 
 LIBLOG_ABI_PUBLIC int __android_log_security_bwrite(int32_t tag,
-                                                    const void *payload,
-                                                    size_t len)
-{
-    struct iovec vec[2];
+                                                    const void* payload,
+                                                    size_t len) {
+  struct iovec vec[2];
 
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = (void*)payload;
-    vec[1].iov_len = len;
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = (void*)payload;
+  vec[1].iov_len = len;
 
-    return write_to_log(LOG_ID_SECURITY, vec, 2);
+  return write_to_log(LOG_ID_SECURITY, vec, 2);
 }
 
 /*
@@ -564,40 +535,38 @@
  * handy if we just want to dump an integer into the log.
  */
 LIBLOG_ABI_PUBLIC int __android_log_btwrite(int32_t tag, char type,
-                                            const void *payload, size_t len)
-{
-    struct iovec vec[3];
+                                            const void* payload, size_t len) {
+  struct iovec vec[3];
 
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = &type;
-    vec[1].iov_len = sizeof(type);
-    vec[2].iov_base = (void*)payload;
-    vec[2].iov_len = len;
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = &type;
+  vec[1].iov_len = sizeof(type);
+  vec[2].iov_base = (void*)payload;
+  vec[2].iov_len = len;
 
-    return write_to_log(LOG_ID_EVENTS, vec, 3);
+  return write_to_log(LOG_ID_EVENTS, vec, 3);
 }
 
 /*
  * Like __android_log_bwrite, but used for writing strings to the
  * event log.
  */
-LIBLOG_ABI_PUBLIC int __android_log_bswrite(int32_t tag, const char *payload)
-{
-    struct iovec vec[4];
-    char type = EVENT_TYPE_STRING;
-    uint32_t len = strlen(payload);
+LIBLOG_ABI_PUBLIC int __android_log_bswrite(int32_t tag, const char* payload) {
+  struct iovec vec[4];
+  char type = EVENT_TYPE_STRING;
+  uint32_t len = strlen(payload);
 
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = &type;
-    vec[1].iov_len = sizeof(type);
-    vec[2].iov_base = &len;
-    vec[2].iov_len = sizeof(len);
-    vec[3].iov_base = (void*)payload;
-    vec[3].iov_len = len;
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = &type;
+  vec[1].iov_len = sizeof(type);
+  vec[2].iov_base = &len;
+  vec[2].iov_len = sizeof(len);
+  vec[3].iov_base = (void*)payload;
+  vec[3].iov_len = len;
 
-    return write_to_log(LOG_ID_EVENTS, vec, 4);
+  return write_to_log(LOG_ID_EVENTS, vec, 4);
 }
 
 /*
@@ -605,104 +574,100 @@
  * security log.
  */
 LIBLOG_ABI_PUBLIC int __android_log_security_bswrite(int32_t tag,
-                                                     const char *payload)
-{
-    struct iovec vec[4];
-    char type = EVENT_TYPE_STRING;
-    uint32_t len = strlen(payload);
+                                                     const char* payload) {
+  struct iovec vec[4];
+  char type = EVENT_TYPE_STRING;
+  uint32_t len = strlen(payload);
 
-    vec[0].iov_base = &tag;
-    vec[0].iov_len = sizeof(tag);
-    vec[1].iov_base = &type;
-    vec[1].iov_len = sizeof(type);
-    vec[2].iov_base = &len;
-    vec[2].iov_len = sizeof(len);
-    vec[3].iov_base = (void*)payload;
-    vec[3].iov_len = len;
+  vec[0].iov_base = &tag;
+  vec[0].iov_len = sizeof(tag);
+  vec[1].iov_base = &type;
+  vec[1].iov_len = sizeof(type);
+  vec[2].iov_base = &len;
+  vec[2].iov_len = sizeof(len);
+  vec[3].iov_base = (void*)payload;
+  vec[3].iov_len = len;
 
-    return write_to_log(LOG_ID_SECURITY, vec, 4);
+  return write_to_log(LOG_ID_SECURITY, vec, 4);
 }
 
-static int __write_to_log_null(log_id_t log_id, struct iovec* vec, size_t nr)
-{
-    size_t len, i;
+static int __write_to_log_null(log_id_t log_id, struct iovec* vec, size_t nr) {
+  size_t len, i;
 
-    if ((log_id < LOG_ID_MIN) || (log_id >= LOG_ID_MAX)) {
-        return -EINVAL;
-    }
+  if ((log_id < LOG_ID_MIN) || (log_id >= LOG_ID_MAX)) {
+    return -EINVAL;
+  }
 
-    for (len = i = 0; i < nr; ++i) {
-        len += vec[i].iov_len;
-    }
-    if (!len) {
-        return -EINVAL;
-    }
-    return len;
+  for (len = i = 0; i < nr; ++i) {
+    len += vec[i].iov_len;
+  }
+  if (!len) {
+    return -EINVAL;
+  }
+  return len;
 }
 
 /* Following functions need access to our internal write_to_log status */
 
-LIBLOG_HIDDEN int __android_log_frontend;
+LIBLOG_HIDDEN int __android_log_transport;
 
-LIBLOG_ABI_PUBLIC int android_set_log_frontend(int frontend_flag)
-{
-    int retval;
+LIBLOG_ABI_PUBLIC int android_set_log_transport(int transport_flag) {
+  int retval;
 
-    if (frontend_flag < 0) {
-        return -EINVAL;
-    }
+  if (transport_flag < 0) {
+    return -EINVAL;
+  }
 
-    retval = LOGGER_NULL;
+  retval = LOGGER_NULL;
 
-    __android_log_lock();
+  __android_log_lock();
 
-    if (frontend_flag & LOGGER_NULL) {
-        write_to_log = __write_to_log_null;
-
-        __android_log_unlock();
-
-        return retval;
-    }
-
-    __android_log_frontend &= LOGGER_LOCAL | LOGGER_LOGD;
-
-    frontend_flag &= LOGGER_LOCAL | LOGGER_LOGD;
-
-    if (__android_log_frontend != frontend_flag) {
-        __android_log_frontend = frontend_flag;
-        __android_log_config_write_close();
-        __android_log_config_read_close();
-
-        write_to_log = __write_to_log_init;
-    /* generically we only expect these two values for write_to_log */
-    } else if ((write_to_log != __write_to_log_init) &&
-               (write_to_log != __write_to_log_daemon)) {
-        write_to_log = __write_to_log_init;
-    }
-
-    retval = __android_log_frontend;
+  if (transport_flag & LOGGER_NULL) {
+    write_to_log = __write_to_log_null;
 
     __android_log_unlock();
 
     return retval;
+  }
+
+  __android_log_transport &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
+
+  transport_flag &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
+
+  if (__android_log_transport != transport_flag) {
+    __android_log_transport = transport_flag;
+    __android_log_config_write_close();
+    __android_log_config_read_close();
+
+    write_to_log = __write_to_log_init;
+    /* generically we only expect these two values for write_to_log */
+  } else if ((write_to_log != __write_to_log_init) &&
+             (write_to_log != __write_to_log_daemon)) {
+    write_to_log = __write_to_log_init;
+  }
+
+  retval = __android_log_transport;
+
+  __android_log_unlock();
+
+  return retval;
 }
 
-LIBLOG_ABI_PUBLIC int android_get_log_frontend()
-{
-    int ret = LOGGER_DEFAULT;
+LIBLOG_ABI_PUBLIC int android_get_log_transport() {
+  int ret = LOGGER_DEFAULT;
 
-    __android_log_lock();
-    if (write_to_log == __write_to_log_null) {
-        ret = LOGGER_NULL;
-    } else {
-        __android_log_frontend &= LOGGER_LOCAL | LOGGER_LOGD;
-        ret = __android_log_frontend;
-        if ((write_to_log != __write_to_log_init) &&
-            (write_to_log != __write_to_log_daemon)) {
-            ret = -EINVAL;
-        }
+  __android_log_lock();
+  if (write_to_log == __write_to_log_null) {
+    ret = LOGGER_NULL;
+  } else {
+    __android_log_transport &= LOGGER_LOCAL | LOGGER_LOGD | LOGGER_STDERR;
+    ret = __android_log_transport;
+    if ((write_to_log != __write_to_log_init) &&
+        (write_to_log != __write_to_log_daemon)) {
+      ret = -EINVAL;
     }
-    __android_log_unlock();
+  }
+  __android_log_unlock();
 
-    return ret;
+  return ret;
 }
diff --git a/liblog/logprint.c b/liblog/logprint.c
index af52528..2ade7b0 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -20,9 +20,6 @@
 #define HAVE_STRSEP
 #endif
 
-//#ifndef __MINGW32__
-//#include <arpa/inet.h>
-//#endif
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
@@ -48,29 +45,29 @@
 #define US_PER_NSEC 1000
 
 #ifndef MIN
-#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
 #endif
 
 typedef struct FilterInfo_t {
-    char *mTag;
-    android_LogPriority mPri;
-    struct FilterInfo_t *p_next;
+  char* mTag;
+  android_LogPriority mPri;
+  struct FilterInfo_t* p_next;
 } FilterInfo;
 
 struct AndroidLogFormat_t {
-    android_LogPriority global_pri;
-    FilterInfo *filters;
-    AndroidLogPrintFormat format;
-    bool colored_output;
-    bool usec_time_output;
-    bool nsec_time_output;
-    bool printable_output;
-    bool year_output;
-    bool zone_output;
-    bool epoch_output;
-    bool monotonic_output;
-    bool uid_output;
-    bool descriptive_output;
+  android_LogPriority global_pri;
+  FilterInfo* filters;
+  AndroidLogPrintFormat format;
+  bool colored_output;
+  bool usec_time_output;
+  bool nsec_time_output;
+  bool printable_output;
+  bool year_output;
+  bool zone_output;
+  bool epoch_output;
+  bool monotonic_output;
+  bool uid_output;
+  bool descriptive_output;
 };
 
 /*
@@ -86,22 +83,21 @@
  *    The color manipulation character stream is defined as:
  *      ESC [ 3 8 ; 5 ; <color#> m
  */
-#define ANDROID_COLOR_BLUE     75
+#define ANDROID_COLOR_BLUE 75
 #define ANDROID_COLOR_DEFAULT 231
-#define ANDROID_COLOR_GREEN    40
-#define ANDROID_COLOR_ORANGE  166
-#define ANDROID_COLOR_RED     196
-#define ANDROID_COLOR_YELLOW  226
+#define ANDROID_COLOR_GREEN 40
+#define ANDROID_COLOR_ORANGE 166
+#define ANDROID_COLOR_RED 196
+#define ANDROID_COLOR_YELLOW 226
 
-static FilterInfo * filterinfo_new(const char * tag, android_LogPriority pri)
-{
-    FilterInfo *p_ret;
+static FilterInfo* filterinfo_new(const char* tag, android_LogPriority pri) {
+  FilterInfo* p_ret;
 
-    p_ret = (FilterInfo *)calloc(1, sizeof(FilterInfo));
-    p_ret->mTag = strdup(tag);
-    p_ret->mPri = pri;
+  p_ret = (FilterInfo*)calloc(1, sizeof(FilterInfo));
+  p_ret->mTag = strdup(tag);
+  p_ret->mPri = pri;
 
-    return p_ret;
+  return p_ret;
 }
 
 /* balance to above, filterinfo_free left unimplemented */
@@ -110,201 +106,193 @@
  * Note: also accepts 0-9 priorities
  * returns ANDROID_LOG_UNKNOWN if the character is unrecognized
  */
-static android_LogPriority filterCharToPri (char c)
-{
-    android_LogPriority pri;
+static android_LogPriority filterCharToPri(char c) {
+  android_LogPriority pri;
 
-    c = tolower(c);
+  c = tolower(c);
 
-    if (c >= '0' && c <= '9') {
-        if (c >= ('0'+ANDROID_LOG_SILENT)) {
-            pri = ANDROID_LOG_VERBOSE;
-        } else {
-            pri = (android_LogPriority)(c - '0');
-        }
-    } else if (c == 'v') {
-        pri = ANDROID_LOG_VERBOSE;
-    } else if (c == 'd') {
-        pri = ANDROID_LOG_DEBUG;
-    } else if (c == 'i') {
-        pri = ANDROID_LOG_INFO;
-    } else if (c == 'w') {
-        pri = ANDROID_LOG_WARN;
-    } else if (c == 'e') {
-        pri = ANDROID_LOG_ERROR;
-    } else if (c == 'f') {
-        pri = ANDROID_LOG_FATAL;
-    } else if (c == 's') {
-        pri = ANDROID_LOG_SILENT;
-    } else if (c == '*') {
-        pri = ANDROID_LOG_DEFAULT;
+  if (c >= '0' && c <= '9') {
+    if (c >= ('0' + ANDROID_LOG_SILENT)) {
+      pri = ANDROID_LOG_VERBOSE;
     } else {
-        pri = ANDROID_LOG_UNKNOWN;
+      pri = (android_LogPriority)(c - '0');
     }
+  } else if (c == 'v') {
+    pri = ANDROID_LOG_VERBOSE;
+  } else if (c == 'd') {
+    pri = ANDROID_LOG_DEBUG;
+  } else if (c == 'i') {
+    pri = ANDROID_LOG_INFO;
+  } else if (c == 'w') {
+    pri = ANDROID_LOG_WARN;
+  } else if (c == 'e') {
+    pri = ANDROID_LOG_ERROR;
+  } else if (c == 'f') {
+    pri = ANDROID_LOG_FATAL;
+  } else if (c == 's') {
+    pri = ANDROID_LOG_SILENT;
+  } else if (c == '*') {
+    pri = ANDROID_LOG_DEFAULT;
+  } else {
+    pri = ANDROID_LOG_UNKNOWN;
+  }
 
-    return pri;
+  return pri;
 }
 
-static char filterPriToChar (android_LogPriority pri)
-{
-    switch (pri) {
-        case ANDROID_LOG_VERBOSE:       return 'V';
-        case ANDROID_LOG_DEBUG:         return 'D';
-        case ANDROID_LOG_INFO:          return 'I';
-        case ANDROID_LOG_WARN:          return 'W';
-        case ANDROID_LOG_ERROR:         return 'E';
-        case ANDROID_LOG_FATAL:         return 'F';
-        case ANDROID_LOG_SILENT:        return 'S';
+static char filterPriToChar(android_LogPriority pri) {
+  switch (pri) {
+    /* clang-format off */
+    case ANDROID_LOG_VERBOSE: return 'V';
+    case ANDROID_LOG_DEBUG:   return 'D';
+    case ANDROID_LOG_INFO:    return 'I';
+    case ANDROID_LOG_WARN:    return 'W';
+    case ANDROID_LOG_ERROR:   return 'E';
+    case ANDROID_LOG_FATAL:   return 'F';
+    case ANDROID_LOG_SILENT:  return 'S';
 
-        case ANDROID_LOG_DEFAULT:
-        case ANDROID_LOG_UNKNOWN:
-        default:                        return '?';
-    }
+    case ANDROID_LOG_DEFAULT:
+    case ANDROID_LOG_UNKNOWN:
+    default:                  return '?';
+    /* clang-format on */
+  }
 }
 
-static int colorFromPri (android_LogPriority pri)
-{
-    switch (pri) {
-        case ANDROID_LOG_VERBOSE:       return ANDROID_COLOR_DEFAULT;
-        case ANDROID_LOG_DEBUG:         return ANDROID_COLOR_BLUE;
-        case ANDROID_LOG_INFO:          return ANDROID_COLOR_GREEN;
-        case ANDROID_LOG_WARN:          return ANDROID_COLOR_ORANGE;
-        case ANDROID_LOG_ERROR:         return ANDROID_COLOR_RED;
-        case ANDROID_LOG_FATAL:         return ANDROID_COLOR_RED;
-        case ANDROID_LOG_SILENT:        return ANDROID_COLOR_DEFAULT;
+static int colorFromPri(android_LogPriority pri) {
+  switch (pri) {
+    /* clang-format off */
+    case ANDROID_LOG_VERBOSE: return ANDROID_COLOR_DEFAULT;
+    case ANDROID_LOG_DEBUG:   return ANDROID_COLOR_BLUE;
+    case ANDROID_LOG_INFO:    return ANDROID_COLOR_GREEN;
+    case ANDROID_LOG_WARN:    return ANDROID_COLOR_ORANGE;
+    case ANDROID_LOG_ERROR:   return ANDROID_COLOR_RED;
+    case ANDROID_LOG_FATAL:   return ANDROID_COLOR_RED;
+    case ANDROID_LOG_SILENT:  return ANDROID_COLOR_DEFAULT;
 
-        case ANDROID_LOG_DEFAULT:
-        case ANDROID_LOG_UNKNOWN:
-        default:                        return ANDROID_COLOR_DEFAULT;
-    }
+    case ANDROID_LOG_DEFAULT:
+    case ANDROID_LOG_UNKNOWN:
+    default:                  return ANDROID_COLOR_DEFAULT;
+    /* clang-format on */
+  }
 }
 
-static android_LogPriority filterPriForTag(
-        AndroidLogFormat *p_format, const char *tag)
-{
-    FilterInfo *p_curFilter;
+static android_LogPriority filterPriForTag(AndroidLogFormat* p_format,
+                                           const char* tag) {
+  FilterInfo* p_curFilter;
 
-    for (p_curFilter = p_format->filters
-            ; p_curFilter != NULL
-            ; p_curFilter = p_curFilter->p_next
-    ) {
-        if (0 == strcmp(tag, p_curFilter->mTag)) {
-            if (p_curFilter->mPri == ANDROID_LOG_DEFAULT) {
-                return p_format->global_pri;
-            } else {
-                return p_curFilter->mPri;
-            }
-        }
+  for (p_curFilter = p_format->filters; p_curFilter != NULL;
+       p_curFilter = p_curFilter->p_next) {
+    if (0 == strcmp(tag, p_curFilter->mTag)) {
+      if (p_curFilter->mPri == ANDROID_LOG_DEFAULT) {
+        return p_format->global_pri;
+      } else {
+        return p_curFilter->mPri;
+      }
     }
+  }
 
-    return p_format->global_pri;
+  return p_format->global_pri;
 }
 
 /**
  * returns 1 if this log line should be printed based on its priority
  * and tag, and 0 if it should not
  */
-LIBLOG_ABI_PUBLIC int android_log_shouldPrintLine (
-        AndroidLogFormat *p_format,
-        const char *tag,
-        android_LogPriority pri)
-{
-    return pri >= filterPriForTag(p_format, tag);
+LIBLOG_ABI_PUBLIC int android_log_shouldPrintLine(AndroidLogFormat* p_format,
+                                                  const char* tag,
+                                                  android_LogPriority pri) {
+  return pri >= filterPriForTag(p_format, tag);
 }
 
-LIBLOG_ABI_PUBLIC AndroidLogFormat *android_log_format_new()
-{
-    AndroidLogFormat *p_ret;
+LIBLOG_ABI_PUBLIC AndroidLogFormat* android_log_format_new() {
+  AndroidLogFormat* p_ret;
 
-    p_ret = calloc(1, sizeof(AndroidLogFormat));
+  p_ret = calloc(1, sizeof(AndroidLogFormat));
 
-    p_ret->global_pri = ANDROID_LOG_VERBOSE;
-    p_ret->format = FORMAT_BRIEF;
-    p_ret->colored_output = false;
-    p_ret->usec_time_output = false;
-    p_ret->nsec_time_output = false;
-    p_ret->printable_output = false;
-    p_ret->year_output = false;
-    p_ret->zone_output = false;
-    p_ret->epoch_output = false;
+  p_ret->global_pri = ANDROID_LOG_VERBOSE;
+  p_ret->format = FORMAT_BRIEF;
+  p_ret->colored_output = false;
+  p_ret->usec_time_output = false;
+  p_ret->nsec_time_output = false;
+  p_ret->printable_output = false;
+  p_ret->year_output = false;
+  p_ret->zone_output = false;
+  p_ret->epoch_output = false;
 #ifdef __ANDROID__
-    p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
+  p_ret->monotonic_output = android_log_clockid() == CLOCK_MONOTONIC;
 #else
-    p_ret->monotonic_output = false;
+  p_ret->monotonic_output = false;
 #endif
-    p_ret->uid_output = false;
-    p_ret->descriptive_output = false;
-    descriptive_output = false;
+  p_ret->uid_output = false;
+  p_ret->descriptive_output = false;
+  descriptive_output = false;
 
-    return p_ret;
+  return p_ret;
 }
 
 static list_declare(convertHead);
 
-LIBLOG_ABI_PUBLIC void android_log_format_free(AndroidLogFormat *p_format)
-{
-    FilterInfo *p_info, *p_info_old;
+LIBLOG_ABI_PUBLIC void android_log_format_free(AndroidLogFormat* p_format) {
+  FilterInfo *p_info, *p_info_old;
 
-    p_info = p_format->filters;
+  p_info = p_format->filters;
 
-    while (p_info != NULL) {
-        p_info_old = p_info;
-        p_info = p_info->p_next;
+  while (p_info != NULL) {
+    p_info_old = p_info;
+    p_info = p_info->p_next;
 
-        free(p_info_old);
-    }
+    free(p_info_old);
+  }
 
-    free(p_format);
+  free(p_format);
 
-    /* Free conversion resource, can always be reconstructed */
-    while (!list_empty(&convertHead)) {
-        struct listnode *node = list_head(&convertHead);
-        list_remove(node);
-        free(node);
-    }
+  /* Free conversion resource, can always be reconstructed */
+  while (!list_empty(&convertHead)) {
+    struct listnode* node = list_head(&convertHead);
+    list_remove(node);
+    free(node);
+  }
 }
 
-LIBLOG_ABI_PUBLIC int android_log_setPrintFormat(
-        AndroidLogFormat *p_format,
-        AndroidLogPrintFormat format)
-{
-    switch (format) {
+LIBLOG_ABI_PUBLIC int android_log_setPrintFormat(AndroidLogFormat* p_format,
+                                                 AndroidLogPrintFormat format) {
+  switch (format) {
     case FORMAT_MODIFIER_COLOR:
-        p_format->colored_output = true;
-        return 0;
+      p_format->colored_output = true;
+      return 0;
     case FORMAT_MODIFIER_TIME_USEC:
-        p_format->usec_time_output = true;
-        return 0;
+      p_format->usec_time_output = true;
+      return 0;
     case FORMAT_MODIFIER_TIME_NSEC:
-        p_format->nsec_time_output = true;
-        return 0;
+      p_format->nsec_time_output = true;
+      return 0;
     case FORMAT_MODIFIER_PRINTABLE:
-        p_format->printable_output = true;
-        return 0;
+      p_format->printable_output = true;
+      return 0;
     case FORMAT_MODIFIER_YEAR:
-        p_format->year_output = true;
-        return 0;
+      p_format->year_output = true;
+      return 0;
     case FORMAT_MODIFIER_ZONE:
-        p_format->zone_output = !p_format->zone_output;
-        return 0;
+      p_format->zone_output = !p_format->zone_output;
+      return 0;
     case FORMAT_MODIFIER_EPOCH:
-        p_format->epoch_output = true;
-        return 0;
+      p_format->epoch_output = true;
+      return 0;
     case FORMAT_MODIFIER_MONOTONIC:
-        p_format->monotonic_output = true;
-        return 0;
+      p_format->monotonic_output = true;
+      return 0;
     case FORMAT_MODIFIER_UID:
-        p_format->uid_output = true;
-        return 0;
+      p_format->uid_output = true;
+      return 0;
     case FORMAT_MODIFIER_DESCRIPT:
-        p_format->descriptive_output = true;
-        descriptive_output = true;
-        return 0;
+      p_format->descriptive_output = true;
+      descriptive_output = true;
+      return 0;
     default:
-        break;
-    }
-    p_format->format = format;
-    return 1;
+      break;
+  }
+  p_format->format = format;
+  return 1;
 }
 
 static const char tz[] = "TZ";
@@ -313,65 +301,65 @@
 /**
  * Returns FORMAT_OFF on invalid string
  */
-LIBLOG_ABI_PUBLIC AndroidLogPrintFormat android_log_formatFromString(
-        const char * formatString)
-{
-    static AndroidLogPrintFormat format;
+LIBLOG_ABI_PUBLIC AndroidLogPrintFormat
+android_log_formatFromString(const char* formatString) {
+  static AndroidLogPrintFormat format;
 
-    if (strcmp(formatString, "brief") == 0) format = FORMAT_BRIEF;
-    else if (strcmp(formatString, "process") == 0) format = FORMAT_PROCESS;
-    else if (strcmp(formatString, "tag") == 0) format = FORMAT_TAG;
-    else if (strcmp(formatString, "thread") == 0) format = FORMAT_THREAD;
-    else if (strcmp(formatString, "raw") == 0) format = FORMAT_RAW;
-    else if (strcmp(formatString, "time") == 0) format = FORMAT_TIME;
-    else if (strcmp(formatString, "threadtime") == 0) format = FORMAT_THREADTIME;
-    else if (strcmp(formatString, "long") == 0) format = FORMAT_LONG;
-    else if (strcmp(formatString, "color") == 0) format = FORMAT_MODIFIER_COLOR;
-    else if (strcmp(formatString, "colour") == 0) format = FORMAT_MODIFIER_COLOR;
-    else if (strcmp(formatString, "usec") == 0) format = FORMAT_MODIFIER_TIME_USEC;
-    else if (strcmp(formatString, "nsec") == 0) format = FORMAT_MODIFIER_TIME_NSEC;
-    else if (strcmp(formatString, "printable") == 0) format = FORMAT_MODIFIER_PRINTABLE;
-    else if (strcmp(formatString, "year") == 0) format = FORMAT_MODIFIER_YEAR;
-    else if (strcmp(formatString, "zone") == 0) format = FORMAT_MODIFIER_ZONE;
-    else if (strcmp(formatString, "epoch") == 0) format = FORMAT_MODIFIER_EPOCH;
-    else if (strcmp(formatString, "monotonic") == 0) format = FORMAT_MODIFIER_MONOTONIC;
-    else if (strcmp(formatString, "uid") == 0) format = FORMAT_MODIFIER_UID;
-    else if (strcmp(formatString, "descriptive") == 0) format = FORMAT_MODIFIER_DESCRIPT;
+  /* clang-format off */
+  if (!strcmp(formatString, "brief")) format = FORMAT_BRIEF;
+  else if (!strcmp(formatString, "process")) format = FORMAT_PROCESS;
+  else if (!strcmp(formatString, "tag")) format = FORMAT_TAG;
+  else if (!strcmp(formatString, "thread")) format = FORMAT_THREAD;
+  else if (!strcmp(formatString, "raw")) format = FORMAT_RAW;
+  else if (!strcmp(formatString, "time")) format = FORMAT_TIME;
+  else if (!strcmp(formatString, "threadtime")) format = FORMAT_THREADTIME;
+  else if (!strcmp(formatString, "long")) format = FORMAT_LONG;
+  else if (!strcmp(formatString, "color")) format = FORMAT_MODIFIER_COLOR;
+  else if (!strcmp(formatString, "colour")) format = FORMAT_MODIFIER_COLOR;
+  else if (!strcmp(formatString, "usec")) format = FORMAT_MODIFIER_TIME_USEC;
+  else if (!strcmp(formatString, "nsec")) format = FORMAT_MODIFIER_TIME_NSEC;
+  else if (!strcmp(formatString, "printable")) format = FORMAT_MODIFIER_PRINTABLE;
+  else if (!strcmp(formatString, "year")) format = FORMAT_MODIFIER_YEAR;
+  else if (!strcmp(formatString, "zone")) format = FORMAT_MODIFIER_ZONE;
+  else if (!strcmp(formatString, "epoch")) format = FORMAT_MODIFIER_EPOCH;
+  else if (!strcmp(formatString, "monotonic")) format = FORMAT_MODIFIER_MONOTONIC;
+  else if (!strcmp(formatString, "uid")) format = FORMAT_MODIFIER_UID;
+  else if (!strcmp(formatString, "descriptive")) format = FORMAT_MODIFIER_DESCRIPT;
+  /* clang-format on */
 #ifndef __MINGW32__
-    else {
-        extern char *tzname[2];
-        static const char gmt[] = "GMT";
-        char *cp = getenv(tz);
-        if (cp) {
-            cp = strdup(cp);
-        }
-        setenv(tz, formatString, 1);
-        /*
-         * Run tzset here to determine if the timezone is legitimate. If the
-         * zone is GMT, check if that is what was asked for, if not then
-         * did not match any on the system; report an error to caller.
-         */
-        tzset();
-        if (!tzname[0]
-                || ((!strcmp(tzname[0], utc)
-                        || !strcmp(tzname[0], gmt)) /* error? */
-                    && strcasecmp(formatString, utc)
-                    && strcasecmp(formatString, gmt))) { /* ok */
-            if (cp) {
-                setenv(tz, cp, 1);
-            } else {
-                unsetenv(tz);
-            }
-            tzset();
-            format = FORMAT_OFF;
-        } else {
-            format = FORMAT_MODIFIER_ZONE;
-        }
-        free(cp);
+  else {
+    extern char* tzname[2];
+    static const char gmt[] = "GMT";
+    char* cp = getenv(tz);
+    if (cp) {
+      cp = strdup(cp);
     }
+    setenv(tz, formatString, 1);
+    /*
+     * Run tzset here to determine if the timezone is legitimate. If the
+     * zone is GMT, check if that is what was asked for, if not then
+     * did not match any on the system; report an error to caller.
+     */
+    tzset();
+    if (!tzname[0] ||
+        ((!strcmp(tzname[0], utc) || !strcmp(tzname[0], gmt)) /* error? */
+         && strcasecmp(formatString, utc) &&
+         strcasecmp(formatString, gmt))) { /* ok */
+      if (cp) {
+        setenv(tz, cp, 1);
+      } else {
+        unsetenv(tz);
+      }
+      tzset();
+      format = FORMAT_OFF;
+    } else {
+      format = FORMAT_MODIFIER_ZONE;
+    }
+    free(cp);
+  }
 #endif
 
-    return format;
+  return format;
 }
 
 /**
@@ -383,92 +371,89 @@
  * Assumes single threaded execution
  */
 
-LIBLOG_ABI_PUBLIC int android_log_addFilterRule(
-        AndroidLogFormat *p_format,
-        const char *filterExpression)
-{
-    size_t tagNameLength;
-    android_LogPriority pri = ANDROID_LOG_DEFAULT;
+LIBLOG_ABI_PUBLIC int android_log_addFilterRule(AndroidLogFormat* p_format,
+                                                const char* filterExpression) {
+  size_t tagNameLength;
+  android_LogPriority pri = ANDROID_LOG_DEFAULT;
 
-    tagNameLength = strcspn(filterExpression, ":");
+  tagNameLength = strcspn(filterExpression, ":");
 
-    if (tagNameLength == 0) {
-        goto error;
+  if (tagNameLength == 0) {
+    goto error;
+  }
+
+  if (filterExpression[tagNameLength] == ':') {
+    pri = filterCharToPri(filterExpression[tagNameLength + 1]);
+
+    if (pri == ANDROID_LOG_UNKNOWN) {
+      goto error;
+    }
+  }
+
+  if (0 == strncmp("*", filterExpression, tagNameLength)) {
+    /*
+     * This filter expression refers to the global filter
+     * The default level for this is DEBUG if the priority
+     * is unspecified
+     */
+    if (pri == ANDROID_LOG_DEFAULT) {
+      pri = ANDROID_LOG_DEBUG;
     }
 
-    if(filterExpression[tagNameLength] == ':') {
-        pri = filterCharToPri(filterExpression[tagNameLength+1]);
-
-        if (pri == ANDROID_LOG_UNKNOWN) {
-            goto error;
-        }
+    p_format->global_pri = pri;
+  } else {
+    /*
+     * for filter expressions that don't refer to the global
+     * filter, the default is verbose if the priority is unspecified
+     */
+    if (pri == ANDROID_LOG_DEFAULT) {
+      pri = ANDROID_LOG_VERBOSE;
     }
 
-    if(0 == strncmp("*", filterExpression, tagNameLength)) {
-        /*
-         * This filter expression refers to the global filter
-         * The default level for this is DEBUG if the priority
-         * is unspecified
-         */
-        if (pri == ANDROID_LOG_DEFAULT) {
-            pri = ANDROID_LOG_DEBUG;
-        }
-
-        p_format->global_pri = pri;
-    } else {
-        /*
-         * for filter expressions that don't refer to the global
-         * filter, the default is verbose if the priority is unspecified
-         */
-        if (pri == ANDROID_LOG_DEFAULT) {
-            pri = ANDROID_LOG_VERBOSE;
-        }
-
-        char *tagName;
+    char* tagName;
 
 /*
  * Presently HAVE_STRNDUP is never defined, so the second case is always taken
  * Darwin doesn't have strndup, everything else does
  */
 #ifdef HAVE_STRNDUP
-        tagName = strndup(filterExpression, tagNameLength);
+    tagName = strndup(filterExpression, tagNameLength);
 #else
-        /* a few extra bytes copied... */
-        tagName = strdup(filterExpression);
-        tagName[tagNameLength] = '\0';
+    /* a few extra bytes copied... */
+    tagName = strdup(filterExpression);
+    tagName[tagNameLength] = '\0';
 #endif /*HAVE_STRNDUP*/
 
-        FilterInfo *p_fi = filterinfo_new(tagName, pri);
-        free(tagName);
+    FilterInfo* p_fi = filterinfo_new(tagName, pri);
+    free(tagName);
 
-        p_fi->p_next = p_format->filters;
-        p_format->filters = p_fi;
-    }
+    p_fi->p_next = p_format->filters;
+    p_format->filters = p_fi;
+  }
 
-    return 0;
+  return 0;
 error:
-    return -1;
+  return -1;
 }
 
 #ifndef HAVE_STRSEP
 /* KISS replacement helper for below */
-static char* strsep(char** stringp, const char* delim)
-{
-    char* token;
-    char* ret = *stringp;
+static char* strsep(char** stringp, const char* delim) {
+  char* token;
+  char* ret = *stringp;
 
-    if (!ret || !*ret) {
-        return NULL;
-    }
-    token = strpbrk(ret, delim);
-    if (token) {
-        *token = '\0';
-        ++token;
-    } else {
-        token = ret + strlen(ret);
-    }
-    *stringp = token;
-    return ret;
+  if (!ret || !*ret) {
+    return NULL;
+  }
+  token = strpbrk(ret, delim);
+  if (token) {
+    *token = '\0';
+    ++token;
+  } else {
+    token = ret + strlen(ret);
+  }
+  *stringp = token;
+  return ret;
 }
 #endif
 
@@ -482,32 +467,30 @@
  * Assumes single threaded execution
  *
  */
-LIBLOG_ABI_PUBLIC int android_log_addFilterString(
-        AndroidLogFormat *p_format,
-        const char *filterString)
-{
-    char *filterStringCopy = strdup (filterString);
-    char *p_cur = filterStringCopy;
-    char *p_ret;
-    int err;
+LIBLOG_ABI_PUBLIC int android_log_addFilterString(AndroidLogFormat* p_format,
+                                                  const char* filterString) {
+  char* filterStringCopy = strdup(filterString);
+  char* p_cur = filterStringCopy;
+  char* p_ret;
+  int err;
 
-    /* Yes, I'm using strsep */
-    while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
-        /* ignore whitespace-only entries */
-        if(p_ret[0] != '\0') {
-            err = android_log_addFilterRule(p_format, p_ret);
+  /* Yes, I'm using strsep */
+  while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
+    /* ignore whitespace-only entries */
+    if (p_ret[0] != '\0') {
+      err = android_log_addFilterRule(p_format, p_ret);
 
-            if (err < 0) {
-                goto error;
-            }
-        }
+      if (err < 0) {
+        goto error;
+      }
     }
+  }
 
-    free (filterStringCopy);
-    return 0;
+  free(filterStringCopy);
+  return 0;
 error:
-    free (filterStringCopy);
-    return -1;
+  free(filterStringCopy);
+  return -1;
 }
 
 /**
@@ -517,125 +500,124 @@
  * Returns 0 on success and -1 on invalid wire format (entry will be
  * in unspecified state)
  */
-LIBLOG_ABI_PUBLIC int android_log_processLogBuffer(
-        struct logger_entry *buf,
-        AndroidLogEntry *entry)
-{
-    entry->tv_sec = buf->sec;
-    entry->tv_nsec = buf->nsec;
-    entry->uid = -1;
-    entry->pid = buf->pid;
-    entry->tid = buf->tid;
+LIBLOG_ABI_PUBLIC int android_log_processLogBuffer(struct logger_entry* buf,
+                                                   AndroidLogEntry* entry) {
+  entry->message = NULL;
+  entry->messageLen = 0;
 
+  entry->tv_sec = buf->sec;
+  entry->tv_nsec = buf->nsec;
+  entry->uid = -1;
+  entry->pid = buf->pid;
+  entry->tid = buf->tid;
+
+  /*
+   * format: <priority:1><tag:N>\0<message:N>\0
+   *
+   * tag str
+   *   starts at buf->msg+1
+   * msg
+   *   starts at buf->msg+1+len(tag)+1
+   *
+   * The message may have been truncated by the kernel log driver.
+   * When that happens, we must null-terminate the message ourselves.
+   */
+  if (buf->len < 3) {
     /*
-     * format: <priority:1><tag:N>\0<message:N>\0
-     *
-     * tag str
-     *   starts at buf->msg+1
-     * msg
-     *   starts at buf->msg+1+len(tag)+1
-     *
-     * The message may have been truncated by the kernel log driver.
-     * When that happens, we must null-terminate the message ourselves.
+     * An well-formed entry must consist of at least a priority
+     * and two null characters
      */
-    if (buf->len < 3) {
-        /*
-         * An well-formed entry must consist of at least a priority
-         * and two null characters
-         */
-        fprintf(stderr, "+++ LOG: entry too small\n");
-        return -1;
-    }
+    fprintf(stderr, "+++ LOG: entry too small\n");
+    return -1;
+  }
 
-    int msgStart = -1;
-    int msgEnd = -1;
+  int msgStart = -1;
+  int msgEnd = -1;
 
-    int i;
-    char *msg = buf->msg;
-    struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
-    if (buf2->hdr_size) {
-        if ((buf2->hdr_size < sizeof(((struct log_msg *)NULL)->entry_v1)) ||
-                (buf2->hdr_size > sizeof(((struct log_msg *)NULL)->entry))) {
-            fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
-            return -1;
-        }
-        msg = ((char *)buf2) + buf2->hdr_size;
-        if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
-            entry->uid = ((struct logger_entry_v4 *)buf)->uid;
-        }
+  int i;
+  char* msg = buf->msg;
+  struct logger_entry_v2* buf2 = (struct logger_entry_v2*)buf;
+  if (buf2->hdr_size) {
+    if ((buf2->hdr_size < sizeof(((struct log_msg*)NULL)->entry_v1)) ||
+        (buf2->hdr_size > sizeof(((struct log_msg*)NULL)->entry))) {
+      fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
+      return -1;
     }
+    msg = ((char*)buf2) + buf2->hdr_size;
+    if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
+      entry->uid = ((struct logger_entry_v4*)buf)->uid;
+    }
+  }
+  for (i = 1; i < buf->len; i++) {
+    if (msg[i] == '\0') {
+      if (msgStart == -1) {
+        msgStart = i + 1;
+      } else {
+        msgEnd = i;
+        break;
+      }
+    }
+  }
+
+  if (msgStart == -1) {
+    /* +++ LOG: malformed log message, DYB */
     for (i = 1; i < buf->len; i++) {
-        if (msg[i] == '\0') {
-            if (msgStart == -1) {
-                msgStart = i + 1;
-            } else {
-                msgEnd = i;
-                break;
-            }
-        }
+      /* odd characters in tag? */
+      if ((msg[i] <= ' ') || (msg[i] == ':') || (msg[i] >= 0x7f)) {
+        msg[i] = '\0';
+        msgStart = i + 1;
+        break;
+      }
     }
-
     if (msgStart == -1) {
-        /* +++ LOG: malformed log message, DYB */
-        for (i = 1; i < buf->len; i++) {
-            /* odd characters in tag? */
-            if ((msg[i] <= ' ') || (msg[i] == ':') || (msg[i] >= 0x7f)) {
-                msg[i] = '\0';
-                msgStart = i + 1;
-                break;
-            }
-        }
-        if (msgStart == -1) {
-            msgStart = buf->len - 1; /* All tag, no message, print truncates */
-        }
+      msgStart = buf->len - 1; /* All tag, no message, print truncates */
     }
-    if (msgEnd == -1) {
-        /* incoming message not null-terminated; force it */
-        msgEnd = buf->len - 1; /* may result in msgEnd < msgStart */
-        msg[msgEnd] = '\0';
-    }
+  }
+  if (msgEnd == -1) {
+    /* incoming message not null-terminated; force it */
+    msgEnd = buf->len - 1; /* may result in msgEnd < msgStart */
+    msg[msgEnd] = '\0';
+  }
 
-    entry->priority = msg[0];
-    entry->tag = msg + 1;
-    entry->tagLen = msgStart - 1;
-    entry->message = msg + msgStart;
-    entry->messageLen = (msgEnd < msgStart) ? 0 : (msgEnd - msgStart);
+  entry->priority = msg[0];
+  entry->tag = msg + 1;
+  entry->tagLen = msgStart - 1;
+  entry->message = msg + msgStart;
+  entry->messageLen = (msgEnd < msgStart) ? 0 : (msgEnd - msgStart);
 
-    return 0;
+  return 0;
 }
 
 /*
  * Extract a 4-byte value from a byte stream.
  */
-static inline uint32_t get4LE(const uint8_t* src)
-{
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+static inline uint32_t get4LE(const uint8_t* src) {
+  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
 /*
  * Extract an 8-byte value from a byte stream.
  */
-static inline uint64_t get8LE(const uint8_t* src)
-{
-    uint32_t low, high;
+static inline uint64_t get8LE(const uint8_t* src) {
+  uint32_t low, high;
 
-    low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
-    high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
-    return ((uint64_t) high << 32) | (uint64_t) low;
+  low = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+  high = src[4] | (src[5] << 8) | (src[6] << 16) | (src[7] << 24);
+  return ((uint64_t)high << 32) | (uint64_t)low;
 }
 
 static bool findChar(const char** cp, size_t* len, int c) {
-    while ((*len) && isspace(*(*cp))) {
-        ++(*cp);
-        --(*len);
-    }
-    if (c == INT_MAX) return *len;
-    if ((*len) && (*(*cp) == c)) {
-        ++(*cp);
-        --(*len);
-        return true;
-    }
-    return false;
+  while ((*len) && isspace(*(*cp))) {
+    ++(*cp);
+    --(*len);
+  }
+  if (c == INT_MAX) return *len;
+  if ((*len) && (*(*cp) == c)) {
+    ++(*cp);
+    --(*len);
+    return true;
+  }
+  return false;
 }
 
 /*
@@ -650,334 +632,337 @@
  * Returns 0 on success, 1 on buffer full, -1 on failure.
  */
 enum objectType {
-    TYPE_OBJECTS      = '1',
-    TYPE_BYTES        = '2',
-    TYPE_MILLISECONDS = '3',
-    TYPE_ALLOCATIONS  = '4',
-    TYPE_ID           = '5',
-    TYPE_PERCENT      = '6'
+  TYPE_OBJECTS = '1',
+  TYPE_BYTES = '2',
+  TYPE_MILLISECONDS = '3',
+  TYPE_ALLOCATIONS = '4',
+  TYPE_ID = '5',
+  TYPE_PERCENT = '6'
 };
 
 static int android_log_printBinaryEvent(const unsigned char** pEventData,
-    size_t* pEventDataLen, char** pOutBuf, size_t* pOutBufLen,
-    const char** fmtStr, size_t* fmtLen)
-{
-    const unsigned char* eventData = *pEventData;
-    size_t eventDataLen = *pEventDataLen;
-    char* outBuf = *pOutBuf;
-    char* outBufSave = outBuf;
-    size_t outBufLen = *pOutBufLen;
-    size_t outBufLenSave = outBufLen;
-    unsigned char type;
-    size_t outCount;
-    int result = 0;
-    const char* cp;
-    size_t len;
-    int64_t lval;
+                                        size_t* pEventDataLen, char** pOutBuf,
+                                        size_t* pOutBufLen, const char** fmtStr,
+                                        size_t* fmtLen) {
+  const unsigned char* eventData = *pEventData;
+  size_t eventDataLen = *pEventDataLen;
+  char* outBuf = *pOutBuf;
+  char* outBufSave = outBuf;
+  size_t outBufLen = *pOutBufLen;
+  size_t outBufLenSave = outBufLen;
+  unsigned char type;
+  size_t outCount;
+  int result = 0;
+  const char* cp;
+  size_t len;
+  int64_t lval;
 
-    if (eventDataLen < 1) return -1;
+  if (eventDataLen < 1) return -1;
 
-    type = *eventData++;
-    eventDataLen--;
+  type = *eventData++;
+  eventDataLen--;
 
-    cp = NULL;
+  cp = NULL;
+  len = 0;
+  if (fmtStr && *fmtStr && fmtLen && *fmtLen && **fmtStr) {
+    cp = *fmtStr;
+    len = *fmtLen;
+  }
+  /*
+   * event.logtag format specification:
+   *
+   * Optionally, after the tag names can be put a description for the value(s)
+   * of the tag. Description are in the format
+   *    (<name>|data type[|data unit])
+   * Multiple values are separated by commas.
+   *
+   * The data type is a number from the following values:
+   * 1: int
+   * 2: long
+   * 3: string
+   * 4: list
+   * 5: float
+   *
+   * The data unit is a number taken from the following list:
+   * 1: Number of objects
+   * 2: Number of bytes
+   * 3: Number of milliseconds
+   * 4: Number of allocations
+   * 5: Id
+   * 6: Percent
+   * Default value for data of type int/long is 2 (bytes).
+   */
+  if (!cp || !findChar(&cp, &len, '(')) {
     len = 0;
-    if (fmtStr && *fmtStr && fmtLen && *fmtLen && **fmtStr) {
-        cp = *fmtStr;
-        len = *fmtLen;
+  } else {
+    char* outBufLastSpace = NULL;
+
+    findChar(&cp, &len, INT_MAX);
+    while (len && *cp && (*cp != '|') && (*cp != ')')) {
+      if (outBufLen <= 0) {
+        /* halt output */
+        goto no_room;
+      }
+      outBufLastSpace = isspace(*cp) ? outBuf : NULL;
+      *outBuf = *cp;
+      ++outBuf;
+      ++cp;
+      --outBufLen;
+      --len;
     }
-    /*
-     * event.logtag format specification:
-     *
-     * Optionally, after the tag names can be put a description for the value(s)
-     * of the tag. Description are in the format
-     *    (<name>|data type[|data unit])
-     * Multiple values are separated by commas.
-     *
-     * The data type is a number from the following values:
-     * 1: int
-     * 2: long
-     * 3: string
-     * 4: list
-     * 5: float
-     *
-     * The data unit is a number taken from the following list:
-     * 1: Number of objects
-     * 2: Number of bytes
-     * 3: Number of milliseconds
-     * 4: Number of allocations
-     * 5: Id
-     * 6: Percent
-     * Default value for data of type int/long is 2 (bytes).
-     */
-    if (!cp || !findChar(&cp, &len, '(')) {
+    if (outBufLastSpace) {
+      outBufLen += outBuf - outBufLastSpace;
+      outBuf = outBufLastSpace;
+    }
+    if (outBufLen <= 0) {
+      /* halt output */
+      goto no_room;
+    }
+    if (outBufSave != outBuf) {
+      *outBuf = '=';
+      ++outBuf;
+      --outBufLen;
+    }
+
+    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
+      static const unsigned char typeTable[] = {
+        EVENT_TYPE_INT, EVENT_TYPE_LONG, EVENT_TYPE_STRING, EVENT_TYPE_LIST,
+        EVENT_TYPE_FLOAT
+      };
+
+      if ((*cp >= '1') &&
+          (*cp < (char)('1' + (sizeof(typeTable) / sizeof(typeTable[0])))) &&
+          (type != typeTable[(size_t)(*cp - '1')]))
         len = 0;
-    } else {
-        char* outBufLastSpace = NULL;
 
-        findChar(&cp, &len, INT_MAX);
-        while (len && *cp && (*cp != '|') && (*cp != ')')) {
-            if (outBufLen <= 0) {
-                /* halt output */
-                goto no_room;
-            }
-            outBufLastSpace = isspace(*cp) ? outBuf : NULL;
-            *outBuf = *cp;
-            ++outBuf;
-            ++cp;
-            --outBufLen;
-            --len;
-        }
-        if (outBufLastSpace) {
-            outBufLen += outBuf - outBufLastSpace;
-            outBuf = outBufLastSpace;
-        }
-        if (outBufLen <= 0) {
-            /* halt output */
-            goto no_room;
-        }
-        if (outBufSave != outBuf) {
-            *outBuf = '=';
-            ++outBuf;
-            --outBufLen;
-        }
-
-        if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
-            static const unsigned char typeTable[] = {
-                EVENT_TYPE_INT,
-                EVENT_TYPE_LONG,
-                EVENT_TYPE_STRING,
-                EVENT_TYPE_LIST,
-                EVENT_TYPE_FLOAT
-            };
-
-            if ((*cp >= '1') &&
-                (*cp < (char)('1' + (sizeof(typeTable) / sizeof(typeTable[0])))) &&
-                (type != typeTable[(size_t)(*cp - '1')])) len = 0;
-
-            if (len) {
-                ++cp;
-                --len;
-            } else {
-                /* reset the format */
-                outBuf = outBufSave;
-                outBufLen = outBufLenSave;
-            }
-        }
+      if (len) {
+        ++cp;
+        --len;
+      } else {
+        /* reset the format */
+        outBuf = outBufSave;
+        outBufLen = outBufLenSave;
+      }
     }
-    outCount = 0;
-    lval = 0;
-    switch (type) {
+  }
+  outCount = 0;
+  lval = 0;
+  switch (type) {
     case EVENT_TYPE_INT:
-        /* 32-bit signed int */
-        {
-            int32_t ival;
+      /* 32-bit signed int */
+      {
+        int32_t ival;
 
-            if (eventDataLen < 4) return -1;
-            ival = get4LE(eventData);
-            eventData += 4;
-            eventDataLen -= 4;
+        if (eventDataLen < 4) return -1;
+        ival = get4LE(eventData);
+        eventData += 4;
+        eventDataLen -= 4;
 
-            lval = ival;
-        }
-        goto pr_lval;
+        lval = ival;
+      }
+      goto pr_lval;
     case EVENT_TYPE_LONG:
-        /* 64-bit signed long */
-        if (eventDataLen < 8) return -1;
-        lval = get8LE(eventData);
-        eventData += 8;
-        eventDataLen -= 8;
+      /* 64-bit signed long */
+      if (eventDataLen < 8) return -1;
+      lval = get8LE(eventData);
+      eventData += 8;
+      eventDataLen -= 8;
     pr_lval:
-        outCount = snprintf(outBuf, outBufLen, "%" PRId64, lval);
-        if (outCount < outBufLen) {
-            outBuf += outCount;
-            outBufLen -= outCount;
-        } else {
-            /* halt output */
-            goto no_room;
-        }
-        break;
+      outCount = snprintf(outBuf, outBufLen, "%" PRId64, lval);
+      if (outCount < outBufLen) {
+        outBuf += outCount;
+        outBufLen -= outCount;
+      } else {
+        /* halt output */
+        goto no_room;
+      }
+      break;
     case EVENT_TYPE_FLOAT:
-        /* float */
-        {
-            uint32_t ival;
-            float fval;
+      /* float */
+      {
+        uint32_t ival;
+        float fval;
 
-            if (eventDataLen < 4) return -1;
-            ival = get4LE(eventData);
-            fval = *(float*)&ival;
-            eventData += 4;
-            eventDataLen -= 4;
+        if (eventDataLen < 4) return -1;
+        ival = get4LE(eventData);
+        fval = *(float*)&ival;
+        eventData += 4;
+        eventDataLen -= 4;
 
-            outCount = snprintf(outBuf, outBufLen, "%f", fval);
-            if (outCount < outBufLen) {
-                outBuf += outCount;
-                outBufLen -= outCount;
-            } else {
-                /* halt output */
-                goto no_room;
-            }
+        outCount = snprintf(outBuf, outBufLen, "%f", fval);
+        if (outCount < outBufLen) {
+          outBuf += outCount;
+          outBufLen -= outCount;
+        } else {
+          /* halt output */
+          goto no_room;
         }
-        break;
+      }
+      break;
     case EVENT_TYPE_STRING:
-        /* UTF-8 chars, not NULL-terminated */
-        {
-            unsigned int strLen;
+      /* UTF-8 chars, not NULL-terminated */
+      {
+        unsigned int strLen;
 
-            if (eventDataLen < 4) return -1;
-            strLen = get4LE(eventData);
-            eventData += 4;
-            eventDataLen -= 4;
+        if (eventDataLen < 4) return -1;
+        strLen = get4LE(eventData);
+        eventData += 4;
+        eventDataLen -= 4;
 
-            if (eventDataLen < strLen) return -1;
-
-            if (cp && (strLen == 0)) {
-                /* reset the format if no content */
-                outBuf = outBufSave;
-                outBufLen = outBufLenSave;
-            }
-            if (strLen < outBufLen) {
-                memcpy(outBuf, eventData, strLen);
-                outBuf += strLen;
-                outBufLen -= strLen;
-            } else if (outBufLen > 0) {
-                /* copy what we can */
-                memcpy(outBuf, eventData, outBufLen);
-                outBuf += outBufLen;
-                outBufLen -= outBufLen;
-                goto no_room;
-            }
-            eventData += strLen;
-            eventDataLen -= strLen;
-            break;
+        if (eventDataLen < strLen) {
+          result = -1; /* mark truncated */
+          strLen = eventDataLen;
         }
-    case EVENT_TYPE_LIST:
-        /* N items, all different types */
-        {
-            unsigned char count;
-            int i;
 
-            if (eventDataLen < 1) return -1;
-
-            count = *eventData++;
-            eventDataLen--;
-
-            if (outBufLen <= 0) goto no_room;
-
-            *outBuf++ = '[';
-            outBufLen--;
-
-            for (i = 0; i < count; i++) {
-                result = android_log_printBinaryEvent(&eventData, &eventDataLen,
-                        &outBuf, &outBufLen, fmtStr, fmtLen);
-                if (result != 0) goto bail;
-
-                if (i < (count - 1)) {
-                    if (outBufLen <= 0) goto no_room;
-                    *outBuf++ = ',';
-                    outBufLen--;
-                }
-            }
-
-            if (outBufLen <= 0) goto no_room;
-
-            *outBuf++ = ']';
-            outBufLen--;
+        if (cp && (strLen == 0)) {
+          /* reset the format if no content */
+          outBuf = outBufSave;
+          outBufLen = outBufLenSave;
         }
+        if (strLen < outBufLen) {
+          memcpy(outBuf, eventData, strLen);
+          outBuf += strLen;
+          outBufLen -= strLen;
+        } else {
+          if (outBufLen > 0) {
+            /* copy what we can */
+            memcpy(outBuf, eventData, outBufLen);
+            outBuf += outBufLen;
+            outBufLen -= outBufLen;
+          }
+          if (!result) result = 1; /* if not truncated, return no room */
+        }
+        eventData += strLen;
+        eventDataLen -= strLen;
+        if (result != 0) goto bail;
         break;
-    default:
-        fprintf(stderr, "Unknown binary event type %d\n", type);
-        return -1;
-    }
-    if (cp && len) {
-        if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
-            switch (*cp) {
-            case TYPE_OBJECTS:
-                outCount = 0;
-                /* outCount = snprintf(outBuf, outBufLen, " objects"); */
-                break;
-            case TYPE_BYTES:
-                if ((lval != 0) && ((lval % 1024) == 0)) {
-                    /* repaint with multiplier */
-                    static const char suffixTable[] = { 'K', 'M', 'G', 'T' };
-                    size_t idx = 0;
-                    outBuf -= outCount;
-                    outBufLen += outCount;
-                    do {
-                        lval /= 1024;
-                        if ((lval % 1024) != 0) break;
-                    } while (++idx < ((sizeof(suffixTable) /
-                                       sizeof(suffixTable[0])) - 1));
-                    outCount = snprintf(outBuf, outBufLen,
-                                        "%" PRId64 "%cB",
-                                        lval, suffixTable[idx]);
-                } else {
-                    outCount = snprintf(outBuf, outBufLen, "B");
-                }
-                break;
-            case TYPE_MILLISECONDS:
-                if (((lval <= -1000) || (1000 <= lval)) &&
-                        (outBufLen || (outBuf[-1] == '0'))) {
-                    /* repaint as (fractional) seconds, possibly saving space */
-                    if (outBufLen) outBuf[0] = outBuf[-1];
-                    outBuf[-1] = outBuf[-2];
-                    outBuf[-2] = outBuf[-3];
-                    outBuf[-3] = '.';
-                    while ((outBufLen == 0) || (*outBuf == '0')) {
-                        --outBuf;
-                        ++outBufLen;
-                    }
-                    if (*outBuf != '.') {
-                       ++outBuf;
-                       --outBufLen;
-                    }
-                    outCount = snprintf(outBuf, outBufLen, "s");
-                } else {
-                    outCount = snprintf(outBuf, outBufLen, "ms");
-                }
-                break;
-            case TYPE_ALLOCATIONS:
-                outCount = 0;
-                /* outCount = snprintf(outBuf, outBufLen, " allocations"); */
-                break;
-            case TYPE_ID:
-                outCount = 0;
-                break;
-            case TYPE_PERCENT:
-                outCount = snprintf(outBuf, outBufLen, "%%");
-                break;
-            default: /* ? */
-                outCount = 0;
-                break;
-            }
-            ++cp;
-            --len;
-            if (outCount < outBufLen) {
-                outBuf += outCount;
-                outBufLen -= outCount;
-            } else if (outCount) {
-                /* halt output */
-                goto no_room;
-            }
+      }
+    case EVENT_TYPE_LIST:
+      /* N items, all different types */
+      {
+        unsigned char count;
+        int i;
+
+        if (eventDataLen < 1) return -1;
+
+        count = *eventData++;
+        eventDataLen--;
+
+        if (outBufLen <= 0) goto no_room;
+
+        *outBuf++ = '[';
+        outBufLen--;
+
+        for (i = 0; i < count; i++) {
+          result = android_log_printBinaryEvent(
+              &eventData, &eventDataLen, &outBuf, &outBufLen, fmtStr, fmtLen);
+          if (result != 0) goto bail;
+
+          if (i < (count - 1)) {
+            if (outBufLen <= 0) goto no_room;
+            *outBuf++ = ',';
+            outBufLen--;
+          }
         }
-        if (!findChar(&cp, &len, ')')) len = 0;
-        if (!findChar(&cp, &len, ',')) len = 0;
+
+        if (outBufLen <= 0) goto no_room;
+
+        *outBuf++ = ']';
+        outBufLen--;
+      }
+      break;
+    default:
+      fprintf(stderr, "Unknown binary event type %d\n", type);
+      return -1;
+  }
+  if (cp && len) {
+    if (findChar(&cp, &len, '|') && findChar(&cp, &len, INT_MAX)) {
+      switch (*cp) {
+        case TYPE_OBJECTS:
+          outCount = 0;
+          /* outCount = snprintf(outBuf, outBufLen, " objects"); */
+          break;
+        case TYPE_BYTES:
+          if ((lval != 0) && ((lval % 1024) == 0)) {
+            /* repaint with multiplier */
+            static const char suffixTable[] = { 'K', 'M', 'G', 'T' };
+            size_t idx = 0;
+            outBuf -= outCount;
+            outBufLen += outCount;
+            do {
+              lval /= 1024;
+              if ((lval % 1024) != 0) break;
+            } while (++idx <
+                     ((sizeof(suffixTable) / sizeof(suffixTable[0])) - 1));
+            outCount = snprintf(outBuf, outBufLen, "%" PRId64 "%cB", lval,
+                                suffixTable[idx]);
+          } else {
+            outCount = snprintf(outBuf, outBufLen, "B");
+          }
+          break;
+        case TYPE_MILLISECONDS:
+          if (((lval <= -1000) || (1000 <= lval)) &&
+              (outBufLen || (outBuf[-1] == '0'))) {
+            /* repaint as (fractional) seconds, possibly saving space */
+            if (outBufLen) outBuf[0] = outBuf[-1];
+            outBuf[-1] = outBuf[-2];
+            outBuf[-2] = outBuf[-3];
+            outBuf[-3] = '.';
+            while ((outBufLen == 0) || (*outBuf == '0')) {
+              --outBuf;
+              ++outBufLen;
+            }
+            if (*outBuf != '.') {
+              ++outBuf;
+              --outBufLen;
+            }
+            outCount = snprintf(outBuf, outBufLen, "s");
+          } else {
+            outCount = snprintf(outBuf, outBufLen, "ms");
+          }
+          break;
+        case TYPE_ALLOCATIONS:
+          outCount = 0;
+          /* outCount = snprintf(outBuf, outBufLen, " allocations"); */
+          break;
+        case TYPE_ID:
+          outCount = 0;
+          break;
+        case TYPE_PERCENT:
+          outCount = snprintf(outBuf, outBufLen, "%%");
+          break;
+        default: /* ? */
+          outCount = 0;
+          break;
+      }
+      ++cp;
+      --len;
+      if (outCount < outBufLen) {
+        outBuf += outCount;
+        outBufLen -= outCount;
+      } else if (outCount) {
+        /* halt output */
+        goto no_room;
+      }
     }
+    if (!findChar(&cp, &len, ')')) len = 0;
+    if (!findChar(&cp, &len, ',')) len = 0;
+  }
 
 bail:
-    *pEventData = eventData;
-    *pEventDataLen = eventDataLen;
-    *pOutBuf = outBuf;
-    *pOutBufLen = outBufLen;
-    if (cp) {
-        *fmtStr = cp;
-        *fmtLen = len;
-    }
-    return result;
+  *pEventData = eventData;
+  *pEventDataLen = eventDataLen;
+  *pOutBuf = outBuf;
+  *pOutBufLen = outBufLen;
+  if (cp) {
+    *fmtStr = cp;
+    *fmtLen = len;
+  }
+  return result;
 
 no_room:
-    result = 1;
-    goto bail;
+  result = 1;
+  goto bail;
 }
 
 /**
@@ -989,144 +974,144 @@
  * here.
  */
 LIBLOG_ABI_PUBLIC int android_log_processBinaryLogBuffer(
-        struct logger_entry *buf,
-        AndroidLogEntry *entry,
-        const EventTagMap *map __unused, // only on !__ANDROID__
-        char *messageBuf, int messageBufLen)
-{
-    size_t inCount;
-    uint32_t tagIndex;
-    const unsigned char* eventData;
+    struct logger_entry* buf, AndroidLogEntry* entry,
+    const EventTagMap* map __unused, /* only on !__ANDROID__ */
+    char* messageBuf, int messageBufLen) {
+  size_t inCount;
+  uint32_t tagIndex;
+  const unsigned char* eventData;
 
-    entry->tv_sec = buf->sec;
-    entry->tv_nsec = buf->nsec;
-    entry->priority = ANDROID_LOG_INFO;
-    entry->uid = -1;
-    entry->pid = buf->pid;
-    entry->tid = buf->tid;
+  entry->message = NULL;
+  entry->messageLen = 0;
 
-    /*
-     * Pull the tag out, fill in some additional details based on incoming
-     * buffer version (v3 adds lid, v4 adds uid).
-     */
-    eventData = (const unsigned char*) buf->msg;
-    struct logger_entry_v2 *buf2 = (struct logger_entry_v2 *)buf;
+  entry->tv_sec = buf->sec;
+  entry->tv_nsec = buf->nsec;
+  entry->priority = ANDROID_LOG_INFO;
+  entry->uid = -1;
+  entry->pid = buf->pid;
+  entry->tid = buf->tid;
+
+  /*
+   * Pull the tag out, fill in some additional details based on incoming
+   * buffer version (v3 adds lid, v4 adds uid).
+   */
+  eventData = (const unsigned char*)buf->msg;
+  struct logger_entry_v2* buf2 = (struct logger_entry_v2*)buf;
+  if (buf2->hdr_size) {
+    if ((buf2->hdr_size < sizeof(((struct log_msg*)NULL)->entry_v1)) ||
+        (buf2->hdr_size > sizeof(((struct log_msg*)NULL)->entry))) {
+      fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
+      return -1;
+    }
+    eventData = ((unsigned char*)buf2) + buf2->hdr_size;
+    if ((buf2->hdr_size >= sizeof(struct logger_entry_v3)) &&
+        (((struct logger_entry_v3*)buf)->lid == LOG_ID_SECURITY)) {
+      entry->priority = ANDROID_LOG_WARN;
+    }
+    if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
+      entry->uid = ((struct logger_entry_v4*)buf)->uid;
+    }
+  }
+  inCount = buf->len;
+  if (inCount < 4) return -1;
+  tagIndex = get4LE(eventData);
+  eventData += 4;
+  inCount -= 4;
+
+  entry->tagLen = 0;
+  entry->tag = NULL;
+#ifdef __ANDROID__
+  if (map != NULL) {
+    entry->tag = android_lookupEventTag_len(map, &entry->tagLen, tagIndex);
+  }
+#endif
+
+  /*
+   * If we don't have a map, or didn't find the tag number in the map,
+   * stuff a generated tag value into the start of the output buffer and
+   * shift the buffer pointers down.
+   */
+  if (entry->tag == NULL) {
+    size_t tagLen;
+
+    tagLen = snprintf(messageBuf, messageBufLen, "[%" PRIu32 "]", tagIndex);
+    if (tagLen >= (size_t)messageBufLen) {
+      tagLen = messageBufLen - 1;
+    }
+    entry->tag = messageBuf;
+    entry->tagLen = tagLen;
+    messageBuf += tagLen + 1;
+    messageBufLen -= tagLen + 1;
+  }
+
+  /*
+   * Format the event log data into the buffer.
+   */
+  const char* fmtStr = NULL;
+  size_t fmtLen = 0;
+#ifdef __ANDROID__
+  if (descriptive_output && map) {
+    fmtStr = android_lookupEventFormat_len(map, &fmtLen, tagIndex);
+  }
+#endif
+
+  char* outBuf = messageBuf;
+  size_t outRemaining = messageBufLen - 1; /* leave one for nul byte */
+  int result = 0;
+
+  if ((inCount > 0) || fmtLen) {
+    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf,
+                                          &outRemaining, &fmtStr, &fmtLen);
+  }
+  if ((result == 1) && fmtStr) {
+    /* We overflowed :-(, let's repaint the line w/o format dressings */
+    eventData = (const unsigned char*)buf->msg;
     if (buf2->hdr_size) {
-        if ((buf2->hdr_size < sizeof(((struct log_msg *)NULL)->entry_v1)) ||
-                (buf2->hdr_size > sizeof(((struct log_msg *)NULL)->entry))) {
-            fprintf(stderr, "+++ LOG: entry illegal hdr_size\n");
-            return -1;
-        }
-        eventData = ((unsigned char *)buf2) + buf2->hdr_size;
-        if ((buf2->hdr_size >= sizeof(struct logger_entry_v3)) &&
-                (((struct logger_entry_v3 *)buf)->lid == LOG_ID_SECURITY)) {
-            entry->priority = ANDROID_LOG_WARN;
-        }
-        if (buf2->hdr_size >= sizeof(struct logger_entry_v4)) {
-            entry->uid = ((struct logger_entry_v4 *)buf)->uid;
-        }
+      eventData = ((unsigned char*)buf2) + buf2->hdr_size;
     }
-    inCount = buf->len;
-    if (inCount < 4) return -1;
-    tagIndex = get4LE(eventData);
     eventData += 4;
-    inCount -= 4;
-
-    entry->tagLen = 0;
-    entry->tag = NULL;
-#ifdef __ANDROID__
-    if (map != NULL) {
-        entry->tag = android_lookupEventTag_len(map, &entry->tagLen, tagIndex);
+    outBuf = messageBuf;
+    outRemaining = messageBufLen - 1;
+    result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf,
+                                          &outRemaining, NULL, NULL);
+  }
+  if (result < 0) {
+    fprintf(stderr, "Binary log entry conversion failed\n");
+  }
+  if (result) {
+    if (!outRemaining) {
+      /* make space to leave an indicator */
+      --outBuf;
+      ++outRemaining;
     }
-#endif
+    *outBuf++ = (result < 0) ? '!' : '^'; /* Error or Truncation? */
+    outRemaining--;
+    /* pretend we ate all the data to prevent log stutter */
+    inCount = 0;
+    if (result > 0) result = 0;
+  }
 
-    /*
-     * If we don't have a map, or didn't find the tag number in the map,
-     * stuff a generated tag value into the start of the output buffer and
-     * shift the buffer pointers down.
-     */
-    if (entry->tag == NULL) {
-        size_t tagLen;
+  /* eat the silly terminating '\n' */
+  if (inCount == 1 && *eventData == '\n') {
+    eventData++;
+    inCount--;
+  }
 
-        tagLen = snprintf(messageBuf, messageBufLen, "[%" PRIu32 "]", tagIndex);
-        if (tagLen >= (size_t)messageBufLen) {
-            tagLen = messageBufLen - 1;
-        }
-        entry->tag = messageBuf;
-        entry->tagLen = tagLen;
-        messageBuf += tagLen + 1;
-        messageBufLen -= tagLen + 1;
-    }
+  if (inCount != 0) {
+    fprintf(stderr, "Warning: leftover binary log data (%zu bytes)\n", inCount);
+  }
 
-    /*
-     * Format the event log data into the buffer.
-     */
-    const char* fmtStr = NULL;
-    size_t fmtLen = 0;
-#ifdef __ANDROID__
-    if (descriptive_output && map) {
-        fmtStr = android_lookupEventFormat_len(map, &fmtLen, tagIndex);
-    }
-#endif
+  /*
+   * Terminate the buffer.  The NUL byte does not count as part of
+   * entry->messageLen.
+   */
+  *outBuf = '\0';
+  entry->messageLen = outBuf - messageBuf;
+  assert(entry->messageLen == (messageBufLen - 1) - outRemaining);
 
-    char* outBuf = messageBuf;
-    size_t outRemaining = messageBufLen - 1; /* leave one for nul byte */
-    int result = 0;
+  entry->message = messageBuf;
 
-    if ((inCount > 0) || fmtLen) {
-        result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf,
-                                              &outRemaining, &fmtStr, &fmtLen);
-    }
-    if ((result == 1) && fmtStr) {
-        /* We overflowed :-(, let's repaint the line w/o format dressings */
-        eventData = (const unsigned char*)buf->msg;
-        if (buf2->hdr_size) {
-            eventData = ((unsigned char *)buf2) + buf2->hdr_size;
-        }
-        eventData += 4;
-        outBuf = messageBuf;
-        outRemaining = messageBufLen - 1;
-        result = android_log_printBinaryEvent(&eventData, &inCount, &outBuf,
-                                              &outRemaining, NULL, NULL);
-    }
-    if (result < 0) {
-        fprintf(stderr, "Binary log entry conversion failed\n");
-    }
-    if (result) {
-        if (!outRemaining) {
-            /* make space to leave an indicator */
-            --outBuf;
-            ++outRemaining;
-        }
-        *outBuf++ = (result < 0) ? '!' : '^'; /* Error or Truncation? */
-        outRemaining--;
-        /* pretend we ate all the data to prevent log stutter */
-        inCount = 0;
-        if (result > 0) result = 0;
-    }
-
-    /* eat the silly terminating '\n' */
-    if (inCount == 1 && *eventData == '\n') {
-        eventData++;
-        inCount--;
-    }
-
-    if (inCount != 0) {
-        fprintf(stderr,
-            "Warning: leftover binary log data (%zu bytes)\n", inCount);
-    }
-
-    /*
-     * Terminate the buffer.  The NUL byte does not count as part of
-     * entry->messageLen.
-     */
-    *outBuf = '\0';
-    entry->messageLen = outBuf - messageBuf;
-    assert(entry->messageLen == (messageBufLen-1) - outRemaining);
-
-    entry->message = messageBuf;
-
-    return result;
+  return result;
 }
 
 /*
@@ -1141,388 +1126,377 @@
  * _also_ be part of libutils/Unicode.cpp if its usefullness needs to
  * propagate globally.
  */
-LIBLOG_WEAK ssize_t utf8_character_length(const char *src, size_t len)
-{
-    const char *cur = src;
-    const char first_char = *cur++;
-    static const uint32_t kUnicodeMaxCodepoint = 0x0010FFFF;
-    int32_t mask, to_ignore_mask;
-    size_t num_to_read;
-    uint32_t utf32;
+LIBLOG_WEAK ssize_t utf8_character_length(const char* src, size_t len) {
+  const char* cur = src;
+  const char first_char = *cur++;
+  static const uint32_t kUnicodeMaxCodepoint = 0x0010FFFF;
+  int32_t mask, to_ignore_mask;
+  size_t num_to_read;
+  uint32_t utf32;
 
-    if ((first_char & 0x80) == 0) { /* ASCII */
-        return first_char ? 1 : -1;
-    }
+  if ((first_char & 0x80) == 0) { /* ASCII */
+    return first_char ? 1 : -1;
+  }
 
-    /*
-     * (UTF-8's character must not be like 10xxxxxx,
-     *  but 110xxxxx, 1110xxxx, ... or 1111110x)
-     */
-    if ((first_char & 0x40) == 0) {
-        return -1;
-    }
+  /*
+   * (UTF-8's character must not be like 10xxxxxx,
+   *  but 110xxxxx, 1110xxxx, ... or 1111110x)
+   */
+  if ((first_char & 0x40) == 0) {
+    return -1;
+  }
 
-    for (utf32 = 1, num_to_read = 1, mask = 0x40, to_ignore_mask = 0x80;
-         num_to_read < 5 && (first_char & mask);
-         num_to_read++, to_ignore_mask |= mask, mask >>= 1) {
-        if (num_to_read > len) {
-            return -1;
-        }
-        if ((*cur & 0xC0) != 0x80) { /* can not be 10xxxxxx? */
-            return -1;
-        }
-        utf32 = (utf32 << 6) + (*cur++ & 0b00111111);
+  for (utf32 = 1, num_to_read = 1, mask = 0x40, to_ignore_mask = 0x80;
+       num_to_read < 5 && (first_char & mask);
+       num_to_read++, to_ignore_mask |= mask, mask >>= 1) {
+    if (num_to_read > len) {
+      return -1;
     }
-    /* "first_char" must be (110xxxxx - 11110xxx) */
-    if (num_to_read >= 5) {
-        return -1;
+    if ((*cur & 0xC0) != 0x80) { /* can not be 10xxxxxx? */
+      return -1;
     }
-    to_ignore_mask |= mask;
-    utf32 |= ((~to_ignore_mask) & first_char) << (6 * (num_to_read - 1));
-    if (utf32 > kUnicodeMaxCodepoint) {
-        return -1;
-    }
-    return num_to_read;
+    utf32 = (utf32 << 6) + (*cur++ & 0b00111111);
+  }
+  /* "first_char" must be (110xxxxx - 11110xxx) */
+  if (num_to_read >= 5) {
+    return -1;
+  }
+  to_ignore_mask |= mask;
+  utf32 |= ((~to_ignore_mask) & first_char) << (6 * (num_to_read - 1));
+  if (utf32 > kUnicodeMaxCodepoint) {
+    return -1;
+  }
+  return num_to_read;
 }
 
 /*
  * Convert to printable from message to p buffer, return string length. If p is
  * NULL, do not copy, but still return the expected string length.
  */
-static size_t convertPrintable(char *p, const char *message, size_t messageLen)
-{
-    char *begin = p;
-    bool print = p != NULL;
+static size_t convertPrintable(char* p, const char* message, size_t messageLen) {
+  char* begin = p;
+  bool print = p != NULL;
 
-    while (messageLen) {
-        char buf[6];
-        ssize_t len = sizeof(buf) - 1;
-        if ((size_t)len > messageLen) {
-            len = messageLen;
+  while (messageLen) {
+    char buf[6];
+    ssize_t len = sizeof(buf) - 1;
+    if ((size_t)len > messageLen) {
+      len = messageLen;
+    }
+    len = utf8_character_length(message, len);
+
+    if (len < 0) {
+      snprintf(buf, sizeof(buf),
+               ((messageLen > 1) && isdigit(message[1])) ? "\\%03o" : "\\%o",
+               *message & 0377);
+      len = 1;
+    } else {
+      buf[0] = '\0';
+      if (len == 1) {
+        if (*message == '\a') {
+          strcpy(buf, "\\a");
+        } else if (*message == '\b') {
+          strcpy(buf, "\\b");
+        } else if (*message == '\t') {
+          strcpy(buf, "\t"); /* Do not escape tabs */
+        } else if (*message == '\v') {
+          strcpy(buf, "\\v");
+        } else if (*message == '\f') {
+          strcpy(buf, "\\f");
+        } else if (*message == '\r') {
+          strcpy(buf, "\\r");
+        } else if (*message == '\\') {
+          strcpy(buf, "\\\\");
+        } else if ((*message < ' ') || (*message & 0x80)) {
+          snprintf(buf, sizeof(buf), "\\%o", *message & 0377);
         }
-        len = utf8_character_length(message, len);
-
-        if (len < 0) {
-            snprintf(buf, sizeof(buf),
-                     ((messageLen > 1) && isdigit(message[1]))
-                         ? "\\%03o"
-                         : "\\%o",
-                     *message & 0377);
-            len = 1;
-        } else {
-            buf[0] = '\0';
-            if (len == 1) {
-                if (*message == '\a') {
-                    strcpy(buf, "\\a");
-                } else if (*message == '\b') {
-                    strcpy(buf, "\\b");
-                } else if (*message == '\t') {
-                    strcpy(buf, "\t"); // Do not escape tabs
-                } else if (*message == '\v') {
-                    strcpy(buf, "\\v");
-                } else if (*message == '\f') {
-                    strcpy(buf, "\\f");
-                } else if (*message == '\r') {
-                    strcpy(buf, "\\r");
-                } else if (*message == '\\') {
-                    strcpy(buf, "\\\\");
-                } else if ((*message < ' ') || (*message & 0x80)) {
-                    snprintf(buf, sizeof(buf), "\\%o", *message & 0377);
-                }
-            }
-            if (!buf[0]) {
-                strncpy(buf, message, len);
-                buf[len] = '\0';
-            }
-        }
-        if (print) {
-            strcpy(p, buf);
-        }
-        p += strlen(buf);
-        message += len;
-        messageLen -= len;
+      }
+      if (!buf[0]) {
+        strncpy(buf, message, len);
+        buf[len] = '\0';
+      }
     }
-    return p - begin;
+    if (print) {
+      strcpy(p, buf);
+    }
+    p += strlen(buf);
+    message += len;
+    messageLen -= len;
+  }
+  return p - begin;
 }
 
-static char *readSeconds(char *e, struct timespec *t)
-{
-    unsigned long multiplier;
-    char *p;
-    t->tv_sec = strtoul(e, &p, 10);
-    if (*p != '.') {
-        return NULL;
-    }
-    t->tv_nsec = 0;
-    multiplier = NS_PER_SEC;
-    while (isdigit(*++p) && (multiplier /= 10)) {
-        t->tv_nsec += (*p - '0') * multiplier;
-    }
-    return p;
+static char* readSeconds(char* e, struct timespec* t) {
+  unsigned long multiplier;
+  char* p;
+  t->tv_sec = strtoul(e, &p, 10);
+  if (*p != '.') {
+    return NULL;
+  }
+  t->tv_nsec = 0;
+  multiplier = NS_PER_SEC;
+  while (isdigit(*++p) && (multiplier /= 10)) {
+    t->tv_nsec += (*p - '0') * multiplier;
+  }
+  return p;
 }
 
-static struct timespec *sumTimespec(struct timespec *left,
-                                    struct timespec *right)
-{
-    left->tv_nsec += right->tv_nsec;
-    left->tv_sec += right->tv_sec;
-    if (left->tv_nsec >= (long)NS_PER_SEC) {
-        left->tv_nsec -= NS_PER_SEC;
-        left->tv_sec += 1;
-    }
-    return left;
+static struct timespec* sumTimespec(struct timespec* left,
+                                    struct timespec* right) {
+  left->tv_nsec += right->tv_nsec;
+  left->tv_sec += right->tv_sec;
+  if (left->tv_nsec >= (long)NS_PER_SEC) {
+    left->tv_nsec -= NS_PER_SEC;
+    left->tv_sec += 1;
+  }
+  return left;
 }
 
-static struct timespec *subTimespec(struct timespec *result,
-                                    struct timespec *left,
-                                    struct timespec *right)
-{
-    result->tv_nsec = left->tv_nsec - right->tv_nsec;
-    result->tv_sec = left->tv_sec - right->tv_sec;
-    if (result->tv_nsec < 0) {
-        result->tv_nsec += NS_PER_SEC;
-        result->tv_sec -= 1;
-    }
-    return result;
+static struct timespec* subTimespec(struct timespec* result,
+                                    struct timespec* left,
+                                    struct timespec* right) {
+  result->tv_nsec = left->tv_nsec - right->tv_nsec;
+  result->tv_sec = left->tv_sec - right->tv_sec;
+  if (result->tv_nsec < 0) {
+    result->tv_nsec += NS_PER_SEC;
+    result->tv_sec -= 1;
+  }
+  return result;
 }
 
-static long long nsecTimespec(struct timespec *now)
-{
-    return (long long)now->tv_sec * NS_PER_SEC + now->tv_nsec;
+static long long nsecTimespec(struct timespec* now) {
+  return (long long)now->tv_sec * NS_PER_SEC + now->tv_nsec;
 }
 
 #ifdef __ANDROID__
-static void convertMonotonic(struct timespec *result,
-                             const AndroidLogEntry *entry)
-{
-    struct listnode *node;
-    struct conversionList {
-        struct listnode node; /* first */
-        struct timespec time;
-        struct timespec convert;
-    } *list, *next;
-    struct timespec time, convert;
+static void convertMonotonic(struct timespec* result,
+                             const AndroidLogEntry* entry) {
+  struct listnode* node;
+  struct conversionList {
+    struct listnode node; /* first */
+    struct timespec time;
+    struct timespec convert;
+  } * list, *next;
+  struct timespec time, convert;
 
-    /* If we do not have a conversion list, build one up */
-    if (list_empty(&convertHead)) {
-        bool suspended_pending = false;
-        struct timespec suspended_monotonic = { 0, 0 };
-        struct timespec suspended_diff = { 0, 0 };
+  /* If we do not have a conversion list, build one up */
+  if (list_empty(&convertHead)) {
+    bool suspended_pending = false;
+    struct timespec suspended_monotonic = { 0, 0 };
+    struct timespec suspended_diff = { 0, 0 };
 
-        /*
-         * Read dmesg for _some_ synchronization markers and insert
-         * Anything in the Android Logger before the dmesg logging span will
-         * be highly suspect regarding the monotonic time calculations.
-         */
-        FILE *p = popen("/system/bin/dmesg", "re");
-        if (p) {
-            char *line = NULL;
-            size_t len = 0;
-            while (getline(&line, &len, p) > 0) {
-                static const char suspend[] = "PM: suspend entry ";
-                static const char resume[] = "PM: suspend exit ";
-                static const char healthd[] = "healthd";
-                static const char battery[] = ": battery ";
-                static const char suspended[] = "Suspended for ";
-                struct timespec monotonic;
-                struct tm tm;
-                char *cp, *e = line;
-                bool add_entry = true;
+    /*
+     * Read dmesg for _some_ synchronization markers and insert
+     * Anything in the Android Logger before the dmesg logging span will
+     * be highly suspect regarding the monotonic time calculations.
+     */
+    FILE* p = popen("/system/bin/dmesg", "re");
+    if (p) {
+      char* line = NULL;
+      size_t len = 0;
+      while (getline(&line, &len, p) > 0) {
+        static const char suspend[] = "PM: suspend entry ";
+        static const char resume[] = "PM: suspend exit ";
+        static const char healthd[] = "healthd";
+        static const char battery[] = ": battery ";
+        static const char suspended[] = "Suspended for ";
+        struct timespec monotonic;
+        struct tm tm;
+        char *cp, *e = line;
+        bool add_entry = true;
 
-                if (*e == '<') {
-                    while (*e && (*e != '>')) {
-                        ++e;
-                    }
-                    if (*e != '>') {
-                        continue;
-                    }
-                }
-                if (*e != '[') {
-                    continue;
-                }
-                while (*++e == ' ') {
-                    ;
-                }
-                e = readSeconds(e, &monotonic);
-                if (!e || (*e != ']')) {
-                    continue;
-                }
-
-                if ((e = strstr(e, suspend))) {
-                    e += sizeof(suspend) - 1;
-                } else if ((e = strstr(line, resume))) {
-                    e += sizeof(resume) - 1;
-                } else if (((e = strstr(line, healthd)))
-                        && ((e = strstr(e + sizeof(healthd) - 1, battery)))) {
-                    /* NB: healthd is roughly 150us late, worth the price to
-                     * deal with ntp-induced or hardware clock drift. */
-                    e += sizeof(battery) - 1;
-                } else if ((e = strstr(line, suspended))) {
-                    e += sizeof(suspended) - 1;
-                    e = readSeconds(e, &time);
-                    if (!e) {
-                        continue;
-                    }
-                    add_entry = false;
-                    suspended_pending = true;
-                    suspended_monotonic = monotonic;
-                    suspended_diff = time;
-                } else {
-                    continue;
-                }
-                if (add_entry) {
-                    /* look for "????-??-?? ??:??:??.????????? UTC" */
-                    cp = strstr(e, " UTC");
-                    if (!cp || ((cp - e) < 29) || (cp[-10] != '.')) {
-                        continue;
-                    }
-                    e = cp - 29;
-                    cp = readSeconds(cp - 10, &time);
-                    if (!cp) {
-                        continue;
-                    }
-                    cp = strptime(e, "%Y-%m-%d %H:%M:%S.", &tm);
-                    if (!cp) {
-                        continue;
-                    }
-                    cp = getenv(tz);
-                    if (cp) {
-                        cp = strdup(cp);
-                    }
-                    setenv(tz, utc, 1);
-                    time.tv_sec = mktime(&tm);
-                    if (cp) {
-                        setenv(tz, cp, 1);
-                        free(cp);
-                    } else {
-                        unsetenv(tz);
-                    }
-                    list = calloc(1, sizeof(struct conversionList));
-                    list_init(&list->node);
-                    list->time = time;
-                    subTimespec(&list->convert, &time, &monotonic);
-                    list_add_tail(&convertHead, &list->node);
-                }
-                if (suspended_pending && !list_empty(&convertHead)) {
-                    list = node_to_item(list_tail(&convertHead),
-                                        struct conversionList, node);
-                    if (subTimespec(&time,
-                                    subTimespec(&time,
-                                                &list->time,
-                                                &list->convert),
-                                    &suspended_monotonic)->tv_sec > 0) {
-                        /* resume, what is convert factor before? */
-                        subTimespec(&convert, &list->convert, &suspended_diff);
-                    } else {
-                        /* suspend */
-                        convert = list->convert;
-                    }
-                    time = suspended_monotonic;
-                    sumTimespec(&time, &convert);
-                    /* breakpoint just before sleep */
-                    list = calloc(1, sizeof(struct conversionList));
-                    list_init(&list->node);
-                    list->time = time;
-                    list->convert = convert;
-                    list_add_tail(&convertHead, &list->node);
-                    /* breakpoint just after sleep */
-                    list = calloc(1, sizeof(struct conversionList));
-                    list_init(&list->node);
-                    list->time = time;
-                    sumTimespec(&list->time, &suspended_diff);
-                    list->convert = convert;
-                    sumTimespec(&list->convert, &suspended_diff);
-                    list_add_tail(&convertHead, &list->node);
-                    suspended_pending = false;
-                }
-            }
-            pclose(p);
+        if (*e == '<') {
+          while (*e && (*e != '>')) {
+            ++e;
+          }
+          if (*e != '>') {
+            continue;
+          }
         }
-        /* last entry is our current time conversion */
-        list = calloc(1, sizeof(struct conversionList));
-        list_init(&list->node);
-        clock_gettime(CLOCK_REALTIME, &list->time);
-        clock_gettime(CLOCK_MONOTONIC, &convert);
-        clock_gettime(CLOCK_MONOTONIC, &time);
-        /* Correct for instant clock_gettime latency (syscall or ~30ns) */
-        subTimespec(&time, &convert, subTimespec(&time, &time, &convert));
-        /* Calculate conversion factor */
-        subTimespec(&list->convert, &list->time, &time);
-        list_add_tail(&convertHead, &list->node);
-        if (suspended_pending) {
-            /* manufacture a suspend @ point before */
+        if (*e != '[') {
+          continue;
+        }
+        while (*++e == ' ') {
+          ;
+        }
+        e = readSeconds(e, &monotonic);
+        if (!e || (*e != ']')) {
+          continue;
+        }
+
+        if ((e = strstr(e, suspend))) {
+          e += sizeof(suspend) - 1;
+        } else if ((e = strstr(line, resume))) {
+          e += sizeof(resume) - 1;
+        } else if (((e = strstr(line, healthd))) &&
+                   ((e = strstr(e + sizeof(healthd) - 1, battery)))) {
+          /* NB: healthd is roughly 150us late, worth the price to
+           * deal with ntp-induced or hardware clock drift. */
+          e += sizeof(battery) - 1;
+        } else if ((e = strstr(line, suspended))) {
+          e += sizeof(suspended) - 1;
+          e = readSeconds(e, &time);
+          if (!e) {
+            continue;
+          }
+          add_entry = false;
+          suspended_pending = true;
+          suspended_monotonic = monotonic;
+          suspended_diff = time;
+        } else {
+          continue;
+        }
+        if (add_entry) {
+          /* look for "????-??-?? ??:??:??.????????? UTC" */
+          cp = strstr(e, " UTC");
+          if (!cp || ((cp - e) < 29) || (cp[-10] != '.')) {
+            continue;
+          }
+          e = cp - 29;
+          cp = readSeconds(cp - 10, &time);
+          if (!cp) {
+            continue;
+          }
+          cp = strptime(e, "%Y-%m-%d %H:%M:%S.", &tm);
+          if (!cp) {
+            continue;
+          }
+          cp = getenv(tz);
+          if (cp) {
+            cp = strdup(cp);
+          }
+          setenv(tz, utc, 1);
+          time.tv_sec = mktime(&tm);
+          if (cp) {
+            setenv(tz, cp, 1);
+            free(cp);
+          } else {
+            unsetenv(tz);
+          }
+          list = calloc(1, sizeof(struct conversionList));
+          list_init(&list->node);
+          list->time = time;
+          subTimespec(&list->convert, &time, &monotonic);
+          list_add_tail(&convertHead, &list->node);
+        }
+        if (suspended_pending && !list_empty(&convertHead)) {
+          list = node_to_item(list_tail(&convertHead), struct conversionList,
+                              node);
+          if (subTimespec(&time, subTimespec(&time, &list->time, &list->convert),
+                          &suspended_monotonic)
+                  ->tv_sec > 0) {
+            /* resume, what is convert factor before? */
             subTimespec(&convert, &list->convert, &suspended_diff);
-            time = suspended_monotonic;
-            sumTimespec(&time, &convert);
-            /* breakpoint just after sleep */
-            list = calloc(1, sizeof(struct conversionList));
-            list_init(&list->node);
-            list->time = time;
-            sumTimespec(&list->time, &suspended_diff);
-            list->convert = convert;
-            sumTimespec(&list->convert, &suspended_diff);
-            list_add_head(&convertHead, &list->node);
-            /* breakpoint just before sleep */
-            list = calloc(1, sizeof(struct conversionList));
-            list_init(&list->node);
-            list->time = time;
-            list->convert = convert;
-            list_add_head(&convertHead, &list->node);
+          } else {
+            /* suspend */
+            convert = list->convert;
+          }
+          time = suspended_monotonic;
+          sumTimespec(&time, &convert);
+          /* breakpoint just before sleep */
+          list = calloc(1, sizeof(struct conversionList));
+          list_init(&list->node);
+          list->time = time;
+          list->convert = convert;
+          list_add_tail(&convertHead, &list->node);
+          /* breakpoint just after sleep */
+          list = calloc(1, sizeof(struct conversionList));
+          list_init(&list->node);
+          list->time = time;
+          sumTimespec(&list->time, &suspended_diff);
+          list->convert = convert;
+          sumTimespec(&list->convert, &suspended_diff);
+          list_add_tail(&convertHead, &list->node);
+          suspended_pending = false;
         }
+      }
+      pclose(p);
     }
+    /* last entry is our current time conversion */
+    list = calloc(1, sizeof(struct conversionList));
+    list_init(&list->node);
+    clock_gettime(CLOCK_REALTIME, &list->time);
+    clock_gettime(CLOCK_MONOTONIC, &convert);
+    clock_gettime(CLOCK_MONOTONIC, &time);
+    /* Correct for instant clock_gettime latency (syscall or ~30ns) */
+    subTimespec(&time, &convert, subTimespec(&time, &time, &convert));
+    /* Calculate conversion factor */
+    subTimespec(&list->convert, &list->time, &time);
+    list_add_tail(&convertHead, &list->node);
+    if (suspended_pending) {
+      /* manufacture a suspend @ point before */
+      subTimespec(&convert, &list->convert, &suspended_diff);
+      time = suspended_monotonic;
+      sumTimespec(&time, &convert);
+      /* breakpoint just after sleep */
+      list = calloc(1, sizeof(struct conversionList));
+      list_init(&list->node);
+      list->time = time;
+      sumTimespec(&list->time, &suspended_diff);
+      list->convert = convert;
+      sumTimespec(&list->convert, &suspended_diff);
+      list_add_head(&convertHead, &list->node);
+      /* breakpoint just before sleep */
+      list = calloc(1, sizeof(struct conversionList));
+      list_init(&list->node);
+      list->time = time;
+      list->convert = convert;
+      list_add_head(&convertHead, &list->node);
+    }
+  }
 
-    /* Find the breakpoint in the conversion list */
-    list = node_to_item(list_head(&convertHead), struct conversionList, node);
-    next = NULL;
-    list_for_each(node, &convertHead) {
-        next = node_to_item(node, struct conversionList, node);
-        if (entry->tv_sec < next->time.tv_sec) {
-            break;
-        } else if (entry->tv_sec == next->time.tv_sec) {
-            if (entry->tv_nsec < next->time.tv_nsec) {
-                break;
-            }
+  /* Find the breakpoint in the conversion list */
+  list = node_to_item(list_head(&convertHead), struct conversionList, node);
+  next = NULL;
+  list_for_each(node, &convertHead) {
+    next = node_to_item(node, struct conversionList, node);
+    if (entry->tv_sec < next->time.tv_sec) {
+      break;
+    } else if (entry->tv_sec == next->time.tv_sec) {
+      if (entry->tv_nsec < next->time.tv_nsec) {
+        break;
+      }
+    }
+    list = next;
+  }
+
+  /* blend time from one breakpoint to the next */
+  convert = list->convert;
+  if (next) {
+    unsigned long long total, run;
+
+    total = nsecTimespec(subTimespec(&time, &next->time, &list->time));
+    time.tv_sec = entry->tv_sec;
+    time.tv_nsec = entry->tv_nsec;
+    run = nsecTimespec(subTimespec(&time, &time, &list->time));
+    if (run < total) {
+      long long crun;
+
+      float f = nsecTimespec(subTimespec(&time, &next->convert, &convert));
+      f *= run;
+      f /= total;
+      crun = f;
+      convert.tv_sec += crun / (long long)NS_PER_SEC;
+      if (crun < 0) {
+        convert.tv_nsec -= (-crun) % NS_PER_SEC;
+        if (convert.tv_nsec < 0) {
+          convert.tv_nsec += NS_PER_SEC;
+          convert.tv_sec -= 1;
         }
-        list = next;
-    }
-
-    /* blend time from one breakpoint to the next */
-    convert = list->convert;
-    if (next) {
-        unsigned long long total, run;
-
-        total = nsecTimespec(subTimespec(&time, &next->time, &list->time));
-        time.tv_sec = entry->tv_sec;
-        time.tv_nsec = entry->tv_nsec;
-        run = nsecTimespec(subTimespec(&time, &time, &list->time));
-        if (run < total) {
-            long long crun;
-
-            float f = nsecTimespec(subTimespec(&time, &next->convert, &convert));
-            f *= run;
-            f /= total;
-            crun = f;
-            convert.tv_sec += crun / (long long)NS_PER_SEC;
-            if (crun < 0) {
-                convert.tv_nsec -= (-crun) % NS_PER_SEC;
-                if (convert.tv_nsec < 0) {
-                    convert.tv_nsec += NS_PER_SEC;
-                    convert.tv_sec -= 1;
-                }
-            } else {
-                convert.tv_nsec += crun % NS_PER_SEC;
-                if (convert.tv_nsec >= (long)NS_PER_SEC) {
-                    convert.tv_nsec -= NS_PER_SEC;
-                    convert.tv_sec += 1;
-                }
-            }
+      } else {
+        convert.tv_nsec += crun % NS_PER_SEC;
+        if (convert.tv_nsec >= (long)NS_PER_SEC) {
+          convert.tv_nsec -= NS_PER_SEC;
+          convert.tv_sec += 1;
         }
+      }
     }
+  }
 
-    /* Apply the correction factor */
-    result->tv_sec = entry->tv_sec;
-    result->tv_nsec = entry->tv_nsec;
-    subTimespec(result, result, &convert);
+  /* Apply the correction factor */
+  result->tv_sec = entry->tv_sec;
+  result->tv_nsec = entry->tv_nsec;
+  subTimespec(result, result, &convert);
 }
 #endif
 
@@ -1534,302 +1508,295 @@
  * Returns NULL on malloc error
  */
 
-LIBLOG_ABI_PUBLIC char *android_log_formatLogLine (
-        AndroidLogFormat *p_format,
-        char *defaultBuffer,
-        size_t defaultBufferSize,
-        const AndroidLogEntry *entry,
-        size_t *p_outLength)
-{
+LIBLOG_ABI_PUBLIC char* android_log_formatLogLine(AndroidLogFormat* p_format,
+                                                  char* defaultBuffer,
+                                                  size_t defaultBufferSize,
+                                                  const AndroidLogEntry* entry,
+                                                  size_t* p_outLength) {
 #if !defined(_WIN32)
-    struct tm tmBuf;
+  struct tm tmBuf;
 #endif
-    struct tm* ptm;
-    /* good margin, 23+nul for msec, 26+nul for usec, 29+nul to nsec */
-    char timeBuf[64];
-    char prefixBuf[128], suffixBuf[128];
-    char priChar;
-    int prefixSuffixIsHeaderFooter = 0;
-    char *ret;
-    time_t now;
-    unsigned long nsec;
+  struct tm* ptm;
+  /* good margin, 23+nul for msec, 26+nul for usec, 29+nul to nsec */
+  char timeBuf[64];
+  char prefixBuf[128], suffixBuf[128];
+  char priChar;
+  int prefixSuffixIsHeaderFooter = 0;
+  char* ret;
+  time_t now;
+  unsigned long nsec;
 
-    priChar = filterPriToChar(entry->priority);
-    size_t prefixLen = 0, suffixLen = 0;
-    size_t len;
+  priChar = filterPriToChar(entry->priority);
+  size_t prefixLen = 0, suffixLen = 0;
+  size_t len;
 
-    /*
-     * Get the current date/time in pretty form
-     *
-     * It's often useful when examining a log with "less" to jump to
-     * a specific point in the file by searching for the date/time stamp.
-     * For this reason it's very annoying to have regexp meta characters
-     * in the time stamp.  Don't use forward slashes, parenthesis,
-     * brackets, asterisks, or other special chars here.
-     *
-     * The caller may have affected the timezone environment, this is
-     * expected to be sensitive to that.
-     */
-    now = entry->tv_sec;
-    nsec = entry->tv_nsec;
+  /*
+   * Get the current date/time in pretty form
+   *
+   * It's often useful when examining a log with "less" to jump to
+   * a specific point in the file by searching for the date/time stamp.
+   * For this reason it's very annoying to have regexp meta characters
+   * in the time stamp.  Don't use forward slashes, parenthesis,
+   * brackets, asterisks, or other special chars here.
+   *
+   * The caller may have affected the timezone environment, this is
+   * expected to be sensitive to that.
+   */
+  now = entry->tv_sec;
+  nsec = entry->tv_nsec;
 #if __ANDROID__
-    if (p_format->monotonic_output) {
-        // prevent convertMonotonic from being called if logd is monotonic
-        if (android_log_clockid() != CLOCK_MONOTONIC) {
-            struct timespec time;
-            convertMonotonic(&time, entry);
-            now = time.tv_sec;
-            nsec = time.tv_nsec;
-        }
+  if (p_format->monotonic_output) {
+    /* prevent convertMonotonic from being called if logd is monotonic */
+    if (android_log_clockid() != CLOCK_MONOTONIC) {
+      struct timespec time;
+      convertMonotonic(&time, entry);
+      now = time.tv_sec;
+      nsec = time.tv_nsec;
     }
+  }
 #endif
-    if (now < 0) {
-        nsec = NS_PER_SEC - nsec;
-    }
-    if (p_format->epoch_output || p_format->monotonic_output) {
-        ptm = NULL;
-        snprintf(timeBuf, sizeof(timeBuf),
-                 p_format->monotonic_output ? "%6lld" : "%19lld",
-                 (long long)now);
-    } else {
+  if (now < 0) {
+    nsec = NS_PER_SEC - nsec;
+  }
+  if (p_format->epoch_output || p_format->monotonic_output) {
+    ptm = NULL;
+    snprintf(timeBuf, sizeof(timeBuf),
+             p_format->monotonic_output ? "%6lld" : "%19lld", (long long)now);
+  } else {
 #if !defined(_WIN32)
-        ptm = localtime_r(&now, &tmBuf);
+    ptm = localtime_r(&now, &tmBuf);
 #else
-        ptm = localtime(&now);
+    ptm = localtime(&now);
 #endif
-        strftime(timeBuf, sizeof(timeBuf),
-                 &"%Y-%m-%d %H:%M:%S"[p_format->year_output ? 0 : 3],
-                 ptm);
-    }
-    len = strlen(timeBuf);
-    if (p_format->nsec_time_output) {
-        len += snprintf(timeBuf + len, sizeof(timeBuf) - len,
-                        ".%09ld", nsec);
-    } else if (p_format->usec_time_output) {
-        len += snprintf(timeBuf + len, sizeof(timeBuf) - len,
-                        ".%06ld", nsec / US_PER_NSEC);
-    } else {
-        len += snprintf(timeBuf + len, sizeof(timeBuf) - len,
-                        ".%03ld", nsec / MS_PER_NSEC);
-    }
-    if (p_format->zone_output && ptm) {
-        strftime(timeBuf + len, sizeof(timeBuf) - len, " %z", ptm);
-    }
+    strftime(timeBuf, sizeof(timeBuf),
+             &"%Y-%m-%d %H:%M:%S"[p_format->year_output ? 0 : 3], ptm);
+  }
+  len = strlen(timeBuf);
+  if (p_format->nsec_time_output) {
+    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%09ld", nsec);
+  } else if (p_format->usec_time_output) {
+    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%06ld",
+                    nsec / US_PER_NSEC);
+  } else {
+    len += snprintf(timeBuf + len, sizeof(timeBuf) - len, ".%03ld",
+                    nsec / MS_PER_NSEC);
+  }
+  if (p_format->zone_output && ptm) {
+    strftime(timeBuf + len, sizeof(timeBuf) - len, " %z", ptm);
+  }
 
-    /*
-     * Construct a buffer containing the log header and log message.
-     */
-    if (p_format->colored_output) {
-        prefixLen = snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[38;5;%dm",
-                             colorFromPri(entry->priority));
-        prefixLen = MIN(prefixLen, sizeof(prefixBuf));
-        suffixLen = snprintf(suffixBuf, sizeof(suffixBuf), "\x1B[0m");
-        suffixLen = MIN(suffixLen, sizeof(suffixBuf));
-    }
+  /*
+   * Construct a buffer containing the log header and log message.
+   */
+  if (p_format->colored_output) {
+    prefixLen = snprintf(prefixBuf, sizeof(prefixBuf), "\x1B[38;5;%dm",
+                         colorFromPri(entry->priority));
+    prefixLen = MIN(prefixLen, sizeof(prefixBuf));
+    suffixLen = snprintf(suffixBuf, sizeof(suffixBuf), "\x1B[0m");
+    suffixLen = MIN(suffixLen, sizeof(suffixBuf));
+  }
 
-    char uid[16];
-    uid[0] = '\0';
-    if (p_format->uid_output) {
-        if (entry->uid >= 0) {
-
-            /*
-             * This code is Android specific, bionic guarantees that
-             * calls to non-reentrant getpwuid() are thread safe.
-             */
+  char uid[16];
+  uid[0] = '\0';
+  if (p_format->uid_output) {
+    if (entry->uid >= 0) {
+/*
+ * This code is Android specific, bionic guarantees that
+ * calls to non-reentrant getpwuid() are thread safe.
+ */
 #if !defined(__MINGW32__)
 #if (FAKE_LOG_DEVICE == 0)
 #ifndef __BIONIC__
-#warning "This code assumes that getpwuid is thread safe, only true with Bionic!"
+#warning \
+    "This code assumes that getpwuid is thread safe, only true with Bionic!"
 #endif
 #endif
-            struct passwd* pwd = getpwuid(entry->uid);
-            if (pwd && (strlen(pwd->pw_name) <= 5)) {
-                 snprintf(uid, sizeof(uid), "%5s:", pwd->pw_name);
-            } else
+      struct passwd* pwd = getpwuid(entry->uid);
+      if (pwd && (strlen(pwd->pw_name) <= 5)) {
+        snprintf(uid, sizeof(uid), "%5s:", pwd->pw_name);
+      } else
 #endif
-            {
-                 // Not worth parsing package list, names all longer than 5
-                 snprintf(uid, sizeof(uid), "%5d:", entry->uid);
-            }
-        } else {
-            snprintf(uid, sizeof(uid), "      ");
-        }
-    }
-
-    switch (p_format->format) {
-        case FORMAT_TAG:
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%c/%-8.*s: ", priChar, (int)entry->tagLen, entry->tag);
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-        case FORMAT_PROCESS:
-            len = snprintf(suffixBuf + suffixLen, sizeof(suffixBuf) - suffixLen,
-                "  (%.*s)\n", (int)entry->tagLen, entry->tag);
-            suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%c(%s%5d) ", priChar, uid, entry->pid);
-            break;
-        case FORMAT_THREAD:
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%c(%s%5d:%5d) ", priChar, uid, entry->pid, entry->tid);
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-        case FORMAT_RAW:
-            prefixBuf[prefixLen] = 0;
-            len = 0;
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-        case FORMAT_TIME:
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%s %c/%-8.*s(%s%5d): ", timeBuf, priChar,
-                (int)entry->tagLen, entry->tag, uid, entry->pid);
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-        case FORMAT_THREADTIME:
-            ret = strchr(uid, ':');
-            if (ret) {
-                *ret = ' ';
-            }
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%s %s%5d %5d %c %-8.*s: ", timeBuf, uid, entry->pid,
-                entry->tid, priChar, (int)entry->tagLen, entry->tag);
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-        case FORMAT_LONG:
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "[ %s %s%5d:%5d %c/%-8.*s ]\n",
-                timeBuf, uid, entry->pid, entry->tid, priChar,
-                (int)entry->tagLen, entry->tag);
-            strcpy(suffixBuf + suffixLen, "\n\n");
-            suffixLen += 2;
-            prefixSuffixIsHeaderFooter = 1;
-            break;
-        case FORMAT_BRIEF:
-        default:
-            len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
-                "%c/%-8.*s(%s%5d): ", priChar, (int)entry->tagLen, entry->tag,
-                uid, entry->pid);
-            strcpy(suffixBuf + suffixLen, "\n");
-            ++suffixLen;
-            break;
-    }
-
-    /* snprintf has a weird return value.   It returns what would have been
-     * written given a large enough buffer.  In the case that the prefix is
-     * longer then our buffer(128), it messes up the calculations below
-     * possibly causing heap corruption.  To avoid this we double check and
-     * set the length at the maximum (size minus null byte)
-     */
-    prefixLen += len;
-    if (prefixLen >= sizeof(prefixBuf)) {
-        prefixLen = sizeof(prefixBuf) - 1;
-        prefixBuf[sizeof(prefixBuf) - 1] = '\0';
-    }
-    if (suffixLen >= sizeof(suffixBuf)) {
-        suffixLen = sizeof(suffixBuf) - 1;
-        suffixBuf[sizeof(suffixBuf) - 2] = '\n';
-        suffixBuf[sizeof(suffixBuf) - 1] = '\0';
-    }
-
-    /* the following code is tragically unreadable */
-
-    size_t numLines;
-    char *p;
-    size_t bufferSize;
-    const char *pm;
-
-    if (prefixSuffixIsHeaderFooter) {
-        /* we're just wrapping message with a header/footer */
-        numLines = 1;
+      {
+        /* Not worth parsing package list, names all longer than 5 */
+        snprintf(uid, sizeof(uid), "%5d:", entry->uid);
+      }
     } else {
-        pm = entry->message;
-        numLines = 0;
-
-        /*
-         * The line-end finding here must match the line-end finding
-         * in for ( ... numLines...) loop below
-         */
-        while (pm < (entry->message + entry->messageLen)) {
-            if (*pm++ == '\n') numLines++;
-        }
-        /* plus one line for anything not newline-terminated at the end */
-        if (pm > entry->message && *(pm-1) != '\n') numLines++;
+      snprintf(uid, sizeof(uid), "      ");
     }
+  }
+
+  switch (p_format->format) {
+    case FORMAT_TAG:
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%c/%-8.*s: ", priChar, (int)entry->tagLen, entry->tag);
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+    case FORMAT_PROCESS:
+      len = snprintf(suffixBuf + suffixLen, sizeof(suffixBuf) - suffixLen,
+                     "  (%.*s)\n", (int)entry->tagLen, entry->tag);
+      suffixLen += MIN(len, sizeof(suffixBuf) - suffixLen);
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%c(%s%5d) ", priChar, uid, entry->pid);
+      break;
+    case FORMAT_THREAD:
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%c(%s%5d:%5d) ", priChar, uid, entry->pid, entry->tid);
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+    case FORMAT_RAW:
+      prefixBuf[prefixLen] = 0;
+      len = 0;
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+    case FORMAT_TIME:
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%s %c/%-8.*s(%s%5d): ", timeBuf, priChar,
+                     (int)entry->tagLen, entry->tag, uid, entry->pid);
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+    case FORMAT_THREADTIME:
+      ret = strchr(uid, ':');
+      if (ret) {
+        *ret = ' ';
+      }
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%s %s%5d %5d %c %-8.*s: ", timeBuf, uid, entry->pid,
+                     entry->tid, priChar, (int)entry->tagLen, entry->tag);
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+    case FORMAT_LONG:
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "[ %s %s%5d:%5d %c/%-8.*s ]\n", timeBuf, uid, entry->pid,
+                     entry->tid, priChar, (int)entry->tagLen, entry->tag);
+      strcpy(suffixBuf + suffixLen, "\n\n");
+      suffixLen += 2;
+      prefixSuffixIsHeaderFooter = 1;
+      break;
+    case FORMAT_BRIEF:
+    default:
+      len = snprintf(prefixBuf + prefixLen, sizeof(prefixBuf) - prefixLen,
+                     "%c/%-8.*s(%s%5d): ", priChar, (int)entry->tagLen,
+                     entry->tag, uid, entry->pid);
+      strcpy(suffixBuf + suffixLen, "\n");
+      ++suffixLen;
+      break;
+  }
+
+  /* snprintf has a weird return value.   It returns what would have been
+   * written given a large enough buffer.  In the case that the prefix is
+   * longer then our buffer(128), it messes up the calculations below
+   * possibly causing heap corruption.  To avoid this we double check and
+   * set the length at the maximum (size minus null byte)
+   */
+  prefixLen += len;
+  if (prefixLen >= sizeof(prefixBuf)) {
+    prefixLen = sizeof(prefixBuf) - 1;
+    prefixBuf[sizeof(prefixBuf) - 1] = '\0';
+  }
+  if (suffixLen >= sizeof(suffixBuf)) {
+    suffixLen = sizeof(suffixBuf) - 1;
+    suffixBuf[sizeof(suffixBuf) - 2] = '\n';
+    suffixBuf[sizeof(suffixBuf) - 1] = '\0';
+  }
+
+  /* the following code is tragically unreadable */
+
+  size_t numLines;
+  char* p;
+  size_t bufferSize;
+  const char* pm;
+
+  if (prefixSuffixIsHeaderFooter) {
+    /* we're just wrapping message with a header/footer */
+    numLines = 1;
+  } else {
+    pm = entry->message;
+    numLines = 0;
 
     /*
-     * this is an upper bound--newlines in message may be counted
-     * extraneously
+     * The line-end finding here must match the line-end finding
+     * in for ( ... numLines...) loop below
      */
-    bufferSize = (numLines * (prefixLen + suffixLen)) + 1;
+    while (pm < (entry->message + entry->messageLen)) {
+      if (*pm++ == '\n') numLines++;
+    }
+    /* plus one line for anything not newline-terminated at the end */
+    if (pm > entry->message && *(pm - 1) != '\n') numLines++;
+  }
+
+  /*
+   * this is an upper bound--newlines in message may be counted
+   * extraneously
+   */
+  bufferSize = (numLines * (prefixLen + suffixLen)) + 1;
+  if (p_format->printable_output) {
+    /* Calculate extra length to convert non-printable to printable */
+    bufferSize += convertPrintable(NULL, entry->message, entry->messageLen);
+  } else {
+    bufferSize += entry->messageLen;
+  }
+
+  if (defaultBufferSize >= bufferSize) {
+    ret = defaultBuffer;
+  } else {
+    ret = (char*)malloc(bufferSize);
+
+    if (ret == NULL) {
+      return ret;
+    }
+  }
+
+  ret[0] = '\0'; /* to start strcat off */
+
+  p = ret;
+  pm = entry->message;
+
+  if (prefixSuffixIsHeaderFooter) {
+    strcat(p, prefixBuf);
+    p += prefixLen;
     if (p_format->printable_output) {
-        /* Calculate extra length to convert non-printable to printable */
-        bufferSize += convertPrintable(NULL, entry->message, entry->messageLen);
+      p += convertPrintable(p, entry->message, entry->messageLen);
     } else {
-        bufferSize += entry->messageLen;
+      strncat(p, entry->message, entry->messageLen);
+      p += entry->messageLen;
     }
+    strcat(p, suffixBuf);
+    p += suffixLen;
+  } else {
+    do {
+      const char* lineStart;
+      size_t lineLen;
+      lineStart = pm;
 
-    if (defaultBufferSize >= bufferSize) {
-        ret = defaultBuffer;
-    } else {
-        ret = (char *)malloc(bufferSize);
+      /* Find the next end-of-line in message */
+      while (pm < (entry->message + entry->messageLen) && *pm != '\n') pm++;
+      lineLen = pm - lineStart;
 
-        if (ret == NULL) {
-            return ret;
-        }
-    }
+      strcat(p, prefixBuf);
+      p += prefixLen;
+      if (p_format->printable_output) {
+        p += convertPrintable(p, lineStart, lineLen);
+      } else {
+        strncat(p, lineStart, lineLen);
+        p += lineLen;
+      }
+      strcat(p, suffixBuf);
+      p += suffixLen;
 
-    ret[0] = '\0';       /* to start strcat off */
+      if (*pm == '\n') pm++;
+    } while (pm < (entry->message + entry->messageLen));
+  }
 
-    p = ret;
-    pm = entry->message;
+  if (p_outLength != NULL) {
+    *p_outLength = p - ret;
+  }
 
-    if (prefixSuffixIsHeaderFooter) {
-        strcat(p, prefixBuf);
-        p += prefixLen;
-        if (p_format->printable_output) {
-            p += convertPrintable(p, entry->message, entry->messageLen);
-        } else {
-            strncat(p, entry->message, entry->messageLen);
-            p += entry->messageLen;
-        }
-        strcat(p, suffixBuf);
-        p += suffixLen;
-    } else {
-        do {
-            const char *lineStart;
-            size_t lineLen;
-            lineStart = pm;
-
-            /* Find the next end-of-line in message */
-            while (pm < (entry->message + entry->messageLen)
-                    && *pm != '\n') pm++;
-            lineLen = pm - lineStart;
-
-            strcat(p, prefixBuf);
-            p += prefixLen;
-            if (p_format->printable_output) {
-                p += convertPrintable(p, lineStart, lineLen);
-            } else {
-                strncat(p, lineStart, lineLen);
-                p += lineLen;
-            }
-            strcat(p, suffixBuf);
-            p += suffixLen;
-
-            if (*pm == '\n') pm++;
-        } while (pm < (entry->message + entry->messageLen));
-    }
-
-    if (p_outLength != NULL) {
-        *p_outLength = p - ret;
-    }
-
-    return ret;
+  return ret;
 }
 
 /**
@@ -1838,41 +1805,38 @@
  * Returns count bytes written
  */
 
-LIBLOG_ABI_PUBLIC int android_log_printLogLine(
-        AndroidLogFormat *p_format,
-        int fd,
-        const AndroidLogEntry *entry)
-{
-    int ret;
-    char defaultBuffer[512];
-    char *outBuffer = NULL;
-    size_t totalLen;
+LIBLOG_ABI_PUBLIC int android_log_printLogLine(AndroidLogFormat* p_format,
+                                               int fd,
+                                               const AndroidLogEntry* entry) {
+  int ret;
+  char defaultBuffer[512];
+  char* outBuffer = NULL;
+  size_t totalLen;
 
-    outBuffer = android_log_formatLogLine(p_format, defaultBuffer,
-            sizeof(defaultBuffer), entry, &totalLen);
+  outBuffer = android_log_formatLogLine(
+      p_format, defaultBuffer, sizeof(defaultBuffer), entry, &totalLen);
 
-    if (!outBuffer) return -1;
+  if (!outBuffer) return -1;
 
-    do {
-        ret = write(fd, outBuffer, totalLen);
-    } while (ret < 0 && errno == EINTR);
+  do {
+    ret = write(fd, outBuffer, totalLen);
+  } while (ret < 0 && errno == EINTR);
 
-    if (ret < 0) {
-        fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
-        ret = 0;
-        goto done;
-    }
+  if (ret < 0) {
+    fprintf(stderr, "+++ LOG: write failed (errno=%d)\n", errno);
+    ret = 0;
+    goto done;
+  }
 
-    if (((size_t)ret) < totalLen) {
-        fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", ret,
-                (int)totalLen);
-        goto done;
-    }
+  if (((size_t)ret) < totalLen) {
+    fprintf(stderr, "+++ LOG: write partial (%d of %d)\n", ret, (int)totalLen);
+    goto done;
+  }
 
 done:
-    if (outBuffer != defaultBuffer) {
-        free(outBuffer);
-    }
+  if (outBuffer != defaultBuffer) {
+    free(outBuffer);
+  }
 
-    return ret;
+  return ret;
 }
diff --git a/liblog/pmsg_reader.c b/liblog/pmsg_reader.c
index e1b81aa..c3ed8a2 100644
--- a/liblog/pmsg_reader.c
+++ b/liblog/pmsg_reader.c
@@ -29,591 +29,571 @@
 #include "logger.h"
 
 static int pmsgAvailable(log_id_t logId);
-static int pmsgVersion(struct android_log_logger *logger,
-                       struct android_log_transport_context *transp);
-static int pmsgRead(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp,
-                    struct log_msg *log_msg);
-static void pmsgClose(struct android_log_logger_list *logger_list,
-                      struct android_log_transport_context *transp);
-static int pmsgClear(struct android_log_logger *logger,
-                     struct android_log_transport_context *transp);
+static int pmsgVersion(struct android_log_logger* logger,
+                       struct android_log_transport_context* transp);
+static int pmsgRead(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp,
+                    struct log_msg* log_msg);
+static void pmsgClose(struct android_log_logger_list* logger_list,
+                      struct android_log_transport_context* transp);
+static int pmsgClear(struct android_log_logger* logger,
+                     struct android_log_transport_context* transp);
 
 LIBLOG_HIDDEN struct android_log_transport_read pmsgLoggerRead = {
-    .node = { &pmsgLoggerRead.node, &pmsgLoggerRead.node },
-    .name = "pmsg",
-    .available = pmsgAvailable,
-    .version = pmsgVersion,
-    .read = pmsgRead,
-    .poll = NULL,
-    .close = pmsgClose,
-    .clear = pmsgClear,
-    .setSize = NULL,
-    .getSize = NULL,
-    .getReadableSize = NULL,
-    .getPrune = NULL,
-    .setPrune = NULL,
-    .getStats = NULL,
+  .node = { &pmsgLoggerRead.node, &pmsgLoggerRead.node },
+  .name = "pmsg",
+  .available = pmsgAvailable,
+  .version = pmsgVersion,
+  .read = pmsgRead,
+  .poll = NULL,
+  .close = pmsgClose,
+  .clear = pmsgClear,
+  .setSize = NULL,
+  .getSize = NULL,
+  .getReadableSize = NULL,
+  .getPrune = NULL,
+  .setPrune = NULL,
+  .getStats = NULL,
 };
 
-static int pmsgAvailable(log_id_t logId)
-{
-    if (logId > LOG_ID_SECURITY) {
-        return -EINVAL;
-    }
-    if (access("/dev/pmsg0", W_OK) == 0) {
-        return 0;
-    }
-    return -EBADF;
+static int pmsgAvailable(log_id_t logId) {
+  if (logId > LOG_ID_SECURITY) {
+    return -EINVAL;
+  }
+  if (access("/dev/pmsg0", W_OK) == 0) {
+    return 0;
+  }
+  return -EBADF;
 }
 
 /* Determine the credentials of the caller */
-static bool uid_has_log_permission(uid_t uid)
-{
-    return (uid == AID_SYSTEM) || (uid == AID_LOG) || (uid == AID_ROOT) || (uid == AID_LOGD);
+static bool uid_has_log_permission(uid_t uid) {
+  return (uid == AID_SYSTEM) || (uid == AID_LOG) || (uid == AID_ROOT) ||
+         (uid == AID_LOGD);
 }
 
-static uid_t get_best_effective_uid()
-{
-    uid_t euid;
-    uid_t uid;
-    gid_t gid;
-    ssize_t i;
-    static uid_t last_uid = (uid_t) -1;
+static uid_t get_best_effective_uid() {
+  uid_t euid;
+  uid_t uid;
+  gid_t gid;
+  ssize_t i;
+  static uid_t last_uid = (uid_t)-1;
 
-    if (last_uid != (uid_t) -1) {
-        return last_uid;
-    }
-    uid = __android_log_uid();
-    if (uid_has_log_permission(uid)) {
-        return last_uid = uid;
-    }
-    euid = geteuid();
-    if (uid_has_log_permission(euid)) {
-        return last_uid = euid;
-    }
-    gid = getgid();
-    if (uid_has_log_permission(gid)) {
-        return last_uid = gid;
-    }
-    gid = getegid();
-    if (uid_has_log_permission(gid)) {
-        return last_uid = gid;
-    }
-    i = getgroups((size_t) 0, NULL);
-    if (i > 0) {
-        gid_t list[i];
-
-        getgroups(i, list);
-        while (--i >= 0) {
-            if (uid_has_log_permission(list[i])) {
-                return last_uid = list[i];
-            }
-        }
-    }
+  if (last_uid != (uid_t)-1) {
+    return last_uid;
+  }
+  uid = __android_log_uid();
+  if (uid_has_log_permission(uid)) {
     return last_uid = uid;
+  }
+  euid = geteuid();
+  if (uid_has_log_permission(euid)) {
+    return last_uid = euid;
+  }
+  gid = getgid();
+  if (uid_has_log_permission(gid)) {
+    return last_uid = gid;
+  }
+  gid = getegid();
+  if (uid_has_log_permission(gid)) {
+    return last_uid = gid;
+  }
+  i = getgroups((size_t)0, NULL);
+  if (i > 0) {
+    gid_t list[i];
+
+    getgroups(i, list);
+    while (--i >= 0) {
+      if (uid_has_log_permission(list[i])) {
+        return last_uid = list[i];
+      }
+    }
+  }
+  return last_uid = uid;
 }
 
-static int pmsgClear(struct android_log_logger *logger __unused,
-                     struct android_log_transport_context *transp __unused)
-{
-    if (uid_has_log_permission(get_best_effective_uid())) {
-        return unlink("/sys/fs/pstore/pmsg-ramoops-0");
-    }
-    errno = EPERM;
-    return -1;
+static int pmsgClear(struct android_log_logger* logger __unused,
+                     struct android_log_transport_context* transp __unused) {
+  if (uid_has_log_permission(get_best_effective_uid())) {
+    return unlink("/sys/fs/pstore/pmsg-ramoops-0");
+  }
+  errno = EPERM;
+  return -1;
 }
 
 /*
  * returns the logger version
  */
-static int pmsgVersion(struct android_log_logger *logger __unused,
-                       struct android_log_transport_context *transp __unused)
-{
-    return 4;
+static int pmsgVersion(struct android_log_logger* logger __unused,
+                       struct android_log_transport_context* transp __unused) {
+  return 4;
 }
 
-static int pmsgRead(struct android_log_logger_list *logger_list,
-                    struct android_log_transport_context *transp,
-                    struct log_msg *log_msg)
-{
-    ssize_t ret;
-    off_t current, next;
-    uid_t uid;
-    struct android_log_logger *logger;
-    struct __attribute__((__packed__)) {
-        android_pmsg_log_header_t p;
-        android_log_header_t l;
-        uint8_t prio;
-    } buf;
-    static uint8_t preread_count;
-    bool is_system;
+static int pmsgRead(struct android_log_logger_list* logger_list,
+                    struct android_log_transport_context* transp,
+                    struct log_msg* log_msg) {
+  ssize_t ret;
+  off_t current, next;
+  uid_t uid;
+  struct android_log_logger* logger;
+  struct __attribute__((__packed__)) {
+    android_pmsg_log_header_t p;
+    android_log_header_t l;
+    uint8_t prio;
+  } buf;
+  static uint8_t preread_count;
+  bool is_system;
 
-    memset(log_msg, 0, sizeof(*log_msg));
+  memset(log_msg, 0, sizeof(*log_msg));
 
-    if (atomic_load(&transp->context.fd) <= 0) {
-        int i, fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
+  if (atomic_load(&transp->context.fd) <= 0) {
+    int i, fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
 
-        if (fd < 0) {
-            return -errno;
-        }
-        if (fd == 0) { /* Argggg */
-            fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
-            close(0);
-            if (fd < 0) {
-                return -errno;
-            }
-        }
-        i = atomic_exchange(&transp->context.fd, fd);
-        if ((i > 0) && (i != fd)) {
-            close(i);
-        }
-        preread_count = 0;
+    if (fd < 0) {
+      return -errno;
     }
+    if (fd == 0) { /* Argggg */
+      fd = open("/sys/fs/pstore/pmsg-ramoops-0", O_RDONLY | O_CLOEXEC);
+      close(0);
+      if (fd < 0) {
+        return -errno;
+      }
+    }
+    i = atomic_exchange(&transp->context.fd, fd);
+    if ((i > 0) && (i != fd)) {
+      close(i);
+    }
+    preread_count = 0;
+  }
 
-    while(1) {
-        int fd;
+  while (1) {
+    int fd;
 
-        if (preread_count < sizeof(buf)) {
-            fd = atomic_load(&transp->context.fd);
-            if (fd <= 0) {
-                return -EBADF;
-            }
-            ret = TEMP_FAILURE_RETRY(read(fd,
-                                          &buf.p.magic + preread_count,
-                                          sizeof(buf) - preread_count));
-            if (ret < 0) {
-                return -errno;
-            }
-            preread_count += ret;
-        }
-        if (preread_count != sizeof(buf)) {
-            return preread_count ? -EIO : -EAGAIN;
-        }
-        if ((buf.p.magic != LOGGER_MAGIC) ||
-                (buf.p.len <= sizeof(buf)) ||
-                (buf.p.len > (sizeof(buf) + LOGGER_ENTRY_MAX_PAYLOAD)) ||
-                (buf.l.id >= LOG_ID_MAX) ||
-                (buf.l.realtime.tv_nsec >= NS_PER_SEC) ||
-                ((buf.l.id != LOG_ID_EVENTS) &&
-                    (buf.l.id != LOG_ID_SECURITY) &&
-                    ((buf.prio == ANDROID_LOG_UNKNOWN) ||
-                        (buf.prio == ANDROID_LOG_DEFAULT) ||
-                        (buf.prio >= ANDROID_LOG_SILENT)))) {
-            do {
-                memmove(&buf.p.magic, &buf.p.magic + 1, --preread_count);
-            } while (preread_count && (buf.p.magic != LOGGER_MAGIC));
-            continue;
-        }
-        preread_count = 0;
+    if (preread_count < sizeof(buf)) {
+      fd = atomic_load(&transp->context.fd);
+      if (fd <= 0) {
+        return -EBADF;
+      }
+      ret = TEMP_FAILURE_RETRY(
+          read(fd, &buf.p.magic + preread_count, sizeof(buf) - preread_count));
+      if (ret < 0) {
+        return -errno;
+      }
+      preread_count += ret;
+    }
+    if (preread_count != sizeof(buf)) {
+      return preread_count ? -EIO : -EAGAIN;
+    }
+    if ((buf.p.magic != LOGGER_MAGIC) || (buf.p.len <= sizeof(buf)) ||
+        (buf.p.len > (sizeof(buf) + LOGGER_ENTRY_MAX_PAYLOAD)) ||
+        (buf.l.id >= LOG_ID_MAX) || (buf.l.realtime.tv_nsec >= NS_PER_SEC) ||
+        ((buf.l.id != LOG_ID_EVENTS) && (buf.l.id != LOG_ID_SECURITY) &&
+         ((buf.prio == ANDROID_LOG_UNKNOWN) ||
+          (buf.prio == ANDROID_LOG_DEFAULT) ||
+          (buf.prio >= ANDROID_LOG_SILENT)))) {
+      do {
+        memmove(&buf.p.magic, &buf.p.magic + 1, --preread_count);
+      } while (preread_count && (buf.p.magic != LOGGER_MAGIC));
+      continue;
+    }
+    preread_count = 0;
 
-        if ((transp->logMask & (1 << buf.l.id)) &&
-                ((!logger_list->start.tv_sec && !logger_list->start.tv_nsec) ||
-                    ((logger_list->start.tv_sec <= buf.l.realtime.tv_sec) &&
-                        ((logger_list->start.tv_sec != buf.l.realtime.tv_sec) ||
-                            (logger_list->start.tv_nsec <=
-                                buf.l.realtime.tv_nsec)))) &&
-                (!logger_list->pid || (logger_list->pid == buf.p.pid))) {
-            uid = get_best_effective_uid();
-            is_system = uid_has_log_permission(uid);
-            if (is_system || (uid == buf.p.uid)) {
-                char *msg = is_system ?
-                    log_msg->entry_v4.msg :
-                    log_msg->entry_v3.msg;
-                *msg = buf.prio;
-                fd = atomic_load(&transp->context.fd);
-                if (fd <= 0) {
-                    return -EBADF;
-                }
-                ret = TEMP_FAILURE_RETRY(read(fd,
-                                              msg + sizeof(buf.prio),
-                                              buf.p.len - sizeof(buf)));
-                if (ret < 0) {
-                    return -errno;
-                }
-                if (ret != (ssize_t)(buf.p.len - sizeof(buf))) {
-                    return -EIO;
-                }
-
-                log_msg->entry_v4.len = buf.p.len - sizeof(buf) + sizeof(buf.prio);
-                log_msg->entry_v4.hdr_size = is_system ?
-                    sizeof(log_msg->entry_v4) :
-                    sizeof(log_msg->entry_v3);
-                log_msg->entry_v4.pid = buf.p.pid;
-                log_msg->entry_v4.tid = buf.l.tid;
-                log_msg->entry_v4.sec = buf.l.realtime.tv_sec;
-                log_msg->entry_v4.nsec = buf.l.realtime.tv_nsec;
-                log_msg->entry_v4.lid = buf.l.id;
-                if (is_system) {
-                    log_msg->entry_v4.uid = buf.p.uid;
-                }
-
-                return ret + sizeof(buf.prio) + log_msg->entry_v4.hdr_size;
-            }
-        }
-
+    if ((transp->logMask & (1 << buf.l.id)) &&
+        ((!logger_list->start.tv_sec && !logger_list->start.tv_nsec) ||
+         ((logger_list->start.tv_sec <= buf.l.realtime.tv_sec) &&
+          ((logger_list->start.tv_sec != buf.l.realtime.tv_sec) ||
+           (logger_list->start.tv_nsec <= buf.l.realtime.tv_nsec)))) &&
+        (!logger_list->pid || (logger_list->pid == buf.p.pid))) {
+      uid = get_best_effective_uid();
+      is_system = uid_has_log_permission(uid);
+      if (is_system || (uid == buf.p.uid)) {
+        char* msg = is_system ? log_msg->entry_v4.msg : log_msg->entry_v3.msg;
+        *msg = buf.prio;
         fd = atomic_load(&transp->context.fd);
         if (fd <= 0) {
-            return -EBADF;
+          return -EBADF;
         }
-        current = TEMP_FAILURE_RETRY(lseek(fd, (off_t)0, SEEK_CUR));
-        if (current < 0) {
-            return -errno;
+        ret = TEMP_FAILURE_RETRY(
+            read(fd, msg + sizeof(buf.prio), buf.p.len - sizeof(buf)));
+        if (ret < 0) {
+          return -errno;
         }
-        fd = atomic_load(&transp->context.fd);
-        if (fd <= 0) {
-            return -EBADF;
+        if (ret != (ssize_t)(buf.p.len - sizeof(buf))) {
+          return -EIO;
         }
-        next = TEMP_FAILURE_RETRY(lseek(fd,
-                                        (off_t)(buf.p.len - sizeof(buf)),
-                                        SEEK_CUR));
-        if (next < 0) {
-            return -errno;
+
+        log_msg->entry_v4.len = buf.p.len - sizeof(buf) + sizeof(buf.prio);
+        log_msg->entry_v4.hdr_size =
+            is_system ? sizeof(log_msg->entry_v4) : sizeof(log_msg->entry_v3);
+        log_msg->entry_v4.pid = buf.p.pid;
+        log_msg->entry_v4.tid = buf.l.tid;
+        log_msg->entry_v4.sec = buf.l.realtime.tv_sec;
+        log_msg->entry_v4.nsec = buf.l.realtime.tv_nsec;
+        log_msg->entry_v4.lid = buf.l.id;
+        if (is_system) {
+          log_msg->entry_v4.uid = buf.p.uid;
         }
-        if ((next - current) != (ssize_t)(buf.p.len - sizeof(buf))) {
-            return -EIO;
-        }
+
+        return ret + sizeof(buf.prio) + log_msg->entry_v4.hdr_size;
+      }
     }
+
+    fd = atomic_load(&transp->context.fd);
+    if (fd <= 0) {
+      return -EBADF;
+    }
+    current = TEMP_FAILURE_RETRY(lseek(fd, (off_t)0, SEEK_CUR));
+    if (current < 0) {
+      return -errno;
+    }
+    fd = atomic_load(&transp->context.fd);
+    if (fd <= 0) {
+      return -EBADF;
+    }
+    next = TEMP_FAILURE_RETRY(
+        lseek(fd, (off_t)(buf.p.len - sizeof(buf)), SEEK_CUR));
+    if (next < 0) {
+      return -errno;
+    }
+    if ((next - current) != (ssize_t)(buf.p.len - sizeof(buf))) {
+      return -EIO;
+    }
+  }
 }
 
-static void pmsgClose(struct android_log_logger_list *logger_list __unused,
-                      struct android_log_transport_context *transp) {
-    int fd = atomic_exchange(&transp->context.fd, 0);
-    if (fd > 0) {
-        close (fd);
-    }
+static void pmsgClose(struct android_log_logger_list* logger_list __unused,
+                      struct android_log_transport_context* transp) {
+  int fd = atomic_exchange(&transp->context.fd, 0);
+  if (fd > 0) {
+    close(fd);
+  }
 }
 
-LIBLOG_ABI_PRIVATE ssize_t __android_log_pmsg_file_read(
-        log_id_t logId,
-        char prio,
-        const char *prefix,
-        __android_log_pmsg_file_read_fn fn, void *arg) {
-    ssize_t ret;
-    struct android_log_logger_list logger_list;
-    struct android_log_transport_context transp;
-    struct content {
-        struct listnode node;
-        union {
-            struct logger_entry_v4 entry;
-            struct logger_entry_v4 entry_v4;
-            struct logger_entry_v3 entry_v3;
-            struct logger_entry_v2 entry_v2;
-            struct logger_entry    entry_v1;
-        };
-    } *content;
-    struct names {
-        struct listnode node;
-        struct listnode content;
-        log_id_t id;
-        char prio;
-        char name[];
-    } *names;
-    struct listnode name_list;
-    struct listnode *node, *n;
-    size_t len, prefix_len;
+LIBLOG_ABI_PRIVATE ssize_t
+__android_log_pmsg_file_read(log_id_t logId, char prio, const char* prefix,
+                             __android_log_pmsg_file_read_fn fn, void* arg) {
+  ssize_t ret;
+  struct android_log_logger_list logger_list;
+  struct android_log_transport_context transp;
+  struct content {
+    struct listnode node;
+    union {
+      struct logger_entry_v4 entry;
+      struct logger_entry_v4 entry_v4;
+      struct logger_entry_v3 entry_v3;
+      struct logger_entry_v2 entry_v2;
+      struct logger_entry entry_v1;
+    };
+  } * content;
+  struct names {
+    struct listnode node;
+    struct listnode content;
+    log_id_t id;
+    char prio;
+    char name[];
+  } * names;
+  struct listnode name_list;
+  struct listnode *node, *n;
+  size_t len, prefix_len;
 
-    if (!fn) {
-        return -EINVAL;
+  if (!fn) {
+    return -EINVAL;
+  }
+
+  /* Add just enough clues in logger_list and transp to make API function */
+  memset(&logger_list, 0, sizeof(logger_list));
+  memset(&transp, 0, sizeof(transp));
+
+  logger_list.mode =
+      ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK | ANDROID_LOG_RDONLY;
+  transp.logMask = (unsigned)-1;
+  if (logId != LOG_ID_ANY) {
+    transp.logMask = (1 << logId);
+  }
+  transp.logMask &=
+      ~((1 << LOG_ID_KERNEL) | (1 << LOG_ID_EVENTS) | (1 << LOG_ID_SECURITY));
+  if (!transp.logMask) {
+    return -EINVAL;
+  }
+
+  /* Initialize name list */
+  list_init(&name_list);
+
+  ret = SSIZE_MAX;
+
+  /* Validate incoming prefix, shift until it contains only 0 or 1 : or / */
+  prefix_len = 0;
+  if (prefix) {
+    const char *prev = NULL, *last = NULL, *cp = prefix;
+    while ((cp = strpbrk(cp, "/:"))) {
+      prev = last;
+      last = cp;
+      cp = cp + 1;
+    }
+    if (prev) {
+      prefix = prev + 1;
+    }
+    prefix_len = strlen(prefix);
+  }
+
+  /* Read the file content */
+  while (pmsgRead(&logger_list, &transp, &transp.logMsg) > 0) {
+    char* cp;
+    size_t hdr_size = transp.logMsg.entry.hdr_size
+                          ? transp.logMsg.entry.hdr_size
+                          : sizeof(transp.logMsg.entry_v1);
+    char* msg = (char*)&transp.logMsg + hdr_size;
+    char* split = NULL;
+
+    if ((hdr_size < sizeof(transp.logMsg.entry_v1)) ||
+        (hdr_size > sizeof(transp.logMsg.entry))) {
+      continue;
+    }
+    /* Check for invalid sequence number */
+    if ((transp.logMsg.entry.nsec % ANDROID_LOG_PMSG_FILE_SEQUENCE) ||
+        ((transp.logMsg.entry.nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >=
+         ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE)) {
+      continue;
     }
 
-    /* Add just enough clues in logger_list and transp to make API function */
-    memset(&logger_list, 0, sizeof(logger_list));
-    memset(&transp, 0, sizeof(transp));
-
-    logger_list.mode = ANDROID_LOG_PSTORE |
-                       ANDROID_LOG_NONBLOCK |
-                       ANDROID_LOG_RDONLY;
-    transp.logMask = (unsigned)-1;
-    if (logId != LOG_ID_ANY) {
-        transp.logMask = (1 << logId);
+    /* Determine if it has <dirbase>:<filebase> format for tag */
+    len = transp.logMsg.entry.len - sizeof(prio);
+    for (cp = msg + sizeof(prio); *cp && isprint(*cp) && !isspace(*cp) && --len;
+         ++cp) {
+      if (*cp == ':') {
+        if (split) {
+          break;
+        }
+        split = cp;
+      }
     }
-    transp.logMask &= ~((1 << LOG_ID_KERNEL) |
-                        (1 << LOG_ID_EVENTS) |
-                        (1 << LOG_ID_SECURITY));
-    if (!transp.logMask) {
-        return -EINVAL;
+    if (*cp || !split) {
+      continue;
     }
 
-    /* Initialize name list */
-    list_init(&name_list);
-
-    ret = SSIZE_MAX;
-
-    /* Validate incoming prefix, shift until it contains only 0 or 1 : or / */
-    prefix_len = 0;
-    if (prefix) {
-        const char *prev = NULL, *last = NULL, *cp = prefix;
-        while ((cp = strpbrk(cp, "/:"))) {
-            prev = last;
-            last = cp;
-            cp = cp + 1;
-        }
-        if (prev) {
-            prefix = prev + 1;
-        }
-        prefix_len = strlen(prefix);
+    /* Filters */
+    if (prefix_len && strncmp(msg + sizeof(prio), prefix, prefix_len)) {
+      size_t offset;
+      /*
+       *   Allow : to be a synonym for /
+       * Things we do dealing with const char * and do not alloc
+       */
+      split = strchr(prefix, ':');
+      if (split) {
+        continue;
+      }
+      split = strchr(prefix, '/');
+      if (!split) {
+        continue;
+      }
+      offset = split - prefix;
+      if ((msg[offset + sizeof(prio)] != ':') ||
+          strncmp(msg + sizeof(prio), prefix, offset)) {
+        continue;
+      }
+      ++offset;
+      if ((prefix_len > offset) && strncmp(&msg[offset + sizeof(prio)],
+                                           split + 1, prefix_len - offset)) {
+        continue;
+      }
     }
 
-    /* Read the file content */
-    while (pmsgRead(&logger_list, &transp, &transp.logMsg) > 0) {
-        char *cp;
-        size_t hdr_size = transp.logMsg.entry.hdr_size ?
-            transp.logMsg.entry.hdr_size : sizeof(transp.logMsg.entry_v1);
-        char *msg = (char *)&transp.logMsg + hdr_size;
-        char *split = NULL;
-
-        if ((hdr_size < sizeof(transp.logMsg.entry_v1)) ||
-                (hdr_size > sizeof(transp.logMsg.entry))) {
-            continue;
-        }
-        /* Check for invalid sequence number */
-        if ((transp.logMsg.entry.nsec % ANDROID_LOG_PMSG_FILE_SEQUENCE) ||
-                ((transp.logMsg.entry.nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >=
-                    ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE)) {
-            continue;
-        }
-
-        /* Determine if it has <dirbase>:<filebase> format for tag */
-        len = transp.logMsg.entry.len - sizeof(prio);
-        for (cp = msg + sizeof(prio);
-                *cp && isprint(*cp) && !isspace(*cp) && --len;
-                ++cp) {
-            if (*cp == ':') {
-                if (split) {
-                    break;
-                }
-                split = cp;
-            }
-        }
-        if (*cp || !split) {
-            continue;
-        }
-
-        /* Filters */
-        if (prefix_len && strncmp(msg + sizeof(prio), prefix, prefix_len)) {
-            size_t offset;
-            /*
-             *   Allow : to be a synonym for /
-             * Things we do dealing with const char * and do not alloc
-             */
-            split = strchr(prefix, ':');
-            if (split) {
-                continue;
-            }
-            split = strchr(prefix, '/');
-            if (!split) {
-                continue;
-            }
-            offset = split - prefix;
-            if ((msg[offset + sizeof(prio)] != ':') ||
-                    strncmp(msg + sizeof(prio), prefix, offset)) {
-                continue;
-            }
-            ++offset;
-            if ((prefix_len > offset) &&
-                    strncmp(&msg[offset + sizeof(prio)], split + 1, prefix_len - offset)) {
-                continue;
-            }
-        }
-
-        if ((prio != ANDROID_LOG_ANY) && (*msg < prio)) {
-            continue;
-        }
-
-        /* check if there is an existing entry */
-        list_for_each(node, &name_list) {
-            names = node_to_item(node, struct names, node);
-            if (!strcmp(names->name, msg + sizeof(prio)) &&
-                    (names->id == transp.logMsg.entry.lid) &&
-                    (names->prio == *msg)) {
-                break;
-            }
-        }
-
-        /* We do not have an existing entry, create and add one */
-        if (node == &name_list) {
-            static const char numbers[] = "0123456789";
-            unsigned long long nl;
-
-            len = strlen(msg + sizeof(prio)) + 1;
-            names = calloc(1, sizeof(*names) + len);
-            if (!names) {
-                ret = -ENOMEM;
-                break;
-            }
-            strcpy(names->name, msg + sizeof(prio));
-            names->id = transp.logMsg.entry.lid;
-            names->prio = *msg;
-            list_init(&names->content);
-            /*
-             * Insert in reverse numeric _then_ alpha sorted order as
-             * representative of log rotation:
-             *
-             *   log.10
-             *   klog.10
-             *   . . .
-             *   log.2
-             *   klog.2
-             *   log.1
-             *   klog.1
-             *   log
-             *   klog
-             *
-             * thus when we present the content, we are provided the oldest
-             * first, which when 'refreshed' could spill off the end of the
-             * pmsg FIFO but retaining the newest data for last with best
-             * chances to survive.
-             */
-            nl = 0;
-            cp = strpbrk(names->name, numbers);
-            if (cp) {
-                nl = strtoull(cp, NULL, 10);
-            }
-            list_for_each_reverse(node, &name_list) {
-                struct names *a_name = node_to_item(node, struct names, node);
-                const char *r = a_name->name;
-                int compare = 0;
-
-                unsigned long long nr = 0;
-                cp = strpbrk(r, numbers);
-                if (cp) {
-                    nr = strtoull(cp, NULL, 10);
-                }
-                if (nr != nl) {
-                    compare = (nl > nr) ? 1 : -1;
-                }
-                if (compare == 0) {
-                    compare = strcmp(names->name, r);
-                }
-                if (compare <= 0) {
-                    break;
-                }
-            }
-            list_add_head(node, &names->node);
-        }
-
-        /* Remove any file fragments that match our sequence number */
-        list_for_each_safe(node, n, &names->content) {
-            content = node_to_item(node, struct content, node);
-            if (transp.logMsg.entry.nsec == content->entry.nsec) {
-                list_remove(&content->node);
-                free(content);
-            }
-        }
-
-        /* Add content */
-        content = calloc(1, sizeof(content->node) +
-                hdr_size + transp.logMsg.entry.len);
-        if (!content) {
-            ret = -ENOMEM;
-            break;
-        }
-        memcpy(&content->entry, &transp.logMsg.entry,
-               hdr_size + transp.logMsg.entry.len);
-
-        /* Insert in sequence number sorted order, to ease reconstruction */
-        list_for_each_reverse(node, &names->content) {
-            if ((node_to_item(node, struct content, node))->entry.nsec <
-                    transp.logMsg.entry.nsec) {
-                break;
-            }
-        }
-        list_add_head(node, &content->node);
+    if ((prio != ANDROID_LOG_ANY) && (*msg < prio)) {
+      continue;
     }
-    pmsgClose(&logger_list, &transp);
 
-    /* Progress through all the collected files */
-    list_for_each_safe(node, n, &name_list) {
-        struct listnode *content_node, *m;
-        char *buf;
-        size_t sequence, tag_len;
-
-        names = node_to_item(node, struct names, node);
-
-        /* Construct content into a linear buffer */
-        buf = NULL;
-        len = 0;
-        sequence = 0;
-        tag_len = strlen(names->name) + sizeof(char); /* tag + nul */
-        list_for_each_safe(content_node, m, &names->content) {
-            ssize_t add_len;
-
-            content = node_to_item(content_node, struct content, node);
-            add_len = content->entry.len - tag_len - sizeof(prio);
-            if (add_len <= 0) {
-                list_remove(content_node);
-                free(content);
-                continue;
-            }
-
-            if (!buf) {
-                buf = malloc(sizeof(char));
-                if (!buf) {
-                    ret = -ENOMEM;
-                    list_remove(content_node);
-                    free(content);
-                    continue;
-                }
-                *buf = '\0';
-            }
-
-            /* Missing sequence numbers */
-            while (sequence < content->entry.nsec) {
-                /* plus space for enforced nul */
-                buf = realloc(buf, len + sizeof(char) + sizeof(char));
-                if (!buf) {
-                    break;
-                }
-                buf[len] = '\f'; /* Mark missing content with a form feed */
-                buf[++len] = '\0';
-                sequence += ANDROID_LOG_PMSG_FILE_SEQUENCE;
-            }
-            if (!buf) {
-                ret = -ENOMEM;
-                list_remove(content_node);
-                free(content);
-                continue;
-            }
-            /* plus space for enforced nul */
-            buf = realloc(buf, len + add_len + sizeof(char));
-            if (!buf) {
-                ret = -ENOMEM;
-                list_remove(content_node);
-                free(content);
-                continue;
-            }
-            memcpy(buf + len,
-                   (char *)&content->entry + content->entry.hdr_size +
-                       tag_len + sizeof(prio),
-                   add_len);
-            len += add_len;
-            buf[len] = '\0'; /* enforce trailing hidden nul */
-            sequence = content->entry.nsec + ANDROID_LOG_PMSG_FILE_SEQUENCE;
-
-            list_remove(content_node);
-            free(content);
-        }
-        if (buf) {
-            if (len) {
-                /* Buffer contains enforced trailing nul just beyond length */
-                ssize_t r;
-                *strchr(names->name, ':') = '/'; /* Convert back to filename */
-                r = (*fn)(names->id, names->prio, names->name, buf, len, arg);
-                if ((ret >= 0) && (r > 0)) {
-                    if (ret == SSIZE_MAX) {
-                        ret = r;
-                    } else {
-                        ret += r;
-                    }
-                } else if (r < ret) {
-                    ret = r;
-                }
-            }
-            free(buf);
-        }
-        list_remove(node);
-        free(names);
+    /* check if there is an existing entry */
+    list_for_each(node, &name_list) {
+      names = node_to_item(node, struct names, node);
+      if (!strcmp(names->name, msg + sizeof(prio)) &&
+          (names->id == transp.logMsg.entry.lid) && (names->prio == *msg)) {
+        break;
+      }
     }
-    return (ret == SSIZE_MAX) ? -ENOENT : ret;
+
+    /* We do not have an existing entry, create and add one */
+    if (node == &name_list) {
+      static const char numbers[] = "0123456789";
+      unsigned long long nl;
+
+      len = strlen(msg + sizeof(prio)) + 1;
+      names = calloc(1, sizeof(*names) + len);
+      if (!names) {
+        ret = -ENOMEM;
+        break;
+      }
+      strcpy(names->name, msg + sizeof(prio));
+      names->id = transp.logMsg.entry.lid;
+      names->prio = *msg;
+      list_init(&names->content);
+      /*
+       * Insert in reverse numeric _then_ alpha sorted order as
+       * representative of log rotation:
+       *
+       *   log.10
+       *   klog.10
+       *   . . .
+       *   log.2
+       *   klog.2
+       *   log.1
+       *   klog.1
+       *   log
+       *   klog
+       *
+       * thus when we present the content, we are provided the oldest
+       * first, which when 'refreshed' could spill off the end of the
+       * pmsg FIFO but retaining the newest data for last with best
+       * chances to survive.
+       */
+      nl = 0;
+      cp = strpbrk(names->name, numbers);
+      if (cp) {
+        nl = strtoull(cp, NULL, 10);
+      }
+      list_for_each_reverse(node, &name_list) {
+        struct names* a_name = node_to_item(node, struct names, node);
+        const char* r = a_name->name;
+        int compare = 0;
+
+        unsigned long long nr = 0;
+        cp = strpbrk(r, numbers);
+        if (cp) {
+          nr = strtoull(cp, NULL, 10);
+        }
+        if (nr != nl) {
+          compare = (nl > nr) ? 1 : -1;
+        }
+        if (compare == 0) {
+          compare = strcmp(names->name, r);
+        }
+        if (compare <= 0) {
+          break;
+        }
+      }
+      list_add_head(node, &names->node);
+    }
+
+    /* Remove any file fragments that match our sequence number */
+    list_for_each_safe(node, n, &names->content) {
+      content = node_to_item(node, struct content, node);
+      if (transp.logMsg.entry.nsec == content->entry.nsec) {
+        list_remove(&content->node);
+        free(content);
+      }
+    }
+
+    /* Add content */
+    content =
+        calloc(1, sizeof(content->node) + hdr_size + transp.logMsg.entry.len);
+    if (!content) {
+      ret = -ENOMEM;
+      break;
+    }
+    memcpy(&content->entry, &transp.logMsg.entry,
+           hdr_size + transp.logMsg.entry.len);
+
+    /* Insert in sequence number sorted order, to ease reconstruction */
+    list_for_each_reverse(node, &names->content) {
+      if ((node_to_item(node, struct content, node))->entry.nsec <
+          transp.logMsg.entry.nsec) {
+        break;
+      }
+    }
+    list_add_head(node, &content->node);
+  }
+  pmsgClose(&logger_list, &transp);
+
+  /* Progress through all the collected files */
+  list_for_each_safe(node, n, &name_list) {
+    struct listnode *content_node, *m;
+    char* buf;
+    size_t sequence, tag_len;
+
+    names = node_to_item(node, struct names, node);
+
+    /* Construct content into a linear buffer */
+    buf = NULL;
+    len = 0;
+    sequence = 0;
+    tag_len = strlen(names->name) + sizeof(char); /* tag + nul */
+    list_for_each_safe(content_node, m, &names->content) {
+      ssize_t add_len;
+
+      content = node_to_item(content_node, struct content, node);
+      add_len = content->entry.len - tag_len - sizeof(prio);
+      if (add_len <= 0) {
+        list_remove(content_node);
+        free(content);
+        continue;
+      }
+
+      if (!buf) {
+        buf = malloc(sizeof(char));
+        if (!buf) {
+          ret = -ENOMEM;
+          list_remove(content_node);
+          free(content);
+          continue;
+        }
+        *buf = '\0';
+      }
+
+      /* Missing sequence numbers */
+      while (sequence < content->entry.nsec) {
+        /* plus space for enforced nul */
+        buf = realloc(buf, len + sizeof(char) + sizeof(char));
+        if (!buf) {
+          break;
+        }
+        buf[len] = '\f'; /* Mark missing content with a form feed */
+        buf[++len] = '\0';
+        sequence += ANDROID_LOG_PMSG_FILE_SEQUENCE;
+      }
+      if (!buf) {
+        ret = -ENOMEM;
+        list_remove(content_node);
+        free(content);
+        continue;
+      }
+      /* plus space for enforced nul */
+      buf = realloc(buf, len + add_len + sizeof(char));
+      if (!buf) {
+        ret = -ENOMEM;
+        list_remove(content_node);
+        free(content);
+        continue;
+      }
+      memcpy(buf + len,
+             (char*)&content->entry + content->entry.hdr_size + tag_len +
+                 sizeof(prio),
+             add_len);
+      len += add_len;
+      buf[len] = '\0'; /* enforce trailing hidden nul */
+      sequence = content->entry.nsec + ANDROID_LOG_PMSG_FILE_SEQUENCE;
+
+      list_remove(content_node);
+      free(content);
+    }
+    if (buf) {
+      if (len) {
+        /* Buffer contains enforced trailing nul just beyond length */
+        ssize_t r;
+        *strchr(names->name, ':') = '/'; /* Convert back to filename */
+        r = (*fn)(names->id, names->prio, names->name, buf, len, arg);
+        if ((ret >= 0) && (r > 0)) {
+          if (ret == SSIZE_MAX) {
+            ret = r;
+          } else {
+            ret += r;
+          }
+        } else if (r < ret) {
+          ret = r;
+        }
+      }
+      free(buf);
+    }
+    list_remove(node);
+    free(names);
+  }
+  return (ret == SSIZE_MAX) ? -ENOENT : ret;
 }
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index 5e4ff98..e71c176 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -36,155 +36,149 @@
 static int pmsgOpen();
 static void pmsgClose();
 static int pmsgAvailable(log_id_t logId);
-static int pmsgWrite(log_id_t logId, struct timespec *ts,
-                      struct iovec *vec, size_t nr);
+static int pmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                     size_t nr);
 
 LIBLOG_HIDDEN struct android_log_transport_write pmsgLoggerWrite = {
-    .node = { &pmsgLoggerWrite.node, &pmsgLoggerWrite.node },
-    .context.fd = -1,
-    .name = "pmsg",
-    .available = pmsgAvailable,
-    .open = pmsgOpen,
-    .close = pmsgClose,
-    .write = pmsgWrite,
+  .node = { &pmsgLoggerWrite.node, &pmsgLoggerWrite.node },
+  .context.fd = -1,
+  .name = "pmsg",
+  .available = pmsgAvailable,
+  .open = pmsgOpen,
+  .close = pmsgClose,
+  .write = pmsgWrite,
 };
 
-static int pmsgOpen()
-{
-    int fd = atomic_load(&pmsgLoggerWrite.context.fd);
-    if (fd < 0) {
-        int i;
+static int pmsgOpen() {
+  int fd = atomic_load(&pmsgLoggerWrite.context.fd);
+  if (fd < 0) {
+    int i;
 
-        fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
-        i = atomic_exchange(&pmsgLoggerWrite.context.fd, fd);
-        if ((i >= 0) && (i != fd)) {
-            close(i);
-        }
+    fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
+    i = atomic_exchange(&pmsgLoggerWrite.context.fd, fd);
+    if ((i >= 0) && (i != fd)) {
+      close(i);
     }
+  }
 
-    return fd;
+  return fd;
 }
 
-static void pmsgClose()
-{
-    int fd = atomic_exchange(&pmsgLoggerWrite.context.fd, -1);
-    if (fd >= 0) {
-        close(fd);
-    }
+static void pmsgClose() {
+  int fd = atomic_exchange(&pmsgLoggerWrite.context.fd, -1);
+  if (fd >= 0) {
+    close(fd);
+  }
 }
 
-static int pmsgAvailable(log_id_t logId)
-{
-    if (logId > LOG_ID_SECURITY) {
-        return -EINVAL;
+static int pmsgAvailable(log_id_t logId) {
+  if (logId > LOG_ID_SECURITY) {
+    return -EINVAL;
+  }
+  if ((logId != LOG_ID_SECURITY) && (logId != LOG_ID_EVENTS) &&
+      !__android_log_is_debuggable()) {
+    return -EINVAL;
+  }
+  if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
+    if (access("/dev/pmsg0", W_OK) == 0) {
+      return 0;
     }
-    if ((logId != LOG_ID_SECURITY) &&
-            (logId != LOG_ID_EVENTS) &&
-            !__android_log_is_debuggable()) {
-        return -EINVAL;
-    }
-    if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
-        if (access("/dev/pmsg0", W_OK) == 0) {
-            return 0;
-        }
-        return -EBADF;
-    }
-    return 1;
+    return -EBADF;
+  }
+  return 1;
 }
 
 /*
  * Extract a 4-byte value from a byte stream.
  */
-static inline uint32_t get4LE(const uint8_t* src)
-{
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+static inline uint32_t get4LE(const uint8_t* src) {
+  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
-static int pmsgWrite(log_id_t logId, struct timespec *ts,
-                      struct iovec *vec, size_t nr)
-{
-    static const unsigned headerLength = 2;
-    struct iovec newVec[nr + headerLength];
-    android_log_header_t header;
-    android_pmsg_log_header_t pmsgHeader;
-    size_t i, payloadSize;
-    ssize_t ret;
+static int pmsgWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                     size_t nr) {
+  static const unsigned headerLength = 2;
+  struct iovec newVec[nr + headerLength];
+  android_log_header_t header;
+  android_pmsg_log_header_t pmsgHeader;
+  size_t i, payloadSize;
+  ssize_t ret;
 
-    if ((logId == LOG_ID_EVENTS) && !__android_log_is_debuggable()) {
-        if (vec[0].iov_len < 4) {
-            return -EINVAL;
-        }
-
-        if (SNET_EVENT_LOG_TAG != get4LE(vec[0].iov_base)) {
-            return -EPERM;
-        }
+  if ((logId == LOG_ID_EVENTS) && !__android_log_is_debuggable()) {
+    if (vec[0].iov_len < 4) {
+      return -EINVAL;
     }
 
-    if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
-        return -EBADF;
+    if (SNET_EVENT_LOG_TAG != get4LE(vec[0].iov_base)) {
+      return -EPERM;
     }
+  }
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsgHeader;
-     *      // what we provide to file
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
+    return -EBADF;
+  }
 
-    pmsgHeader.magic = LOGGER_MAGIC;
-    pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header);
-    pmsgHeader.uid = __android_log_uid();
-    pmsgHeader.pid = getpid();
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsgHeader;
+   *      // what we provide to file
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    header.id = logId;
-    header.tid = gettid();
-    header.realtime.tv_sec = ts->tv_sec;
-    header.realtime.tv_nsec = ts->tv_nsec;
+  pmsgHeader.magic = LOGGER_MAGIC;
+  pmsgHeader.len = sizeof(pmsgHeader) + sizeof(header);
+  pmsgHeader.uid = __android_log_uid();
+  pmsgHeader.pid = getpid();
 
-    newVec[0].iov_base   = (unsigned char *)&pmsgHeader;
-    newVec[0].iov_len    = sizeof(pmsgHeader);
-    newVec[1].iov_base   = (unsigned char *)&header;
-    newVec[1].iov_len    = sizeof(header);
+  header.id = logId;
+  header.tid = gettid();
+  header.realtime.tv_sec = ts->tv_sec;
+  header.realtime.tv_nsec = ts->tv_nsec;
 
-    for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
-        newVec[i].iov_base = vec[i - headerLength].iov_base;
-        payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
+  newVec[0].iov_base = (unsigned char*)&pmsgHeader;
+  newVec[0].iov_len = sizeof(pmsgHeader);
+  newVec[1].iov_base = (unsigned char*)&header;
+  newVec[1].iov_len = sizeof(header);
 
-        if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
-            newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
-            if (newVec[i].iov_len) {
-                ++i;
-            }
-            payloadSize = LOGGER_ENTRY_MAX_PAYLOAD;
-            break;
-        }
+  for (payloadSize = 0, i = headerLength; i < nr + headerLength; i++) {
+    newVec[i].iov_base = vec[i - headerLength].iov_base;
+    payloadSize += newVec[i].iov_len = vec[i - headerLength].iov_len;
+
+    if (payloadSize > LOGGER_ENTRY_MAX_PAYLOAD) {
+      newVec[i].iov_len -= payloadSize - LOGGER_ENTRY_MAX_PAYLOAD;
+      if (newVec[i].iov_len) {
+        ++i;
+      }
+      payloadSize = LOGGER_ENTRY_MAX_PAYLOAD;
+      break;
     }
-    pmsgHeader.len += payloadSize;
+  }
+  pmsgHeader.len += payloadSize;
 
-    ret = TEMP_FAILURE_RETRY(writev(atomic_load(&pmsgLoggerWrite.context.fd),
-                                    newVec, i));
-    if (ret < 0) {
-        ret = errno ? -errno : -ENOTCONN;
-    }
+  ret = TEMP_FAILURE_RETRY(
+      writev(atomic_load(&pmsgLoggerWrite.context.fd), newVec, i));
+  if (ret < 0) {
+    ret = errno ? -errno : -ENOTCONN;
+  }
 
-    if (ret > (ssize_t)(sizeof(header) + sizeof(pmsgHeader))) {
-        ret -= sizeof(header) - sizeof(pmsgHeader);
-    }
+  if (ret > (ssize_t)(sizeof(header) + sizeof(pmsgHeader))) {
+    ret -= sizeof(header) - sizeof(pmsgHeader);
+  }
 
-    return ret;
+  return ret;
 }
 
 /*
@@ -197,116 +191,116 @@
  * Will hijack the header.realtime.tv_nsec field for a sequence number in usec.
  */
 
-static inline const char *strnrchr(const char *buf, size_t len, char c) {
-    const char *cp = buf + len;
-    while ((--cp > buf) && (*cp != c));
-    if (cp <= buf) {
-        return buf + len;
-    }
-    return cp;
+static inline const char* strnrchr(const char* buf, size_t len, char c) {
+  const char* cp = buf + len;
+  while ((--cp > buf) && (*cp != c))
+    ;
+  if (cp <= buf) {
+    return buf + len;
+  }
+  return cp;
 }
 
 /* Write a buffer as filename references (tag = <basedir>:<basename>) */
-LIBLOG_ABI_PRIVATE ssize_t __android_log_pmsg_file_write(
-        log_id_t logId,
-        char prio,
-        const char *filename,
-        const char *buf, size_t len) {
-    bool weOpened;
-    size_t length, packet_len;
-    const char *tag;
-    char *cp, *slash;
-    struct timespec ts;
-    struct iovec vec[3];
+LIBLOG_ABI_PRIVATE ssize_t __android_log_pmsg_file_write(log_id_t logId,
+                                                         char prio,
+                                                         const char* filename,
+                                                         const char* buf,
+                                                         size_t len) {
+  bool weOpened;
+  size_t length, packet_len;
+  const char* tag;
+  char *cp, *slash;
+  struct timespec ts;
+  struct iovec vec[3];
 
-    /* Make sure the logId value is not a bad idea */
-    if ((logId == LOG_ID_KERNEL) ||       /* Verbotten */
-            (logId == LOG_ID_EVENTS) ||   /* Do not support binary content */
-            (logId == LOG_ID_SECURITY) || /* Bad idea to allow */
-            ((unsigned)logId >= 32)) {    /* fit within logMask on arch32 */
-        return -EINVAL;
-    }
+  /* Make sure the logId value is not a bad idea */
+  if ((logId == LOG_ID_KERNEL) ||   /* Verbotten */
+      (logId == LOG_ID_EVENTS) ||   /* Do not support binary content */
+      (logId == LOG_ID_SECURITY) || /* Bad idea to allow */
+      ((unsigned)logId >= 32)) {    /* fit within logMask on arch32 */
+    return -EINVAL;
+  }
 
-    clock_gettime(android_log_clockid(), &ts);
+  clock_gettime(android_log_clockid(), &ts);
 
-    cp = strdup(filename);
-    if (!cp) {
-        return -ENOMEM;
-    }
+  cp = strdup(filename);
+  if (!cp) {
+    return -ENOMEM;
+  }
 
-    tag = cp;
+  tag = cp;
+  slash = strrchr(cp, '/');
+  if (slash) {
+    *slash = ':';
     slash = strrchr(cp, '/');
     if (slash) {
-        *slash = ':';
-        slash = strrchr(cp, '/');
-        if (slash) {
-            tag = slash + 1;
-        }
+      tag = slash + 1;
+    }
+  }
+
+  length = strlen(tag) + 1;
+  packet_len = LOGGER_ENTRY_MAX_PAYLOAD - sizeof(char) - length;
+
+  vec[0].iov_base = &prio;
+  vec[0].iov_len = sizeof(char);
+  vec[1].iov_base = (unsigned char*)tag;
+  vec[1].iov_len = length;
+
+  weOpened = false;
+  for (ts.tv_nsec = 0, length = len; length;
+       ts.tv_nsec += ANDROID_LOG_PMSG_FILE_SEQUENCE) {
+    ssize_t ret;
+    size_t transfer;
+
+    if ((ts.tv_nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >=
+        ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE) {
+      len -= length;
+      break;
     }
 
-    length = strlen(tag) + 1;
-    packet_len = LOGGER_ENTRY_MAX_PAYLOAD - sizeof(char) - length;
-
-    vec[0].iov_base = &prio;
-    vec[0].iov_len  = sizeof(char);
-    vec[1].iov_base = (unsigned char *)tag;
-    vec[1].iov_len  = length;
-
-    weOpened = false;
-    for (ts.tv_nsec = 0, length = len;
-            length;
-            ts.tv_nsec += ANDROID_LOG_PMSG_FILE_SEQUENCE) {
-        ssize_t ret;
-        size_t transfer;
-
-        if ((ts.tv_nsec / ANDROID_LOG_PMSG_FILE_SEQUENCE) >=
-                ANDROID_LOG_PMSG_FILE_MAX_SEQUENCE) {
-            len -= length;
-            break;
-        }
-
-        transfer = length;
-        if (transfer > packet_len) {
-            transfer = strnrchr(buf, packet_len - 1, '\n') - buf;
-            if ((transfer < length) && (buf[transfer] == '\n')) {
-                ++transfer;
-            }
-        }
-
-        vec[2].iov_base = (unsigned char *)buf;
-        vec[2].iov_len  = transfer;
-
-        if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
-            if (!weOpened) { /* Impossible for weOpened = true here */
-                __android_log_lock();
-            }
-            weOpened = atomic_load(&pmsgLoggerWrite.context.fd) < 0;
-            if (!weOpened) {
-                __android_log_unlock();
-            } else if (pmsgOpen() < 0) {
-                __android_log_unlock();
-                free(cp);
-                return -EBADF;
-            }
-        }
-
-        ret = pmsgWrite(logId, &ts, vec, sizeof(vec) / sizeof(vec[0]));
-
-        if (ret <= 0) {
-            if (weOpened) {
-                pmsgClose();
-                __android_log_unlock();
-            }
-            free(cp);
-            return ret ? ret : (len - length);
-        }
-        length -= transfer;
-        buf += transfer;
+    transfer = length;
+    if (transfer > packet_len) {
+      transfer = strnrchr(buf, packet_len - 1, '\n') - buf;
+      if ((transfer < length) && (buf[transfer] == '\n')) {
+        ++transfer;
+      }
     }
-    if (weOpened) {
+
+    vec[2].iov_base = (unsigned char*)buf;
+    vec[2].iov_len = transfer;
+
+    if (atomic_load(&pmsgLoggerWrite.context.fd) < 0) {
+      if (!weOpened) { /* Impossible for weOpened = true here */
+        __android_log_lock();
+      }
+      weOpened = atomic_load(&pmsgLoggerWrite.context.fd) < 0;
+      if (!weOpened) {
+        __android_log_unlock();
+      } else if (pmsgOpen() < 0) {
+        __android_log_unlock();
+        free(cp);
+        return -EBADF;
+      }
+    }
+
+    ret = pmsgWrite(logId, &ts, vec, sizeof(vec) / sizeof(vec[0]));
+
+    if (ret <= 0) {
+      if (weOpened) {
         pmsgClose();
         __android_log_unlock();
+      }
+      free(cp);
+      return ret ? ret : (len - length);
     }
-    free(cp);
-    return len;
+    length -= transfer;
+    buf += transfer;
+  }
+  if (weOpened) {
+    pmsgClose();
+    __android_log_unlock();
+  }
+  free(cp);
+  return len;
 }
diff --git a/liblog/properties.c b/liblog/properties.c
index dda09e0..0b0ef52 100644
--- a/liblog/properties.c
+++ b/liblog/properties.c
@@ -29,179 +29,173 @@
 
 static pthread_mutex_t lock_loggable = PTHREAD_MUTEX_INITIALIZER;
 
-static int lock()
-{
-    /*
-     * If we trigger a signal handler in the middle of locked activity and the
-     * signal handler logs a message, we could get into a deadlock state.
-     */
-    /*
-     *  Any contention, and we can turn around and use the non-cached method
-     * in less time than the system call associated with a mutex to deal with
-     * the contention.
-     */
-    return pthread_mutex_trylock(&lock_loggable);
+static int lock() {
+  /*
+   * If we trigger a signal handler in the middle of locked activity and the
+   * signal handler logs a message, we could get into a deadlock state.
+   */
+  /*
+   *  Any contention, and we can turn around and use the non-cached method
+   * in less time than the system call associated with a mutex to deal with
+   * the contention.
+   */
+  return pthread_mutex_trylock(&lock_loggable);
 }
 
-static void unlock()
-{
-    pthread_mutex_unlock(&lock_loggable);
+static void unlock() {
+  pthread_mutex_unlock(&lock_loggable);
 }
 
 struct cache {
-    const prop_info* pinfo;
-    uint32_t serial;
+  const prop_info* pinfo;
+  uint32_t serial;
 };
 
 struct cache_char {
-    struct cache cache;
-    unsigned char c;
+  struct cache cache;
+  unsigned char c;
 };
 
-static int check_cache(struct cache* cache)
-{
-    return cache->pinfo
-        && __system_property_serial(cache->pinfo) != cache->serial;
+static int check_cache(struct cache* cache) {
+  return cache->pinfo && __system_property_serial(cache->pinfo) != cache->serial;
 }
 
 #define BOOLEAN_TRUE 0xFF
 #define BOOLEAN_FALSE 0xFE
 
-static void refresh_cache(struct cache_char* cache, const char* key)
-{
-    char buf[PROP_VALUE_MAX];
+static void refresh_cache(struct cache_char* cache, const char* key) {
+  char buf[PROP_VALUE_MAX];
 
+  if (!cache->cache.pinfo) {
+    cache->cache.pinfo = __system_property_find(key);
     if (!cache->cache.pinfo) {
-        cache->cache.pinfo = __system_property_find(key);
-        if (!cache->cache.pinfo) {
-            return;
-        }
+      return;
     }
-    cache->cache.serial = __system_property_serial(cache->cache.pinfo);
-    __system_property_read(cache->cache.pinfo, 0, buf);
-    switch(buf[0]) {
-    case 't': case 'T':
-        cache->c = strcasecmp(buf + 1, "rue") ? buf[0] : BOOLEAN_TRUE;
-        break;
-    case 'f': case 'F':
-        cache->c = strcasecmp(buf + 1, "alse") ? buf[0] : BOOLEAN_FALSE;
-        break;
+  }
+  cache->cache.serial = __system_property_serial(cache->cache.pinfo);
+  __system_property_read(cache->cache.pinfo, 0, buf);
+  switch (buf[0]) {
+    case 't':
+    case 'T':
+      cache->c = strcasecmp(buf + 1, "rue") ? buf[0] : BOOLEAN_TRUE;
+      break;
+    case 'f':
+    case 'F':
+      cache->c = strcasecmp(buf + 1, "alse") ? buf[0] : BOOLEAN_FALSE;
+      break;
     default:
-        cache->c = buf[0];
-    }
+      cache->c = buf[0];
+  }
 }
 
-static int __android_log_level(const char* tag, size_t len, int default_prio)
-{
-    /* sizeof() is used on this array below */
-    static const char log_namespace[] = "persist.log.tag.";
-    static const size_t base_offset = 8; /* skip "persist." */
-    /* calculate the size of our key temporary buffer */
-    const size_t taglen = tag ? len : 0;
-    /* sizeof(log_namespace) = strlen(log_namespace) + 1 */
-    char key[sizeof(log_namespace) + taglen]; /* may be > PROP_NAME_MAX */
-    char* kp;
-    size_t i;
-    char c = 0;
+static int __android_log_level(const char* tag, size_t len, int default_prio) {
+  /* sizeof() is used on this array below */
+  static const char log_namespace[] = "persist.log.tag.";
+  static const size_t base_offset = 8; /* skip "persist." */
+  /* calculate the size of our key temporary buffer */
+  const size_t taglen = tag ? len : 0;
+  /* sizeof(log_namespace) = strlen(log_namespace) + 1 */
+  char key[sizeof(log_namespace) + taglen]; /* may be > PROP_NAME_MAX */
+  char* kp;
+  size_t i;
+  char c = 0;
+  /*
+   * Single layer cache of four properties. Priorities are:
+   *    log.tag.<tag>
+   *    persist.log.tag.<tag>
+   *    log.tag
+   *    persist.log.tag
+   * Where the missing tag matches all tags and becomes the
+   * system global default. We do not support ro.log.tag* .
+   */
+  static char last_tag[PROP_NAME_MAX];
+  static uint32_t global_serial;
+  /* some compilers erroneously see uninitialized use. !not_locked */
+  uint32_t current_global_serial = 0;
+  static struct cache_char tag_cache[2];
+  static struct cache_char global_cache[2];
+  int change_detected;
+  int global_change_detected;
+  int not_locked;
+
+  strcpy(key, log_namespace);
+
+  global_change_detected = change_detected = not_locked = lock();
+
+  if (!not_locked) {
     /*
-     * Single layer cache of four properties. Priorities are:
-     *    log.tag.<tag>
-     *    persist.log.tag.<tag>
-     *    log.tag
-     *    persist.log.tag
-     * Where the missing tag matches all tags and becomes the
-     * system global default. We do not support ro.log.tag* .
+     *  check all known serial numbers to changes.
      */
-    static char last_tag[PROP_NAME_MAX];
-    static uint32_t global_serial;
-    /* some compilers erroneously see uninitialized use. !not_locked */
-    uint32_t current_global_serial = 0;
-    static struct cache_char tag_cache[2];
-    static struct cache_char global_cache[2];
-    int change_detected;
-    int global_change_detected;
-    int not_locked;
+    for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
+      if (check_cache(&tag_cache[i].cache)) {
+        change_detected = 1;
+      }
+    }
+    for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
+      if (check_cache(&global_cache[i].cache)) {
+        global_change_detected = 1;
+      }
+    }
 
-    strcpy(key, log_namespace);
+    current_global_serial = __system_property_area_serial();
+    if (current_global_serial != global_serial) {
+      change_detected = 1;
+      global_change_detected = 1;
+    }
+  }
 
-    global_change_detected = change_detected = not_locked = lock();
-
+  if (taglen) {
+    int local_change_detected = change_detected;
     if (!not_locked) {
-        /*
-         *  check all known serial numbers to changes.
-         */
+      if (!last_tag[0] || (last_tag[0] != tag[0]) ||
+          strncmp(
+              last_tag + 1, tag + 1,
+              (len < sizeof(last_tag)) ? (len - 1) : (sizeof(last_tag) - 1)) ||
+          ((len < sizeof(last_tag)) && last_tag[len])) {
+        /* invalidate log.tag.<tag> cache */
         for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-            if (check_cache(&tag_cache[i].cache)) {
-                change_detected = 1;
-            }
+          tag_cache[i].cache.pinfo = NULL;
+          tag_cache[i].c = '\0';
         }
-        for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
-            if (check_cache(&global_cache[i].cache)) {
-                global_change_detected = 1;
-            }
+        last_tag[0] = '\0';
+        local_change_detected = 1;
+      }
+      if (!last_tag[0]) {
+        if (len < sizeof(last_tag)) {
+          strncpy(last_tag, tag, len);
+          last_tag[len] = '\0';
+        } else {
+          strncpy(last_tag, tag, sizeof(last_tag));
         }
-
-        current_global_serial = __system_property_area_serial();
-        if (current_global_serial != global_serial) {
-            change_detected = 1;
-            global_change_detected = 1;
-        }
+      }
     }
+    strncpy(key + sizeof(log_namespace) - 1, tag, len);
+    key[sizeof(log_namespace) - 1 + len] = '\0';
 
-    if (taglen) {
-        int local_change_detected = change_detected;
-        if (!not_locked) {
-            if (!last_tag[0]
-                    || (last_tag[0] != tag[0])
-                    || strncmp(last_tag + 1, tag + 1,
-                               (len < sizeof(last_tag)) ?
-                                    (len - 1) :
-                                    (sizeof(last_tag) - 1))
-                    || ((len < sizeof(last_tag)) && last_tag[len])) {
-                /* invalidate log.tag.<tag> cache */
-                for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-                    tag_cache[i].cache.pinfo = NULL;
-                    tag_cache[i].c = '\0';
-                }
-                last_tag[0] = '\0';
-                local_change_detected = 1;
-            }
-            if (!last_tag[0]) {
-                if (len < sizeof(last_tag)) {
-                    strncpy(last_tag, tag, len);
-                    last_tag[len] = '\0';
-                } else {
-                    strncpy(last_tag, tag, sizeof(last_tag));
-                }
-            }
-        }
-        strncpy(key + sizeof(log_namespace) - 1, tag, len);
-        key[sizeof(log_namespace) - 1 + len] = '\0';
+    kp = key;
+    for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
+      struct cache_char* cache = &tag_cache[i];
+      struct cache_char temp_cache;
 
-        kp = key;
-        for (i = 0; i < (sizeof(tag_cache) / sizeof(tag_cache[0])); ++i) {
-            struct cache_char* cache = &tag_cache[i];
-            struct cache_char temp_cache;
+      if (not_locked) {
+        temp_cache.cache.pinfo = NULL;
+        temp_cache.c = '\0';
+        cache = &temp_cache;
+      }
+      if (local_change_detected) {
+        refresh_cache(cache, kp);
+      }
 
-            if (not_locked) {
-                temp_cache.cache.pinfo = NULL;
-                temp_cache.c = '\0';
-                cache = &temp_cache;
-            }
-            if (local_change_detected) {
-                refresh_cache(cache, kp);
-            }
+      if (cache->c) {
+        c = cache->c;
+        break;
+      }
 
-            if (cache->c) {
-                c = cache->c;
-                break;
-            }
-
-            kp = key + base_offset;
-        }
+      kp = key + base_offset;
     }
+  }
 
-    switch (toupper(c)) { /* if invalid, resort to global */
+  switch (toupper(c)) { /* if invalid, resort to global */
     case 'V':
     case 'D':
     case 'I':
@@ -211,44 +205,45 @@
     case 'A':
     case 'S':
     case BOOLEAN_FALSE: /* Not officially supported */
-        break;
+      break;
     default:
-        /* clear '.' after log.tag */
-        key[sizeof(log_namespace) - 2] = '\0';
+      /* clear '.' after log.tag */
+      key[sizeof(log_namespace) - 2] = '\0';
 
-        kp = key;
-        for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
-            struct cache_char* cache = &global_cache[i];
-            struct cache_char temp_cache;
+      kp = key;
+      for (i = 0; i < (sizeof(global_cache) / sizeof(global_cache[0])); ++i) {
+        struct cache_char* cache = &global_cache[i];
+        struct cache_char temp_cache;
 
-            if (not_locked) {
-                temp_cache = *cache;
-                if (temp_cache.cache.pinfo != cache->cache.pinfo) { /* check atomic */
-                    temp_cache.cache.pinfo = NULL;
-                    temp_cache.c = '\0';
-                }
-                cache = &temp_cache;
-            }
-            if (global_change_detected) {
-                refresh_cache(cache, kp);
-            }
-
-            if (cache->c) {
-                c = cache->c;
-                break;
-            }
-
-            kp = key + base_offset;
+        if (not_locked) {
+          temp_cache = *cache;
+          if (temp_cache.cache.pinfo != cache->cache.pinfo) { /* check atomic */
+            temp_cache.cache.pinfo = NULL;
+            temp_cache.c = '\0';
+          }
+          cache = &temp_cache;
         }
-        break;
-    }
+        if (global_change_detected) {
+          refresh_cache(cache, kp);
+        }
 
-    if (!not_locked) {
-        global_serial = current_global_serial;
-        unlock();
-    }
+        if (cache->c) {
+          c = cache->c;
+          break;
+        }
 
-    switch (toupper(c)) {
+        kp = key + base_offset;
+      }
+      break;
+  }
+
+  if (!not_locked) {
+    global_serial = current_global_serial;
+    unlock();
+  }
+
+  switch (toupper(c)) {
+    /* clang-format off */
     case 'V': return ANDROID_LOG_VERBOSE;
     case 'D': return ANDROID_LOG_DEBUG;
     case 'I': return ANDROID_LOG_INFO;
@@ -258,57 +253,53 @@
     case 'A': return ANDROID_LOG_FATAL;
     case BOOLEAN_FALSE: /* FALLTHRU */ /* Not Officially supported */
     case 'S': return -1; /* ANDROID_LOG_SUPPRESS */
+    /* clang-format on */
+  }
+  return default_prio;
+}
+
+LIBLOG_ABI_PUBLIC int __android_log_is_loggable_len(int prio, const char* tag,
+                                                    size_t len,
+                                                    int default_prio) {
+  int logLevel = __android_log_level(tag, len, default_prio);
+  return logLevel >= 0 && prio >= logLevel;
+}
+
+LIBLOG_ABI_PUBLIC int __android_log_is_loggable(int prio, const char* tag,
+                                                int default_prio) {
+  int logLevel =
+      __android_log_level(tag, (tag && *tag) ? strlen(tag) : 0, default_prio);
+  return logLevel >= 0 && prio >= logLevel;
+}
+
+LIBLOG_ABI_PRIVATE int __android_log_is_debuggable() {
+  static uint32_t serial;
+  static struct cache_char tag_cache;
+  static const char key[] = "ro.debuggable";
+  int ret;
+
+  if (tag_cache.c) { /* ro property does not change after set */
+    ret = tag_cache.c == '1';
+  } else if (lock()) {
+    struct cache_char temp_cache = { { NULL, -1 }, '\0' };
+    refresh_cache(&temp_cache, key);
+    ret = temp_cache.c == '1';
+  } else {
+    int change_detected = check_cache(&tag_cache.cache);
+    uint32_t current_serial = __system_property_area_serial();
+    if (current_serial != serial) {
+      change_detected = 1;
     }
-    return default_prio;
-}
-
-LIBLOG_ABI_PUBLIC int __android_log_is_loggable_len(int prio,
-                                                    const char* tag, size_t len,
-                                                    int default_prio)
-{
-    int logLevel = __android_log_level(tag, len, default_prio);
-    return logLevel >= 0 && prio >= logLevel;
-}
-
-LIBLOG_ABI_PUBLIC int __android_log_is_loggable(int prio,
-                                                const char* tag,
-                                                int default_prio)
-{
-    int logLevel = __android_log_level(tag,
-                                       (tag && *tag) ? strlen(tag) : 0,
-                                       default_prio);
-    return logLevel >= 0 && prio >= logLevel;
-}
-
-LIBLOG_ABI_PRIVATE int __android_log_is_debuggable()
-{
-    static uint32_t serial;
-    static struct cache_char tag_cache;
-    static const char key[] = "ro.debuggable";
-    int ret;
-
-    if (tag_cache.c) { /* ro property does not change after set */
-        ret = tag_cache.c == '1';
-    } else if (lock()) {
-        struct cache_char temp_cache = { { NULL, -1 }, '\0' };
-        refresh_cache(&temp_cache, key);
-        ret = temp_cache.c == '1';
-    } else {
-        int change_detected = check_cache(&tag_cache.cache);
-        uint32_t current_serial = __system_property_area_serial();
-        if (current_serial != serial) {
-            change_detected = 1;
-        }
-        if (change_detected) {
-            refresh_cache(&tag_cache, key);
-            serial = current_serial;
-        }
-        ret = tag_cache.c == '1';
-
-        unlock();
+    if (change_detected) {
+      refresh_cache(&tag_cache, key);
+      serial = current_serial;
     }
+    ret = tag_cache.c == '1';
 
-    return ret;
+    unlock();
+  }
+
+  return ret;
 }
 
 /*
@@ -317,100 +308,88 @@
  * Use a separate lock from is_loggable to keep contention down b/25563384.
  */
 struct cache2_char {
-    pthread_mutex_t lock;
-    uint32_t serial;
-    const char* key_persist;
-    struct cache_char cache_persist;
-    const char* key_ro;
-    struct cache_char cache_ro;
-    unsigned char (*const evaluate)(const struct cache2_char *self);
+  pthread_mutex_t lock;
+  uint32_t serial;
+  const char* key_persist;
+  struct cache_char cache_persist;
+  const char* key_ro;
+  struct cache_char cache_ro;
+  unsigned char (*const evaluate)(const struct cache2_char* self);
 };
 
-static inline unsigned char do_cache2_char(struct cache2_char *self)
-{
-    uint32_t current_serial;
-    int change_detected;
-    unsigned char c;
+static inline unsigned char do_cache2_char(struct cache2_char* self) {
+  uint32_t current_serial;
+  int change_detected;
+  unsigned char c;
 
-    if (pthread_mutex_trylock(&self->lock)) {
-        /* We are willing to accept some race in this context */
-        return self->evaluate(self);
-    }
+  if (pthread_mutex_trylock(&self->lock)) {
+    /* We are willing to accept some race in this context */
+    return self->evaluate(self);
+  }
 
-    change_detected = check_cache(&self->cache_persist.cache)
-                   || check_cache(&self->cache_ro.cache);
-    current_serial = __system_property_area_serial();
-    if (current_serial != self->serial) {
-        change_detected = 1;
-    }
-    if (change_detected) {
-        refresh_cache(&self->cache_persist, self->key_persist);
-        refresh_cache(&self->cache_ro, self->key_ro);
-        self->serial = current_serial;
-    }
-    c = self->evaluate(self);
+  change_detected = check_cache(&self->cache_persist.cache) ||
+                    check_cache(&self->cache_ro.cache);
+  current_serial = __system_property_area_serial();
+  if (current_serial != self->serial) {
+    change_detected = 1;
+  }
+  if (change_detected) {
+    refresh_cache(&self->cache_persist, self->key_persist);
+    refresh_cache(&self->cache_ro, self->key_ro);
+    self->serial = current_serial;
+  }
+  c = self->evaluate(self);
 
-    pthread_mutex_unlock(&self->lock);
+  pthread_mutex_unlock(&self->lock);
 
-    return c;
+  return c;
 }
 
-static unsigned char evaluate_persist_ro(const struct cache2_char *self)
-{
-    unsigned char c = self->cache_persist.c;
+static unsigned char evaluate_persist_ro(const struct cache2_char* self) {
+  unsigned char c = self->cache_persist.c;
 
-    if (c) {
-        return c;
-    }
+  if (c) {
+    return c;
+  }
 
-    return self->cache_ro.c;
+  return self->cache_ro.c;
 }
 
 /*
  * Timestamp state generally remains constant, but can change at any time
  * to handle developer requirements.
  */
-LIBLOG_ABI_PUBLIC clockid_t android_log_clockid()
-{
-    static struct cache2_char clockid = {
-        PTHREAD_MUTEX_INITIALIZER,
-        0,
-        "persist.logd.timestamp",
-        { { NULL, -1 }, '\0' },
-        "ro.logd.timestamp",
-        { { NULL, -1 }, '\0' },
-        evaluate_persist_ro
-    };
+LIBLOG_ABI_PUBLIC clockid_t android_log_clockid() {
+  static struct cache2_char clockid = {
+    PTHREAD_MUTEX_INITIALIZER, 0,
+    "persist.logd.timestamp",  { { NULL, -1 }, '\0' },
+    "ro.logd.timestamp",       { { NULL, -1 }, '\0' },
+    evaluate_persist_ro
+  };
 
-    return (tolower(do_cache2_char(&clockid)) == 'm')
-        ? CLOCK_MONOTONIC
-        : CLOCK_REALTIME;
+  return (tolower(do_cache2_char(&clockid)) == 'm') ? CLOCK_MONOTONIC
+                                                    : CLOCK_REALTIME;
 }
 
 /*
  * Security state generally remains constant, but the DO must be able
  * to turn off logging should it become spammy after an attack is detected.
  */
-static unsigned char evaluate_security(const struct cache2_char *self)
-{
-    unsigned char c = self->cache_ro.c;
+static unsigned char evaluate_security(const struct cache2_char* self) {
+  unsigned char c = self->cache_ro.c;
 
-    return (c != BOOLEAN_FALSE) && c && (self->cache_persist.c == BOOLEAN_TRUE);
+  return (c != BOOLEAN_FALSE) && c && (self->cache_persist.c == BOOLEAN_TRUE);
 }
 
-LIBLOG_ABI_PUBLIC int __android_log_security()
-{
-    static struct cache2_char security = {
-        PTHREAD_MUTEX_INITIALIZER,
-        0,
-        "persist.logd.security",
-        { { NULL, -1 }, BOOLEAN_FALSE },
-        "ro.device_owner",
-        { { NULL, -1 }, BOOLEAN_FALSE },
-        evaluate_security
-    };
+LIBLOG_ABI_PUBLIC int __android_log_security() {
+  static struct cache2_char security = {
+    PTHREAD_MUTEX_INITIALIZER, 0,
+    "persist.logd.security",   { { NULL, -1 }, BOOLEAN_FALSE },
+    "ro.device_owner",         { { NULL, -1 }, BOOLEAN_FALSE },
+    evaluate_security
+  };
 
-    return do_cache2_char(&security);
+  return do_cache2_char(&security);
 }
 
 /*
@@ -420,245 +399,240 @@
 
 /* Property helper */
 static bool check_flag(const char* prop, const char* flag) {
-    const char* cp = strcasestr(prop, flag);
-    if (!cp) {
-        return false;
-    }
-    /* We only will document comma (,) */
-    static const char sep[] = ",:;|+ \t\f";
-    if ((cp != prop) && !strchr(sep, cp[-1])) {
-        return false;
-    }
-    cp += strlen(flag);
-    return !*cp || !!strchr(sep, *cp);
+  const char* cp = strcasestr(prop, flag);
+  if (!cp) {
+    return false;
+  }
+  /* We only will document comma (,) */
+  static const char sep[] = ",:;|+ \t\f";
+  if ((cp != prop) && !strchr(sep, cp[-1])) {
+    return false;
+  }
+  cp += strlen(flag);
+  return !*cp || !!strchr(sep, *cp);
 }
 
 /* cache structure */
 struct cache_property {
-    struct cache cache;
-    char property[PROP_VALUE_MAX];
+  struct cache cache;
+  char property[PROP_VALUE_MAX];
 };
 
-static void refresh_cache_property(struct cache_property* cache, const char* key)
-{
+static void refresh_cache_property(struct cache_property* cache,
+                                   const char* key) {
+  if (!cache->cache.pinfo) {
+    cache->cache.pinfo = __system_property_find(key);
     if (!cache->cache.pinfo) {
-        cache->cache.pinfo = __system_property_find(key);
-        if (!cache->cache.pinfo) {
-            return;
-        }
+      return;
     }
-    cache->cache.serial = __system_property_serial(cache->cache.pinfo);
-    __system_property_read(cache->cache.pinfo, 0, cache->property);
+  }
+  cache->cache.serial = __system_property_serial(cache->cache.pinfo);
+  __system_property_read(cache->cache.pinfo, 0, cache->property);
 }
 
 /* get boolean with the logger twist that supports eng adjustments */
 LIBLOG_ABI_PRIVATE bool __android_logger_property_get_bool(const char* key,
-                                                           int flag)
-{
-    struct cache_property property = { { NULL, -1 }, { 0 } };
-    if (flag & BOOL_DEFAULT_FLAG_PERSIST) {
-        char newkey[PROP_NAME_MAX];
-        snprintf(newkey, sizeof(newkey), "ro.%s", key);
-        refresh_cache_property(&property, newkey);
-        property.cache.pinfo = NULL;
-        property.cache.serial = -1;
-        snprintf(newkey, sizeof(newkey), "persist.%s", key);
-        refresh_cache_property(&property, newkey);
-        property.cache.pinfo = NULL;
-        property.cache.serial = -1;
-    }
+                                                           int flag) {
+  struct cache_property property = { { NULL, -1 }, { 0 } };
+  if (flag & BOOL_DEFAULT_FLAG_PERSIST) {
+    char newkey[PROP_NAME_MAX];
+    snprintf(newkey, sizeof(newkey), "ro.%s", key);
+    refresh_cache_property(&property, newkey);
+    property.cache.pinfo = NULL;
+    property.cache.serial = -1;
+    snprintf(newkey, sizeof(newkey), "persist.%s", key);
+    refresh_cache_property(&property, newkey);
+    property.cache.pinfo = NULL;
+    property.cache.serial = -1;
+  }
 
-    refresh_cache_property(&property, key);
+  refresh_cache_property(&property, key);
 
-    if (check_flag(property.property, "true")) {
-        return true;
-    }
-    if (check_flag(property.property, "false")) {
-        return false;
-    }
-    if (check_flag(property.property, "eng")) {
-       flag |= BOOL_DEFAULT_FLAG_ENG;
-    }
-    /* this is really a "not" flag */
-    if (check_flag(property.property, "svelte")) {
-       flag |= BOOL_DEFAULT_FLAG_SVELTE;
-    }
+  if (check_flag(property.property, "true")) {
+    return true;
+  }
+  if (check_flag(property.property, "false")) {
+    return false;
+  }
+  if (check_flag(property.property, "eng")) {
+    flag |= BOOL_DEFAULT_FLAG_ENG;
+  }
+  /* this is really a "not" flag */
+  if (check_flag(property.property, "svelte")) {
+    flag |= BOOL_DEFAULT_FLAG_SVELTE;
+  }
 
-    /* Sanity Check */
-    if (flag & (BOOL_DEFAULT_FLAG_SVELTE | BOOL_DEFAULT_FLAG_ENG)) {
-        flag &= ~BOOL_DEFAULT_FLAG_TRUE_FALSE;
-        flag |= BOOL_DEFAULT_TRUE;
-    }
+  /* Sanity Check */
+  if (flag & (BOOL_DEFAULT_FLAG_SVELTE | BOOL_DEFAULT_FLAG_ENG)) {
+    flag &= ~BOOL_DEFAULT_FLAG_TRUE_FALSE;
+    flag |= BOOL_DEFAULT_TRUE;
+  }
 
-    if ((flag & BOOL_DEFAULT_FLAG_SVELTE)
-            && __android_logger_property_get_bool("ro.config.low_ram",
-                                 BOOL_DEFAULT_FALSE)) {
-        return false;
-    }
-    if ((flag & BOOL_DEFAULT_FLAG_ENG) && !__android_log_is_debuggable()) {
-        return false;
-    }
+  if ((flag & BOOL_DEFAULT_FLAG_SVELTE) &&
+      __android_logger_property_get_bool("ro.config.low_ram",
+                                         BOOL_DEFAULT_FALSE)) {
+    return false;
+  }
+  if ((flag & BOOL_DEFAULT_FLAG_ENG) && !__android_log_is_debuggable()) {
+    return false;
+  }
 
-    return (flag & BOOL_DEFAULT_FLAG_TRUE_FALSE) != BOOL_DEFAULT_FALSE;
+  return (flag & BOOL_DEFAULT_FLAG_TRUE_FALSE) != BOOL_DEFAULT_FALSE;
 }
 
-LIBLOG_ABI_PRIVATE bool __android_logger_valid_buffer_size(unsigned long value)
-{
-    static long pages, pagesize;
-    unsigned long maximum;
+LIBLOG_ABI_PRIVATE bool __android_logger_valid_buffer_size(unsigned long value) {
+  static long pages, pagesize;
+  unsigned long maximum;
 
-    if ((value < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < value)) {
-        return false;
+  if ((value < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < value)) {
+    return false;
+  }
+
+  if (!pages) {
+    pages = sysconf(_SC_PHYS_PAGES);
+  }
+  if (pages < 1) {
+    return true;
+  }
+
+  if (!pagesize) {
+    pagesize = sysconf(_SC_PAGESIZE);
+    if (pagesize <= 1) {
+      pagesize = PAGE_SIZE;
     }
+  }
 
-    if (!pages) {
-        pages = sysconf(_SC_PHYS_PAGES);
-    }
-    if (pages < 1) {
-        return true;
-    }
+  /* maximum memory impact a somewhat arbitrary ~3% */
+  pages = (pages + 31) / 32;
+  maximum = pages * pagesize;
 
-    if (!pagesize) {
-        pagesize = sysconf(_SC_PAGESIZE);
-        if (pagesize <= 1) {
-            pagesize = PAGE_SIZE;
-        }
-    }
+  if ((maximum < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < maximum)) {
+    return true;
+  }
 
-    /* maximum memory impact a somewhat arbitrary ~3% */
-    pages = (pages + 31) / 32;
-    maximum = pages * pagesize;
-
-    if ((maximum < LOG_BUFFER_MIN_SIZE) || (LOG_BUFFER_MAX_SIZE < maximum)) {
-        return true;
-    }
-
-    return value <= maximum;
+  return value <= maximum;
 }
 
 struct cache2_property_size {
-    pthread_mutex_t lock;
-    uint32_t serial;
-    const char* key_persist;
-    struct cache_property cache_persist;
-    const char* key_ro;
-    struct cache_property cache_ro;
-    unsigned long (*const evaluate)(const struct cache2_property_size* self);
+  pthread_mutex_t lock;
+  uint32_t serial;
+  const char* key_persist;
+  struct cache_property cache_persist;
+  const char* key_ro;
+  struct cache_property cache_ro;
+  unsigned long (*const evaluate)(const struct cache2_property_size* self);
 };
 
-static inline unsigned long do_cache2_property_size(struct cache2_property_size* self)
-{
-    uint32_t current_serial;
-    int change_detected;
-    unsigned long v;
+static inline unsigned long do_cache2_property_size(
+    struct cache2_property_size* self) {
+  uint32_t current_serial;
+  int change_detected;
+  unsigned long v;
 
-    if (pthread_mutex_trylock(&self->lock)) {
-        /* We are willing to accept some race in this context */
-        return self->evaluate(self);
-    }
+  if (pthread_mutex_trylock(&self->lock)) {
+    /* We are willing to accept some race in this context */
+    return self->evaluate(self);
+  }
 
-    change_detected = check_cache(&self->cache_persist.cache)
-                   || check_cache(&self->cache_ro.cache);
-    current_serial = __system_property_area_serial();
-    if (current_serial != self->serial) {
-        change_detected = 1;
-    }
-    if (change_detected) {
-        refresh_cache_property(&self->cache_persist, self->key_persist);
-        refresh_cache_property(&self->cache_ro, self->key_ro);
-        self->serial = current_serial;
-    }
-    v = self->evaluate(self);
+  change_detected = check_cache(&self->cache_persist.cache) ||
+                    check_cache(&self->cache_ro.cache);
+  current_serial = __system_property_area_serial();
+  if (current_serial != self->serial) {
+    change_detected = 1;
+  }
+  if (change_detected) {
+    refresh_cache_property(&self->cache_persist, self->key_persist);
+    refresh_cache_property(&self->cache_ro, self->key_ro);
+    self->serial = current_serial;
+  }
+  v = self->evaluate(self);
 
-    pthread_mutex_unlock(&self->lock);
+  pthread_mutex_unlock(&self->lock);
 
-    return v;
+  return v;
 }
 
-static unsigned long property_get_size_from_cache(const struct cache_property* cache)
-{
-    char* cp;
-    unsigned long value = strtoul(cache->property, &cp, 10);
+static unsigned long property_get_size_from_cache(
+    const struct cache_property* cache) {
+  char* cp;
+  unsigned long value = strtoul(cache->property, &cp, 10);
 
-    switch(*cp) {
+  switch (*cp) {
     case 'm':
     case 'M':
-        value *= 1024;
+      value *= 1024;
     /* FALLTHRU */
     case 'k':
     case 'K':
-        value *= 1024;
+      value *= 1024;
     /* FALLTHRU */
     case '\0':
-        break;
+      break;
 
     default:
-        value = 0;
-    }
+      value = 0;
+  }
 
-    if (!__android_logger_valid_buffer_size(value)) {
-        value = 0;
-    }
+  if (!__android_logger_valid_buffer_size(value)) {
+    value = 0;
+  }
 
-    return value;
+  return value;
 }
 
-static unsigned long evaluate_property_get_size(const struct cache2_property_size* self)
-{
-    unsigned long size = property_get_size_from_cache(&self->cache_persist);
-    if (size) {
-        return size;
-    }
-    return property_get_size_from_cache(&self->cache_ro);
+static unsigned long evaluate_property_get_size(
+    const struct cache2_property_size* self) {
+  unsigned long size = property_get_size_from_cache(&self->cache_persist);
+  if (size) {
+    return size;
+  }
+  return property_get_size_from_cache(&self->cache_ro);
 }
 
-LIBLOG_ABI_PRIVATE unsigned long __android_logger_get_buffer_size(log_id_t logId)
-{
-    static const char global_tunable[] = "persist.logd.size"; /* Settings App */
-    static const char global_default[] = "ro.logd.size"; /* BoardConfig.mk */
-    static struct cache2_property_size global = {
-        PTHREAD_MUTEX_INITIALIZER,
-        0,
-        global_tunable,
-        { { NULL, -1 }, {} },
-        global_default,
-        { { NULL, -1 }, {} },
-        evaluate_property_get_size
-    };
-    char key_persist[PROP_NAME_MAX];
-    char key_ro[PROP_NAME_MAX];
-    struct cache2_property_size local = {
-        PTHREAD_MUTEX_INITIALIZER,
-        0,
-        key_persist,
-        { { NULL, -1 }, {} },
-        key_ro,
-        { { NULL, -1 }, {} },
-        evaluate_property_get_size
-    };
-    unsigned long property_size, default_size;
+LIBLOG_ABI_PRIVATE unsigned long __android_logger_get_buffer_size(log_id_t logId) {
+  static const char global_tunable[] = "persist.logd.size"; /* Settings App */
+  static const char global_default[] = "ro.logd.size";      /* BoardConfig.mk */
+  static struct cache2_property_size global = {
+    /* clang-format off */
+    PTHREAD_MUTEX_INITIALIZER, 0,
+    global_tunable, { { NULL, -1 }, {} },
+    global_default, { { NULL, -1 }, {} },
+    evaluate_property_get_size
+    /* clang-format on */
+  };
+  char key_persist[PROP_NAME_MAX];
+  char key_ro[PROP_NAME_MAX];
+  struct cache2_property_size local = {
+    /* clang-format off */
+    PTHREAD_MUTEX_INITIALIZER, 0,
+    key_persist, { { NULL, -1 }, {} },
+    key_ro,      { { NULL, -1 }, {} },
+    evaluate_property_get_size
+    /* clang-format on */
+  };
+  unsigned long property_size, default_size;
 
-    default_size =  do_cache2_property_size(&global);
-    if (!default_size) {
-        default_size = __android_logger_property_get_bool("ro.config.low_ram",
-                                                          BOOL_DEFAULT_FALSE)
-            ? LOG_BUFFER_MIN_SIZE /* 64K  */
-            : LOG_BUFFER_SIZE;    /* 256K */
-    }
+  default_size = do_cache2_property_size(&global);
+  if (!default_size) {
+    default_size = __android_logger_property_get_bool("ro.config.low_ram",
+                                                      BOOL_DEFAULT_FALSE)
+                       ? LOG_BUFFER_MIN_SIZE /* 64K  */
+                       : LOG_BUFFER_SIZE;    /* 256K */
+  }
 
-    snprintf(key_persist, sizeof(key_persist), "%s.%s",
-             global_tunable, android_log_id_to_name(logId));
-    snprintf(key_ro, sizeof(key_ro), "%s.%s",
-             global_default, android_log_id_to_name(logId));
-    property_size = do_cache2_property_size(&local);
+  snprintf(key_persist, sizeof(key_persist), "%s.%s", global_tunable,
+           android_log_id_to_name(logId));
+  snprintf(key_ro, sizeof(key_ro), "%s.%s", global_default,
+           android_log_id_to_name(logId));
+  property_size = do_cache2_property_size(&local);
 
-    if (!property_size) {
-        property_size = default_size;
-    }
+  if (!property_size) {
+    property_size = default_size;
+  }
 
-    if (!property_size) {
-        property_size = LOG_BUFFER_SIZE;
-    }
+  if (!property_size) {
+    property_size = LOG_BUFFER_SIZE;
+  }
 
-    return property_size;
+  return property_size;
 }
diff --git a/liblog/stderr_write.c b/liblog/stderr_write.c
new file mode 100644
index 0000000..dbe5309
--- /dev/null
+++ b/liblog/stderr_write.c
@@ -0,0 +1,212 @@
+/*
+ * 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.
+ */
+
+/*
+ * stderr write handler.  Output is logcat-like, and responds to
+ * logcat's environment variables ANDROID_PRINTF_LOG and
+ * ANDROID_LOG_TAGS to filter output.
+ *
+ * This transport only provides a writer, that means that it does not
+ * provide an End-To-End capability as the logs are effectively _lost_
+ * to the stderr file stream.  The purpose of this transport is to
+ * supply a means for command line tools to report their logging
+ * to the stderr stream, in line with all other activities.
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <log/event_tag_map.h>
+#include <log/log.h>
+#include <log/logprint.h>
+#include <log/uio.h>
+
+#include "log_portability.h"
+#include "logger.h"
+
+static int stderrOpen();
+static void stderrClose();
+static int stderrAvailable(log_id_t logId);
+static int stderrWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                       size_t nr);
+
+struct stderrContext {
+  AndroidLogFormat* logformat;
+#if defined(__ANDROID__)
+  EventTagMap* eventTagMap;
+#endif
+};
+
+LIBLOG_HIDDEN struct android_log_transport_write stderrLoggerWrite = {
+  .node = { &stderrLoggerWrite.node, &stderrLoggerWrite.node },
+  .context.priv = NULL,
+  .name = "stderr",
+  .available = stderrAvailable,
+  .open = stderrOpen,
+  .close = stderrClose,
+  .write = stderrWrite,
+};
+
+static int stderrOpen() {
+  struct stderrContext* ctx;
+  const char* envStr;
+  bool setFormat;
+
+  if (!stderr || (fileno(stderr) < 0)) {
+    return -EBADF;
+  }
+
+  if (stderrLoggerWrite.context.priv) {
+    return fileno(stderr);
+  }
+
+  ctx = calloc(1, sizeof(struct stderrContext));
+  if (!ctx) {
+    return -ENOMEM;
+  }
+
+  ctx->logformat = android_log_format_new();
+  if (!ctx->logformat) {
+    free(ctx);
+    return -ENOMEM;
+  }
+
+  envStr = getenv("ANDROID_PRINTF_LOG");
+  setFormat = false;
+
+  if (envStr) {
+    char* formats = strdup(envStr);
+    char* sv = NULL;
+    char* arg = formats;
+    while (!!(arg = strtok_r(arg, ",:; \t\n\r\f", &sv))) {
+      AndroidLogPrintFormat format = android_log_formatFromString(arg);
+      arg = NULL;
+      if (format == FORMAT_OFF) {
+        continue;
+      }
+      if (android_log_setPrintFormat(ctx->logformat, format) <= 0) {
+        continue;
+      }
+      setFormat = true;
+    }
+    free(formats);
+  }
+  if (!setFormat) {
+    AndroidLogPrintFormat format = android_log_formatFromString("threadtime");
+    android_log_setPrintFormat(ctx->logformat, format);
+  }
+  envStr = getenv("ANDROID_LOG_TAGS");
+  if (envStr) {
+    android_log_addFilterString(ctx->logformat, envStr);
+  }
+  stderrLoggerWrite.context.priv = ctx;
+
+  return fileno(stderr);
+}
+
+static void stderrClose() {
+  struct stderrContext* ctx = stderrLoggerWrite.context.priv;
+
+  if (ctx) {
+    stderrLoggerWrite.context.priv = NULL;
+    if (ctx->logformat) {
+      android_log_format_free(ctx->logformat);
+      ctx->logformat = NULL;
+    }
+#if defined(__ANDROID__)
+    if (ctx->eventTagMap) {
+      android_closeEventTagMap(ctx->eventTagMap);
+      ctx->eventTagMap = NULL;
+    }
+#endif
+  }
+}
+
+static int stderrAvailable(log_id_t logId) {
+  if ((logId >= LOG_ID_MAX) || (logId == LOG_ID_KERNEL)) {
+    return -EINVAL;
+  }
+  return 1;
+}
+
+static int stderrWrite(log_id_t logId, struct timespec* ts, struct iovec* vec,
+                       size_t nr) {
+  struct log_msg log_msg;
+  AndroidLogEntry entry;
+  char binaryMsgBuf[1024];
+  int err;
+  size_t i;
+  struct stderrContext* ctx = stderrLoggerWrite.context.priv;
+
+  if (!ctx) return -EBADF;
+  if (!vec || !nr) return -EINVAL;
+
+  log_msg.entry.len = 0;
+  log_msg.entry.hdr_size = sizeof(log_msg.entry);
+  log_msg.entry.pid = getpid();
+#ifdef __BIONIC__
+  log_msg.entry.tid = gettid();
+#else
+  log_msg.entry.tid = getpid();
+#endif
+  log_msg.entry.sec = ts->tv_sec;
+  log_msg.entry.nsec = ts->tv_nsec;
+  log_msg.entry.lid = logId;
+  log_msg.entry.uid = __android_log_uid();
+
+  for (i = 0; i < nr; ++i) {
+    size_t len = vec[i].iov_len;
+    if ((log_msg.entry.len + len) > LOGGER_ENTRY_MAX_PAYLOAD) {
+      len = LOGGER_ENTRY_MAX_PAYLOAD - log_msg.entry.len;
+    }
+    if (!len) continue;
+    memcpy(log_msg.entry.msg + log_msg.entry.len, vec[i].iov_base, len);
+    log_msg.entry.len += len;
+  }
+
+  if ((logId == LOG_ID_EVENTS) || (logId == LOG_ID_SECURITY)) {
+#if defined(__ANDROID__)
+    if (!ctx->eventTagMap) {
+      ctx->eventTagMap = android_openEventTagMap(NULL);
+    }
+#endif
+    err = android_log_processBinaryLogBuffer(&log_msg.entry_v1, &entry,
+#if defined(__ANDROID__)
+                                             ctx->eventTagMap,
+#else
+                                             NULL,
+#endif
+                                             binaryMsgBuf, sizeof(binaryMsgBuf));
+  } else {
+    err = android_log_processLogBuffer(&log_msg.entry_v1, &entry);
+  }
+
+  /* print known truncated data, in essence logcat --debug */
+  if ((err < 0) && !entry.message) return -EINVAL;
+
+  if (!android_log_shouldPrintLine(ctx->logformat, entry.tag, entry.priority)) {
+    return log_msg.entry.len;
+  }
+
+  err = android_log_printLogLine(ctx->logformat, fileno(stderr), &entry);
+  if (err < 0) return errno ? -errno : -EINVAL;
+  return log_msg.entry.len;
+}
diff --git a/liblog/tests/Android.mk b/liblog/tests/Android.mk
index cfea452..0e6432c 100644
--- a/liblog/tests/Android.mk
+++ b/liblog/tests/Android.mk
@@ -57,6 +57,8 @@
 test_src_files := \
     liblog_test_default.cpp \
     liblog_test_local.cpp \
+    liblog_test_stderr.cpp \
+    liblog_test_stderr_local.cpp \
     log_id_test.cpp \
     log_radio_test.cpp \
     log_read_test.cpp \
diff --git a/liblog/tests/benchmark_main.cpp b/liblog/tests/benchmark_main.cpp
index e5ef970..7367f1b 100644
--- a/liblog/tests/benchmark_main.cpp
+++ b/liblog/tests/benchmark_main.cpp
@@ -22,8 +22,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <string>
 #include <map>
+#include <string>
 #include <vector>
 
 static uint64_t gBytesProcessed;
@@ -32,21 +32,21 @@
 static uint64_t gBenchmarkNum;
 static uint64_t gBenchmarkStartTimeNs;
 
-typedef std::vector< ::testing::Benchmark* > BenchmarkList;
+typedef std::vector< ::testing::Benchmark*> BenchmarkList;
 static BenchmarkList* gBenchmarks;
 
 static int Round(int n) {
   int base = 1;
-  while (base*10 < n) {
+  while (base * 10 < n) {
     base *= 10;
   }
-  if (n < 2*base) {
-    return 2*base;
+  if (n < 2 * base) {
+    return 2 * base;
   }
-  if (n < 5*base) {
-    return 5*base;
+  if (n < 5 * base) {
+    return 5 * base;
   }
-  return 10*base;
+  return 10 * base;
 }
 
 static uint64_t NanoTime() {
@@ -58,20 +58,19 @@
 
 namespace testing {
 
-int PrettyPrintInt(char* str, int len, unsigned int arg)
-{
-  if (arg >= (1<<30) && arg % (1<<30) == 0) {
-    return snprintf(str, len, "%uGi", arg/(1<<30));
-  } else if (arg >= (1<<20) && arg % (1<<20) == 0) {
-    return snprintf(str, len, "%uMi", arg/(1<<20));
-  } else if (arg >= (1<<10) && arg % (1<<10) == 0) {
-    return snprintf(str, len, "%uKi", arg/(1<<10));
+int PrettyPrintInt(char* str, int len, unsigned int arg) {
+  if (arg >= (1 << 30) && arg % (1 << 30) == 0) {
+    return snprintf(str, len, "%uGi", arg / (1 << 30));
+  } else if (arg >= (1 << 20) && arg % (1 << 20) == 0) {
+    return snprintf(str, len, "%uMi", arg / (1 << 20));
+  } else if (arg >= (1 << 10) && arg % (1 << 10) == 0) {
+    return snprintf(str, len, "%uKi", arg / (1 << 10));
   } else if (arg >= 1000000000 && arg % 1000000000 == 0) {
-    return snprintf(str, len, "%uG", arg/1000000000);
+    return snprintf(str, len, "%uG", arg / 1000000000);
   } else if (arg >= 1000000 && arg % 1000000 == 0) {
-    return snprintf(str, len, "%uM", arg/1000000);
+    return snprintf(str, len, "%uM", arg / 1000000);
   } else if (arg >= 1000 && arg % 1000 == 0) {
-    return snprintf(str, len, "%uK", arg/1000);
+    return snprintf(str, len, "%uK", arg / 1000);
   } else {
     return snprintf(str, len, "%u", arg);
   }
@@ -86,7 +85,8 @@
   for (int i = 1; i < argc; i++) {
     regex_t re;
     if (regcomp(&re, argv[i], 0) != 0) {
-      fprintf(stderr, "couldn't compile \"%s\" as a regular expression!\n", argv[i]);
+      fprintf(stderr, "couldn't compile \"%s\" as a regular expression!\n",
+              argv[i]);
       exit(EXIT_FAILURE);
     }
     int match = regexec(&re, b->Name(), 0, NULL, 0);
@@ -111,9 +111,8 @@
   uint64_t StartTimeNs = NanoTime();
   b->RunFn(iterations);
   // Catch us if we fail to log anything.
-  if ((gBenchmarkTotalTimeNs == 0)
-   && (StartTimeNs != 0)
-   && (gBenchmarkStartTimeNs == 0)) {
+  if ((gBenchmarkTotalTimeNs == 0) && (StartTimeNs != 0) &&
+      (gBenchmarkStartTimeNs == 0)) {
     gBenchmarkTotalTimeNs = NanoTime() - StartTimeNs;
   }
 }
@@ -126,12 +125,13 @@
   s = NanoTime() - s;
   while (s < 2e9 && gBenchmarkTotalTimeNs < 1e9 && iterations < 1e9) {
     unsigned last = iterations;
-    if (gBenchmarkTotalTimeNs/iterations == 0) {
+    if (gBenchmarkTotalTimeNs / iterations == 0) {
       iterations = 1e9;
     } else {
-      iterations = 1e9 / (gBenchmarkTotalTimeNs/iterations);
+      iterations = 1e9 / (gBenchmarkTotalTimeNs / iterations);
     }
-    iterations = std::max(last + 1, std::min(iterations + iterations/2, 100*last));
+    iterations =
+        std::max(last + 1, std::min(iterations + iterations / 2, 100 * last));
     iterations = Round(iterations);
     s = NanoTime();
     RunRepeatedly(b, iterations);
@@ -141,30 +141,30 @@
   char throughput[100];
   throughput[0] = '\0';
   if (gBenchmarkTotalTimeNs > 0 && gBytesProcessed > 0) {
-    double mib_processed = static_cast<double>(gBytesProcessed)/1e6;
-    double seconds = static_cast<double>(gBenchmarkTotalTimeNs)/1e9;
-    snprintf(throughput, sizeof(throughput), " %8.2f MiB/s", mib_processed/seconds);
+    double mib_processed = static_cast<double>(gBytesProcessed) / 1e6;
+    double seconds = static_cast<double>(gBenchmarkTotalTimeNs) / 1e9;
+    snprintf(throughput, sizeof(throughput), " %8.2f MiB/s",
+             mib_processed / seconds);
   }
 
   char full_name[100];
   snprintf(full_name, sizeof(full_name), "%s%s%s", b->Name(),
-           b->ArgName() ? "/" : "",
-           b->ArgName() ? b->ArgName() : "");
+           b->ArgName() ? "/" : "", b->ArgName() ? b->ArgName() : "");
 
   uint64_t mean = gBenchmarkTotalTimeNs / iterations;
   uint64_t sdev = 0;
   if (gBenchmarkNum == iterations) {
     mean = gBenchmarkTotalTimeNs / gBenchmarkNum;
-    uint64_t nXvariance = gBenchmarkTotalTimeNsSquared * gBenchmarkNum
-                        - (gBenchmarkTotalTimeNs * gBenchmarkTotalTimeNs);
+    uint64_t nXvariance = gBenchmarkTotalTimeNsSquared * gBenchmarkNum -
+                          (gBenchmarkTotalTimeNs * gBenchmarkTotalTimeNs);
     sdev = (sqrt((double)nXvariance) / gBenchmarkNum / gBenchmarkNum) + 0.5;
   }
   if (mean > (10000 * sdev)) {
     printf("%-25s %10" PRIu64 " %10" PRIu64 "%s\n", full_name,
-            static_cast<uint64_t>(iterations), mean, throughput);
+           static_cast<uint64_t>(iterations), mean, throughput);
   } else {
-    printf("%-25s %10" PRIu64 " %10" PRIu64 "(\317\203%" PRIu64 ")%s\n", full_name,
-           static_cast<uint64_t>(iterations), mean, sdev, throughput);
+    printf("%-25s %10" PRIu64 " %10" PRIu64 "(\317\203%" PRIu64 ")%s\n",
+           full_name, static_cast<uint64_t>(iterations), mean, sdev, throughput);
   }
   fflush(stdout);
 }
diff --git a/liblog/tests/libc_test.cpp b/liblog/tests/libc_test.cpp
index 8cea7dc..329ba85 100644
--- a/liblog/tests/libc_test.cpp
+++ b/liblog/tests/libc_test.cpp
@@ -21,29 +21,29 @@
 
 TEST(libc, __pstore_append) {
 #ifdef __ANDROID__
-    FILE *fp;
-    ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "a")));
-    static const char message[] = "libc.__pstore_append\n";
-    ASSERT_EQ((size_t)1, fwrite(message, sizeof(message), 1, fp));
-    int fflushReturn = fflush(fp);
-    int fflushErrno = fflushReturn ? errno : 0;
-    ASSERT_EQ(0, fflushReturn);
-    ASSERT_EQ(0, fflushErrno);
-    int fcloseReturn = fclose(fp);
-    int fcloseErrno = fcloseReturn ? errno : 0;
-    ASSERT_EQ(0, fcloseReturn);
-    ASSERT_EQ(0, fcloseErrno);
-    if ((fcloseErrno == ENOMEM) || (fflushErrno == ENOMEM)) {
-        fprintf(stderr,
-                "Kernel does not have space allocated to pmsg pstore driver configured\n"
-               );
-    }
-    if (!fcloseReturn && !fcloseErrno && !fflushReturn && !fflushReturn) {
-        fprintf(stderr,
-                "Reboot, ensure string libc.__pstore_append is in /sys/fs/pstore/pmsg-ramoops-0\n"
-               );
-    }
+  FILE* fp;
+  ASSERT_TRUE(NULL != (fp = fopen("/dev/pmsg0", "a")));
+  static const char message[] = "libc.__pstore_append\n";
+  ASSERT_EQ((size_t)1, fwrite(message, sizeof(message), 1, fp));
+  int fflushReturn = fflush(fp);
+  int fflushErrno = fflushReturn ? errno : 0;
+  ASSERT_EQ(0, fflushReturn);
+  ASSERT_EQ(0, fflushErrno);
+  int fcloseReturn = fclose(fp);
+  int fcloseErrno = fcloseReturn ? errno : 0;
+  ASSERT_EQ(0, fcloseReturn);
+  ASSERT_EQ(0, fcloseErrno);
+  if ((fcloseErrno == ENOMEM) || (fflushErrno == ENOMEM)) {
+    fprintf(stderr,
+            "Kernel does not have space allocated to pmsg pstore driver "
+            "configured\n");
+  }
+  if (!fcloseReturn && !fcloseErrno && !fflushReturn && !fflushReturn) {
+    fprintf(stderr,
+            "Reboot, ensure string libc.__pstore_append is in "
+            "/sys/fs/pstore/pmsg-ramoops-0\n");
+  }
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
diff --git a/liblog/tests/liblog_benchmark.cpp b/liblog/tests/liblog_benchmark.cpp
index dac84eb..3f79552 100644
--- a/liblog/tests/liblog_benchmark.cpp
+++ b/liblog/tests/liblog_benchmark.cpp
@@ -27,7 +27,7 @@
 #include <android-base/file.h>
 #include <cutils/sockets.h>
 #include <log/event_tag_map.h>
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 #include <private/android_logger.h>
 
 #include "benchmark.h"
@@ -36,16 +36,15 @@
 // non-syscall libs. Since we are benchmarking, or using this in the emergency
 // signal to stuff a terminating code, we do NOT want to introduce
 // a syscall or usleep on EAGAIN retry.
-#define LOG_FAILURE_RETRY(exp) ({  \
-    typeof (exp) _rc;              \
-    do {                           \
-        _rc = (exp);               \
-    } while (((_rc == -1)          \
-           && ((errno == EINTR)    \
-            || (errno == EAGAIN))) \
-          || (_rc == -EINTR)       \
-          || (_rc == -EAGAIN));    \
-    _rc; })
+#define LOG_FAILURE_RETRY(exp)                                           \
+  ({                                                                     \
+    typeof(exp) _rc;                                                     \
+    do {                                                                 \
+      _rc = (exp);                                                       \
+    } while (((_rc == -1) && ((errno == EINTR) || (errno == EAGAIN))) || \
+             (_rc == -EINTR) || (_rc == -EAGAIN));                       \
+    _rc;                                                                 \
+  })
 
 /*
  *	Measure the fastest rate we can reliabley stuff print messages into
@@ -53,15 +52,14 @@
  * wakeup time (2ms?)
  */
 static void BM_log_maximum_retry(int iters) {
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        LOG_FAILURE_RETRY(
-            __android_log_print(ANDROID_LOG_INFO,
-                                "BM_log_maximum_retry", "%d", i));
-    }
+  for (int i = 0; i < iters; ++i) {
+    LOG_FAILURE_RETRY(
+        __android_log_print(ANDROID_LOG_INFO, "BM_log_maximum_retry", "%d", i));
+  }
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_log_maximum_retry);
 
@@ -71,28 +69,28 @@
  * time (2ms?)
  */
 static void BM_log_maximum(int iters) {
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        __android_log_print(ANDROID_LOG_INFO, "BM_log_maximum", "%d", i);
-    }
+  for (int i = 0; i < iters; ++i) {
+    __android_log_print(ANDROID_LOG_INFO, "BM_log_maximum", "%d", i);
+  }
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_log_maximum);
 
 static void set_log_null() {
-    android_set_log_frontend(LOGGER_NULL);
+  android_set_log_transport(LOGGER_NULL);
 }
 
 static void set_log_default() {
-    android_set_log_frontend(LOGGER_DEFAULT);
+  android_set_log_transport(LOGGER_DEFAULT);
 }
 
 static void BM_log_maximum_null(int iters) {
-    set_log_null();
-    BM_log_maximum(iters);
-    set_log_default();
+  set_log_null();
+  BM_log_maximum(iters);
+  set_log_default();
 }
 BENCHMARK(BM_log_maximum_null);
 
@@ -106,10 +104,10 @@
  * clock_gettime to be zero-syscall.
  */
 static void BM_clock_overhead(int iters) {
-    for (int i = 0; i < iters; ++i) {
-       StartBenchmarkTiming();
-       StopBenchmarkTiming();
-    }
+  for (int i = 0; i < iters; ++i) {
+    StartBenchmarkTiming();
+    StopBenchmarkTiming();
+  }
 }
 BENCHMARK(BM_clock_overhead);
 
@@ -117,75 +115,74 @@
  * Measure the time it takes to submit the android logging data to pstore
  */
 static void BM_pmsg_short(int iters) {
+  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+  if (pstore_fd < 0) {
+    return;
+  }
 
-    int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
-    if (pstore_fd < 0) {
-        return;
-    }
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsg_header;
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsg_header;
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  struct timespec ts;
+  clock_gettime(android_log_clockid(), &ts);
 
-    struct timespec ts;
-    clock_gettime(android_log_clockid(), &ts);
+  android_pmsg_log_header_t pmsg_header;
+  pmsg_header.magic = LOGGER_MAGIC;
+  pmsg_header.len =
+      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
+  pmsg_header.uid = getuid();
+  pmsg_header.pid = getpid();
 
-    android_pmsg_log_header_t pmsg_header;
-    pmsg_header.magic = LOGGER_MAGIC;
-    pmsg_header.len = sizeof(android_pmsg_log_header_t)
-                    + sizeof(android_log_header_t);
-    pmsg_header.uid = getuid();
-    pmsg_header.pid = getpid();
+  android_log_header_t header;
+  header.tid = gettid();
+  header.realtime.tv_sec = ts.tv_sec;
+  header.realtime.tv_nsec = ts.tv_nsec;
 
-    android_log_header_t header;
-    header.tid = gettid();
-    header.realtime.tv_sec = ts.tv_sec;
-    header.realtime.tv_nsec = ts.tv_nsec;
+  static const unsigned nr = 1;
+  static const unsigned header_length = 2;
+  struct iovec newVec[nr + header_length];
 
-    static const unsigned nr = 1;
-    static const unsigned header_length = 2;
-    struct iovec newVec[nr + header_length];
+  newVec[0].iov_base = (unsigned char*)&pmsg_header;
+  newVec[0].iov_len = sizeof(pmsg_header);
+  newVec[1].iov_base = (unsigned char*)&header;
+  newVec[1].iov_len = sizeof(header);
 
-    newVec[0].iov_base   = (unsigned char *) &pmsg_header;
-    newVec[0].iov_len    = sizeof(pmsg_header);
-    newVec[1].iov_base   = (unsigned char *) &header;
-    newVec[1].iov_len    = sizeof(header);
+  android_log_event_int_t buffer;
 
-    android_log_event_int_t buffer;
+  header.id = LOG_ID_EVENTS;
+  buffer.header.tag = 0;
+  buffer.payload.type = EVENT_TYPE_INT;
+  uint32_t snapshot = 0;
+  buffer.payload.data = htole32(snapshot);
 
-    header.id = LOG_ID_EVENTS;
-    buffer.header.tag = 0;
-    buffer.payload.type = EVENT_TYPE_INT;
-    uint32_t snapshot = 0;
+  newVec[2].iov_base = &buffer;
+  newVec[2].iov_len = sizeof(buffer);
+
+  StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    ++snapshot;
     buffer.payload.data = htole32(snapshot);
-
-    newVec[2].iov_base = &buffer;
-    newVec[2].iov_len  = sizeof(buffer);
-
-    StartBenchmarkTiming();
-    for (int i = 0; i < iters; ++i) {
-        ++snapshot;
-        buffer.payload.data = htole32(snapshot);
-        writev(pstore_fd, newVec, nr);
-    }
-    StopBenchmarkTiming();
-    close(pstore_fd);
+    writev(pstore_fd, newVec, nr);
+  }
+  StopBenchmarkTiming();
+  close(pstore_fd);
 }
 BENCHMARK(BM_pmsg_short);
 
@@ -194,74 +191,72 @@
  * best case aligned single block.
  */
 static void BM_pmsg_short_aligned(int iters) {
+  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+  if (pstore_fd < 0) {
+    return;
+  }
 
-    int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
-    if (pstore_fd < 0) {
-        return;
-    }
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsg_header;
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsg_header;
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  struct timespec ts;
+  clock_gettime(android_log_clockid(), &ts);
 
-    struct timespec ts;
-    clock_gettime(android_log_clockid(), &ts);
+  struct packet {
+    android_pmsg_log_header_t pmsg_header;
+    android_log_header_t header;
+    android_log_event_int_t payload;
+  };
+  alignas(8) char buf[sizeof(struct packet) + 8];
+  memset(buf, 0, sizeof(buf));
+  struct packet* buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
+  if (((uintptr_t)&buffer->pmsg_header) & 7) {
+    fprintf(stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
+  }
 
-    struct packet {
-        android_pmsg_log_header_t pmsg_header;
-        android_log_header_t header;
-        android_log_event_int_t payload;
-    };
-    alignas(8) char buf[sizeof(struct packet) + 8];
-    memset(buf, 0, sizeof(buf));
-    struct packet *buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
-    if (((uintptr_t)&buffer->pmsg_header) & 7) {
-        fprintf (stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
-    }
+  buffer->pmsg_header.magic = LOGGER_MAGIC;
+  buffer->pmsg_header.len =
+      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
+  buffer->pmsg_header.uid = getuid();
+  buffer->pmsg_header.pid = getpid();
 
-    buffer->pmsg_header.magic = LOGGER_MAGIC;
-    buffer->pmsg_header.len = sizeof(android_pmsg_log_header_t)
-                            + sizeof(android_log_header_t);
-    buffer->pmsg_header.uid = getuid();
-    buffer->pmsg_header.pid = getpid();
+  buffer->header.tid = gettid();
+  buffer->header.realtime.tv_sec = ts.tv_sec;
+  buffer->header.realtime.tv_nsec = ts.tv_nsec;
 
-    buffer->header.tid = gettid();
-    buffer->header.realtime.tv_sec = ts.tv_sec;
-    buffer->header.realtime.tv_nsec = ts.tv_nsec;
+  buffer->header.id = LOG_ID_EVENTS;
+  buffer->payload.header.tag = 0;
+  buffer->payload.payload.type = EVENT_TYPE_INT;
+  uint32_t snapshot = 0;
+  buffer->payload.payload.data = htole32(snapshot);
 
-    buffer->header.id = LOG_ID_EVENTS;
-    buffer->payload.header.tag = 0;
-    buffer->payload.payload.type = EVENT_TYPE_INT;
-    uint32_t snapshot = 0;
+  StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    ++snapshot;
     buffer->payload.payload.data = htole32(snapshot);
-
-    StartBenchmarkTiming();
-    for (int i = 0; i < iters; ++i) {
-        ++snapshot;
-        buffer->payload.payload.data = htole32(snapshot);
-        write(pstore_fd, &buffer->pmsg_header,
-            sizeof(android_pmsg_log_header_t) +
-            sizeof(android_log_header_t) +
-            sizeof(android_log_event_int_t));
-    }
-    StopBenchmarkTiming();
-    close(pstore_fd);
+    write(pstore_fd, &buffer->pmsg_header,
+          sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t) +
+              sizeof(android_log_event_int_t));
+  }
+  StopBenchmarkTiming();
+  close(pstore_fd);
 }
 BENCHMARK(BM_pmsg_short_aligned);
 
@@ -270,74 +265,72 @@
  * best case aligned single block.
  */
 static void BM_pmsg_short_unaligned1(int iters) {
+  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+  if (pstore_fd < 0) {
+    return;
+  }
 
-    int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
-    if (pstore_fd < 0) {
-        return;
-    }
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsg_header;
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsg_header;
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  struct timespec ts;
+  clock_gettime(android_log_clockid(), &ts);
 
-    struct timespec ts;
-    clock_gettime(android_log_clockid(), &ts);
+  struct packet {
+    android_pmsg_log_header_t pmsg_header;
+    android_log_header_t header;
+    android_log_event_int_t payload;
+  };
+  alignas(8) char buf[sizeof(struct packet) + 8];
+  memset(buf, 0, sizeof(buf));
+  struct packet* buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
+  if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
+    fprintf(stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
+  }
 
-    struct packet {
-        android_pmsg_log_header_t pmsg_header;
-        android_log_header_t header;
-        android_log_event_int_t payload;
-    };
-    alignas(8) char buf[sizeof(struct packet) + 8];
-    memset(buf, 0, sizeof(buf));
-    struct packet *buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
-    if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
-        fprintf (stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
-    }
+  buffer->pmsg_header.magic = LOGGER_MAGIC;
+  buffer->pmsg_header.len =
+      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
+  buffer->pmsg_header.uid = getuid();
+  buffer->pmsg_header.pid = getpid();
 
-    buffer->pmsg_header.magic = LOGGER_MAGIC;
-    buffer->pmsg_header.len = sizeof(android_pmsg_log_header_t)
-                            + sizeof(android_log_header_t);
-    buffer->pmsg_header.uid = getuid();
-    buffer->pmsg_header.pid = getpid();
+  buffer->header.tid = gettid();
+  buffer->header.realtime.tv_sec = ts.tv_sec;
+  buffer->header.realtime.tv_nsec = ts.tv_nsec;
 
-    buffer->header.tid = gettid();
-    buffer->header.realtime.tv_sec = ts.tv_sec;
-    buffer->header.realtime.tv_nsec = ts.tv_nsec;
+  buffer->header.id = LOG_ID_EVENTS;
+  buffer->payload.header.tag = 0;
+  buffer->payload.payload.type = EVENT_TYPE_INT;
+  uint32_t snapshot = 0;
+  buffer->payload.payload.data = htole32(snapshot);
 
-    buffer->header.id = LOG_ID_EVENTS;
-    buffer->payload.header.tag = 0;
-    buffer->payload.payload.type = EVENT_TYPE_INT;
-    uint32_t snapshot = 0;
+  StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    ++snapshot;
     buffer->payload.payload.data = htole32(snapshot);
-
-    StartBenchmarkTiming();
-    for (int i = 0; i < iters; ++i) {
-        ++snapshot;
-        buffer->payload.payload.data = htole32(snapshot);
-        write(pstore_fd, &buffer->pmsg_header,
-            sizeof(android_pmsg_log_header_t) +
-            sizeof(android_log_header_t) +
-            sizeof(android_log_event_int_t));
-    }
-    StopBenchmarkTiming();
-    close(pstore_fd);
+    write(pstore_fd, &buffer->pmsg_header,
+          sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t) +
+              sizeof(android_log_event_int_t));
+  }
+  StopBenchmarkTiming();
+  close(pstore_fd);
 }
 BENCHMARK(BM_pmsg_short_unaligned1);
 
@@ -346,71 +339,70 @@
  * best case aligned single block.
  */
 static void BM_pmsg_long_aligned(int iters) {
+  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+  if (pstore_fd < 0) {
+    return;
+  }
 
-    int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
-    if (pstore_fd < 0) {
-        return;
-    }
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsg_header;
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsg_header;
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  struct timespec ts;
+  clock_gettime(android_log_clockid(), &ts);
 
-    struct timespec ts;
-    clock_gettime(android_log_clockid(), &ts);
+  struct packet {
+    android_pmsg_log_header_t pmsg_header;
+    android_log_header_t header;
+    android_log_event_int_t payload;
+  };
+  alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
+  memset(buf, 0, sizeof(buf));
+  struct packet* buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
+  if (((uintptr_t)&buffer->pmsg_header) & 7) {
+    fprintf(stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
+  }
 
-    struct packet {
-        android_pmsg_log_header_t pmsg_header;
-        android_log_header_t header;
-        android_log_event_int_t payload;
-    };
-    alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
-    memset(buf, 0, sizeof(buf));
-    struct packet *buffer = (struct packet*)(((uintptr_t)buf + 7) & ~7);
-    if (((uintptr_t)&buffer->pmsg_header) & 7) {
-        fprintf (stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
-    }
+  buffer->pmsg_header.magic = LOGGER_MAGIC;
+  buffer->pmsg_header.len =
+      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
+  buffer->pmsg_header.uid = getuid();
+  buffer->pmsg_header.pid = getpid();
 
-    buffer->pmsg_header.magic = LOGGER_MAGIC;
-    buffer->pmsg_header.len = sizeof(android_pmsg_log_header_t)
-                            + sizeof(android_log_header_t);
-    buffer->pmsg_header.uid = getuid();
-    buffer->pmsg_header.pid = getpid();
+  buffer->header.tid = gettid();
+  buffer->header.realtime.tv_sec = ts.tv_sec;
+  buffer->header.realtime.tv_nsec = ts.tv_nsec;
 
-    buffer->header.tid = gettid();
-    buffer->header.realtime.tv_sec = ts.tv_sec;
-    buffer->header.realtime.tv_nsec = ts.tv_nsec;
+  buffer->header.id = LOG_ID_EVENTS;
+  buffer->payload.header.tag = 0;
+  buffer->payload.payload.type = EVENT_TYPE_INT;
+  uint32_t snapshot = 0;
+  buffer->payload.payload.data = htole32(snapshot);
 
-    buffer->header.id = LOG_ID_EVENTS;
-    buffer->payload.header.tag = 0;
-    buffer->payload.payload.type = EVENT_TYPE_INT;
-    uint32_t snapshot = 0;
+  StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    ++snapshot;
     buffer->payload.payload.data = htole32(snapshot);
-
-    StartBenchmarkTiming();
-    for (int i = 0; i < iters; ++i) {
-        ++snapshot;
-        buffer->payload.payload.data = htole32(snapshot);
-        write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
-    }
-    StopBenchmarkTiming();
-    close(pstore_fd);
+    write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
+  }
+  StopBenchmarkTiming();
+  close(pstore_fd);
 }
 BENCHMARK(BM_pmsg_long_aligned);
 
@@ -419,71 +411,70 @@
  * best case aligned single block.
  */
 static void BM_pmsg_long_unaligned1(int iters) {
+  int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
+  if (pstore_fd < 0) {
+    return;
+  }
 
-    int pstore_fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY));
-    if (pstore_fd < 0) {
-        return;
-    }
+  /*
+   *  struct {
+   *      // what we provide to pstore
+   *      android_pmsg_log_header_t pmsg_header;
+   *      // what we provide to socket
+   *      android_log_header_t header;
+   *      // caller provides
+   *      union {
+   *          struct {
+   *              char     prio;
+   *              char     payload[];
+   *          } string;
+   *          struct {
+   *              uint32_t tag
+   *              char     payload[];
+   *          } binary;
+   *      };
+   *  };
+   */
 
-    /*
-     *  struct {
-     *      // what we provide to pstore
-     *      android_pmsg_log_header_t pmsg_header;
-     *      // what we provide to socket
-     *      android_log_header_t header;
-     *      // caller provides
-     *      union {
-     *          struct {
-     *              char     prio;
-     *              char     payload[];
-     *          } string;
-     *          struct {
-     *              uint32_t tag
-     *              char     payload[];
-     *          } binary;
-     *      };
-     *  };
-     */
+  struct timespec ts;
+  clock_gettime(android_log_clockid(), &ts);
 
-    struct timespec ts;
-    clock_gettime(android_log_clockid(), &ts);
+  struct packet {
+    android_pmsg_log_header_t pmsg_header;
+    android_log_header_t header;
+    android_log_event_int_t payload;
+  };
+  alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
+  memset(buf, 0, sizeof(buf));
+  struct packet* buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
+  if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
+    fprintf(stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
+  }
 
-    struct packet {
-        android_pmsg_log_header_t pmsg_header;
-        android_log_header_t header;
-        android_log_event_int_t payload;
-    };
-    alignas(8) char buf[sizeof(struct packet) + 8 + LOGGER_ENTRY_MAX_PAYLOAD];
-    memset(buf, 0, sizeof(buf));
-    struct packet *buffer = (struct packet*)((((uintptr_t)buf + 7) & ~7) + 1);
-    if ((((uintptr_t)&buffer->pmsg_header) & 7) != 1) {
-        fprintf (stderr, "&buffer=0x%p iters=%d\n", &buffer->pmsg_header, iters);
-    }
+  buffer->pmsg_header.magic = LOGGER_MAGIC;
+  buffer->pmsg_header.len =
+      sizeof(android_pmsg_log_header_t) + sizeof(android_log_header_t);
+  buffer->pmsg_header.uid = getuid();
+  buffer->pmsg_header.pid = getpid();
 
-    buffer->pmsg_header.magic = LOGGER_MAGIC;
-    buffer->pmsg_header.len = sizeof(android_pmsg_log_header_t)
-                            + sizeof(android_log_header_t);
-    buffer->pmsg_header.uid = getuid();
-    buffer->pmsg_header.pid = getpid();
+  buffer->header.tid = gettid();
+  buffer->header.realtime.tv_sec = ts.tv_sec;
+  buffer->header.realtime.tv_nsec = ts.tv_nsec;
 
-    buffer->header.tid = gettid();
-    buffer->header.realtime.tv_sec = ts.tv_sec;
-    buffer->header.realtime.tv_nsec = ts.tv_nsec;
+  buffer->header.id = LOG_ID_EVENTS;
+  buffer->payload.header.tag = 0;
+  buffer->payload.payload.type = EVENT_TYPE_INT;
+  uint32_t snapshot = 0;
+  buffer->payload.payload.data = htole32(snapshot);
 
-    buffer->header.id = LOG_ID_EVENTS;
-    buffer->payload.header.tag = 0;
-    buffer->payload.payload.type = EVENT_TYPE_INT;
-    uint32_t snapshot = 0;
+  StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    ++snapshot;
     buffer->payload.payload.data = htole32(snapshot);
-
-    StartBenchmarkTiming();
-    for (int i = 0; i < iters; ++i) {
-        ++snapshot;
-        buffer->payload.payload.data = htole32(snapshot);
-        write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
-    }
-    StopBenchmarkTiming();
-    close(pstore_fd);
+    write(pstore_fd, &buffer->pmsg_header, LOGGER_ENTRY_MAX_PAYLOAD);
+  }
+  StopBenchmarkTiming();
+  close(pstore_fd);
 }
 BENCHMARK(BM_pmsg_long_unaligned1);
 
@@ -494,26 +485,26 @@
  * time if zero-syscall time.
  */
 /* helper function */
-static void test_print(const char *fmt, ...) {
-    va_list ap;
-    char buf[1024];
+static void test_print(const char* fmt, ...) {
+  va_list ap;
+  char buf[1024];
 
-    va_start(ap, fmt);
-    vsnprintf(buf, sizeof(buf), fmt, ap);
-    va_end(ap);
+  va_start(ap, fmt);
+  vsnprintf(buf, sizeof(buf), fmt, ap);
+  va_end(ap);
 }
 
-#define logd_yield() sched_yield() // allow logd to catch up
-#define logd_sleep() usleep(50)    // really allow logd to catch up
+#define logd_yield() sched_yield()  // allow logd to catch up
+#define logd_sleep() usleep(50)     // really allow logd to catch up
 
 /* performance test */
 static void BM_sprintf_overhead(int iters) {
-    for (int i = 0; i < iters; ++i) {
-       StartBenchmarkTiming();
-       test_print("BM_sprintf_overhead:%d", i);
-       StopBenchmarkTiming();
-       logd_yield();
-    }
+  for (int i = 0; i < iters; ++i) {
+    StartBenchmarkTiming();
+    test_print("BM_sprintf_overhead:%d", i);
+    StopBenchmarkTiming();
+    logd_yield();
+  }
 }
 BENCHMARK(BM_sprintf_overhead);
 
@@ -524,12 +515,12 @@
  * syscall periods (40us) plus time to run *printf
  */
 static void BM_log_print_overhead(int iters) {
-    for (int i = 0; i < iters; ++i) {
-       StartBenchmarkTiming();
-       __android_log_print(ANDROID_LOG_INFO, "BM_log_overhead", "%d", i);
-       StopBenchmarkTiming();
-       logd_yield();
-    }
+  for (int i = 0; i < iters; ++i) {
+    StartBenchmarkTiming();
+    __android_log_print(ANDROID_LOG_INFO, "BM_log_overhead", "%d", i);
+    StopBenchmarkTiming();
+    logd_yield();
+  }
 }
 BENCHMARK(BM_log_print_overhead);
 
@@ -539,19 +530,19 @@
  * under light load. Expect this to be a dozen or so syscall periods (40us)
  */
 static void BM_log_event_overhead(int iters) {
-    for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
-       StartBenchmarkTiming();
-       __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
-       StopBenchmarkTiming();
-       logd_yield();
-    }
+  for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
+    StartBenchmarkTiming();
+    __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
+    StopBenchmarkTiming();
+    logd_yield();
+  }
 }
 BENCHMARK(BM_log_event_overhead);
 
 static void BM_log_event_overhead_null(int iters) {
-    set_log_null();
-    BM_log_event_overhead(iters);
-    set_log_default();
+  set_log_null();
+  BM_log_event_overhead(iters);
+  set_log_default();
 }
 BENCHMARK(BM_log_event_overhead_null);
 
@@ -561,40 +552,38 @@
  * under very-light load (<1% CPU utilization).
  */
 static void BM_log_light_overhead(int iters) {
-    for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
-       StartBenchmarkTiming();
-       __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
-       StopBenchmarkTiming();
-       usleep(10000);
-    }
+  for (unsigned long long i = 0; i < (unsigned)iters; ++i) {
+    StartBenchmarkTiming();
+    __android_log_btwrite(0, EVENT_TYPE_LONG, &i, sizeof(i));
+    StopBenchmarkTiming();
+    usleep(10000);
+  }
 }
 BENCHMARK(BM_log_light_overhead);
 
 static void BM_log_light_overhead_null(int iters) {
-    set_log_null();
-    BM_log_light_overhead(iters);
-    set_log_default();
+  set_log_null();
+  BM_log_light_overhead(iters);
+  set_log_default();
 }
 BENCHMARK(BM_log_light_overhead_null);
 
-static void caught_latency(int /*signum*/)
-{
-    unsigned long long v = 0xDEADBEEFA55A5AA5ULL;
+static void caught_latency(int /*signum*/) {
+  unsigned long long v = 0xDEADBEEFA55A5AA5ULL;
 
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
+  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
 }
 
-static unsigned long long caught_convert(char *cp)
-{
-    unsigned long long l = cp[0] & 0xFF;
-    l |= (unsigned long long) (cp[1] & 0xFF) << 8;
-    l |= (unsigned long long) (cp[2] & 0xFF) << 16;
-    l |= (unsigned long long) (cp[3] & 0xFF) << 24;
-    l |= (unsigned long long) (cp[4] & 0xFF) << 32;
-    l |= (unsigned long long) (cp[5] & 0xFF) << 40;
-    l |= (unsigned long long) (cp[6] & 0xFF) << 48;
-    l |= (unsigned long long) (cp[7] & 0xFF) << 56;
-    return l;
+static unsigned long long caught_convert(char* cp) {
+  unsigned long long l = cp[0] & 0xFF;
+  l |= (unsigned long long)(cp[1] & 0xFF) << 8;
+  l |= (unsigned long long)(cp[2] & 0xFF) << 16;
+  l |= (unsigned long long)(cp[3] & 0xFF) << 24;
+  l |= (unsigned long long)(cp[4] & 0xFF) << 32;
+  l |= (unsigned long long)(cp[5] & 0xFF) << 40;
+  l |= (unsigned long long)(cp[6] & 0xFF) << 48;
+  l |= (unsigned long long)(cp[7] & 0xFF) << 56;
+  return l;
 }
 
 static const int alarm_time = 3;
@@ -605,77 +594,75 @@
  * 4 syscalls (3us).
  */
 static void BM_log_latency(int iters) {
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    struct logger_list * logger_list = android_logger_list_open(LOG_ID_EVENTS,
-        ANDROID_LOG_RDONLY, 0, pid);
+  struct logger_list* logger_list =
+      android_logger_list_open(LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 0, pid);
 
-    if (!logger_list) {
-        fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
-        exit(EXIT_FAILURE);
-    }
+  if (!logger_list) {
+    fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
+    exit(EXIT_FAILURE);
+  }
 
-    signal(SIGALRM, caught_latency);
-    alarm(alarm_time);
+  signal(SIGALRM, caught_latency);
+  alarm(alarm_time);
 
-    for (int j = 0, i = 0; i < iters && j < 10*iters; ++i, ++j) {
-        log_time ts;
-        LOG_FAILURE_RETRY((
-            ts = log_time(CLOCK_REALTIME),
-            android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts))));
+  for (int j = 0, i = 0; i < iters && j < 10 * iters; ++i, ++j) {
+    log_time ts;
+    LOG_FAILURE_RETRY((ts = log_time(CLOCK_REALTIME),
+                       android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts))));
 
-        for (;;) {
-            log_msg log_msg;
-            int ret = android_logger_list_read(logger_list, &log_msg);
-            alarm(alarm_time);
+    for (;;) {
+      log_msg log_msg;
+      int ret = android_logger_list_read(logger_list, &log_msg);
+      alarm(alarm_time);
 
-            if (ret <= 0) {
-                iters = i;
-                break;
-            }
-            if ((log_msg.entry.len != (4 + 1 + 8))
-             || (log_msg.id() != LOG_ID_EVENTS)) {
-                continue;
-            }
+      if (ret <= 0) {
+        iters = i;
+        break;
+      }
+      if ((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 || (eventData[4] != EVENT_TYPE_LONG)) {
-                continue;
-            }
-            log_time tx(eventData + 4 + 1);
-            if (ts != tx) {
-                if (0xDEADBEEFA55A5AA5ULL == caught_convert(eventData + 4 + 1)) {
-                    iters = i;
-                    break;
-                }
-                continue;
-            }
-
-            uint64_t start = ts.nsec();
-            uint64_t end = log_msg.nsec();
-            if (end >= start) {
-                StartBenchmarkTiming(start);
-                StopBenchmarkTiming(end);
-            } else {
-                --i;
-            }
-            break;
+      if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) {
+        continue;
+      }
+      log_time tx(eventData + 4 + 1);
+      if (ts != tx) {
+        if (0xDEADBEEFA55A5AA5ULL == caught_convert(eventData + 4 + 1)) {
+          iters = i;
+          break;
         }
+        continue;
+      }
+
+      uint64_t start = ts.nsec();
+      uint64_t end = log_msg.nsec();
+      if (end >= start) {
+        StartBenchmarkTiming(start);
+        StopBenchmarkTiming(end);
+      } else {
+        --i;
+      }
+      break;
     }
+  }
 
-    signal(SIGALRM, SIG_DFL);
-    alarm(0);
+  signal(SIGALRM, SIG_DFL);
+  alarm(0);
 
-    android_logger_list_free(logger_list);
+  android_logger_list_free(logger_list);
 }
 BENCHMARK(BM_log_latency);
 
-static void caught_delay(int /*signum*/)
-{
-    unsigned long long v = 0xDEADBEEFA55A5AA6ULL;
+static void caught_delay(int /*signum*/) {
+  unsigned long long v = 0xDEADBEEFA55A5AA6ULL;
 
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
+  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
 }
 
 /*
@@ -683,65 +670,64 @@
  * the logs. Expect this to be less than double the process wakeup time (2ms).
  */
 static void BM_log_delay(int iters) {
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    struct logger_list * logger_list = android_logger_list_open(LOG_ID_EVENTS,
-        ANDROID_LOG_RDONLY, 0, pid);
+  struct logger_list* logger_list =
+      android_logger_list_open(LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 0, pid);
 
-    if (!logger_list) {
-        fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
-        exit(EXIT_FAILURE);
-    }
+  if (!logger_list) {
+    fprintf(stderr, "Unable to open events log: %s\n", strerror(errno));
+    exit(EXIT_FAILURE);
+  }
 
-    signal(SIGALRM, caught_delay);
-    alarm(alarm_time);
+  signal(SIGALRM, caught_delay);
+  alarm(alarm_time);
 
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        log_time ts(CLOCK_REALTIME);
+  for (int i = 0; i < iters; ++i) {
+    log_time ts(CLOCK_REALTIME);
 
-        LOG_FAILURE_RETRY(
-            android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+    LOG_FAILURE_RETRY(android_btWriteLog(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
 
-        for (;;) {
-            log_msg log_msg;
-            int ret = android_logger_list_read(logger_list, &log_msg);
-            alarm(alarm_time);
+    for (;;) {
+      log_msg log_msg;
+      int ret = android_logger_list_read(logger_list, &log_msg);
+      alarm(alarm_time);
 
-            if (ret <= 0) {
-                iters = i;
-                break;
-            }
-            if ((log_msg.entry.len != (4 + 1 + 8))
-             || (log_msg.id() != LOG_ID_EVENTS)) {
-                continue;
-            }
+      if (ret <= 0) {
+        iters = i;
+        break;
+      }
+      if ((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 || (eventData[4] != EVENT_TYPE_LONG)) {
-                continue;
-            }
-            log_time tx(eventData + 4 + 1);
-            if (ts != tx) {
-                if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) {
-                    iters = i;
-                    break;
-                }
-                continue;
-            }
-
-            break;
+      if (!eventData || (eventData[4] != EVENT_TYPE_LONG)) {
+        continue;
+      }
+      log_time tx(eventData + 4 + 1);
+      if (ts != tx) {
+        if (0xDEADBEEFA55A5AA6ULL == caught_convert(eventData + 4 + 1)) {
+          iters = i;
+          break;
         }
+        continue;
+      }
+
+      break;
     }
+  }
 
-    signal(SIGALRM, SIG_DFL);
-    alarm(0);
+  signal(SIGALRM, SIG_DFL);
+  alarm(0);
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 
-    android_logger_list_free(logger_list);
+  android_logger_list_free(logger_list);
 }
 BENCHMARK(BM_log_delay);
 
@@ -749,17 +735,16 @@
  *	Measure the time it takes for __android_log_is_loggable.
  */
 static void BM_is_loggable(int iters) {
-    static const char logd[] = "logd";
+  static const char logd[] = "logd";
 
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        __android_log_is_loggable_len(ANDROID_LOG_WARN,
-                                      logd, strlen(logd),
-                                      ANDROID_LOG_VERBOSE);
-    }
+  for (int i = 0; i < iters; ++i) {
+    __android_log_is_loggable_len(ANDROID_LOG_WARN, logd, strlen(logd),
+                                  ANDROID_LOG_VERBOSE);
+  }
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_is_loggable);
 
@@ -767,13 +752,13 @@
  *	Measure the time it takes for android_log_clockid.
  */
 static void BM_clockid(int iters) {
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        android_log_clockid();
-    }
+  for (int i = 0; i < iters; ++i) {
+    android_log_clockid();
+  }
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_clockid);
 
@@ -781,13 +766,13 @@
  *	Measure the time it takes for __android_log_security.
  */
 static void BM_security(int iters) {
-    StartBenchmarkTiming();
+  StartBenchmarkTiming();
 
-    for (int i = 0; i < iters; ++i) {
-        __android_log_security();
-    }
+  for (int i = 0; i < iters; ++i) {
+    __android_log_security();
+  }
 
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_security);
 
@@ -796,41 +781,40 @@
 static EventTagMap* map;
 
 static bool prechargeEventMap() {
-    if (map) return true;
+  if (map) return true;
 
-    fprintf(stderr, "Precharge: start\n");
+  fprintf(stderr, "Precharge: start\n");
 
-    map = android_openEventTagMap(NULL);
-    for (uint32_t tag = 1; tag < USHRT_MAX; ++tag) {
-        size_t len;
-        if (android_lookupEventTag_len(map, &len, tag) == NULL) continue;
-        set.insert(tag);
-    }
+  map = android_openEventTagMap(NULL);
+  for (uint32_t tag = 1; tag < USHRT_MAX; ++tag) {
+    size_t len;
+    if (android_lookupEventTag_len(map, &len, tag) == NULL) continue;
+    set.insert(tag);
+  }
 
-    fprintf(stderr, "Precharge: stop %zu\n", set.size());
+  fprintf(stderr, "Precharge: stop %zu\n", set.size());
 
-    return true;
+  return true;
 }
 
 /*
  *	Measure the time it takes for android_lookupEventTag_len
  */
 static void BM_lookupEventTag(int iters) {
+  prechargeEventMap();
 
-    prechargeEventMap();
+  std::unordered_set<uint32_t>::const_iterator it = set.begin();
 
-    std::unordered_set<uint32_t>::const_iterator it = set.begin();
+  StartBenchmarkTiming();
 
-    StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    size_t len;
+    android_lookupEventTag_len(map, &len, (*it));
+    ++it;
+    if (it == set.end()) it = set.begin();
+  }
 
-    for (int i = 0; i < iters; ++i) {
-        size_t len;
-        android_lookupEventTag_len(map, &len, (*it));
-        ++it;
-        if (it == set.end()) it = set.begin();
-    }
-
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_lookupEventTag);
 
@@ -840,25 +824,24 @@
 static uint32_t notTag = 1;
 
 static void BM_lookupEventTag_NOT(int iters) {
+  prechargeEventMap();
 
-    prechargeEventMap();
-
-    while (set.find(notTag) != set.end()) {
-        ++notTag;
-        if (notTag >= USHRT_MAX) notTag = 1;
-    }
-
-    StartBenchmarkTiming();
-
-    for (int i = 0; i < iters; ++i) {
-        size_t len;
-        android_lookupEventTag_len(map, &len, notTag);
-    }
-
-    StopBenchmarkTiming();
-
+  while (set.find(notTag) != set.end()) {
     ++notTag;
     if (notTag >= USHRT_MAX) notTag = 1;
+  }
+
+  StartBenchmarkTiming();
+
+  for (int i = 0; i < iters; ++i) {
+    size_t len;
+    android_lookupEventTag_len(map, &len, notTag);
+  }
+
+  StopBenchmarkTiming();
+
+  ++notTag;
+  if (notTag >= USHRT_MAX) notTag = 1;
 }
 BENCHMARK(BM_lookupEventTag_NOT);
 
@@ -866,21 +849,20 @@
  *	Measure the time it takes for android_lookupEventFormat_len
  */
 static void BM_lookupEventFormat(int iters) {
+  prechargeEventMap();
 
-    prechargeEventMap();
+  std::unordered_set<uint32_t>::const_iterator it = set.begin();
 
-    std::unordered_set<uint32_t>::const_iterator it = set.begin();
+  StartBenchmarkTiming();
 
-    StartBenchmarkTiming();
+  for (int i = 0; i < iters; ++i) {
+    size_t len;
+    android_lookupEventFormat_len(map, &len, (*it));
+    ++it;
+    if (it == set.end()) it = set.begin();
+  }
 
-    for (int i = 0; i < iters; ++i) {
-        size_t len;
-        android_lookupEventFormat_len(map, &len, (*it));
-        ++it;
-        if (it == set.end()) it = set.begin();
-    }
-
-    StopBenchmarkTiming();
+  StopBenchmarkTiming();
 }
 BENCHMARK(BM_lookupEventFormat);
 
@@ -888,137 +870,135 @@
  *	Measure the time it takes for android_lookupEventTagNum plus above
  */
 static void BM_lookupEventTagNum(int iters) {
+  prechargeEventMap();
 
-    prechargeEventMap();
+  std::unordered_set<uint32_t>::const_iterator it = set.begin();
 
-    std::unordered_set<uint32_t>::const_iterator it = set.begin();
-
-    for (int i = 0; i < iters; ++i) {
-        size_t len;
-        const char* name = android_lookupEventTag_len(map, &len, (*it));
-        std::string Name(name, len);
-        const char* format = android_lookupEventFormat_len(map, &len, (*it));
-        std::string Format(format, len);
-        StartBenchmarkTiming();
-        android_lookupEventTagNum(map, Name.c_str(), Format.c_str(),
-                                  ANDROID_LOG_UNKNOWN);
-        StopBenchmarkTiming();
-        ++it;
-        if (it == set.end()) it = set.begin();
-    }
-
+  for (int i = 0; i < iters; ++i) {
+    size_t len;
+    const char* name = android_lookupEventTag_len(map, &len, (*it));
+    std::string Name(name, len);
+    const char* format = android_lookupEventFormat_len(map, &len, (*it));
+    std::string Format(format, len);
+    StartBenchmarkTiming();
+    android_lookupEventTagNum(map, Name.c_str(), Format.c_str(),
+                              ANDROID_LOG_UNKNOWN);
+    StopBenchmarkTiming();
+    ++it;
+    if (it == set.end()) it = set.begin();
+  }
 }
 BENCHMARK(BM_lookupEventTagNum);
 
 // Must be functionally identical to liblog internal __send_log_msg.
-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) return;
-    size_t writeLen = strlen(buf) + 1;
+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) return;
+  size_t writeLen = strlen(buf) + 1;
 
-    ssize_t ret = TEMP_FAILURE_RETRY(write(sock, buf, writeLen));
-    if (ret <= 0) {
-        close(sock);
-        return;
-    }
-    while ((ret = read(sock, buf, len)) > 0) {
-        if (((size_t)ret == len) || (len < PAGE_SIZE)) {
-            break;
-        }
-        len -= ret;
-        buf += ret;
-
-        struct pollfd p = {
-            .fd = sock,
-            .events = POLLIN,
-            .revents = 0
-        };
-
-        ret = poll(&p, 1, 20);
-        if ((ret <= 0) || !(p.revents & POLLIN)) {
-            break;
-        }
-    }
+  ssize_t ret = TEMP_FAILURE_RETRY(write(sock, buf, writeLen));
+  if (ret <= 0) {
     close(sock);
+    return;
+  }
+  while ((ret = read(sock, buf, len)) > 0) {
+    if (((size_t)ret == len) || (len < PAGE_SIZE)) {
+      break;
+    }
+    len -= ret;
+    buf += ret;
+
+    struct pollfd p = {.fd = sock, .events = POLLIN, .revents = 0 };
+
+    ret = poll(&p, 1, 20);
+    if ((ret <= 0) || !(p.revents & POLLIN)) {
+      break;
+    }
+  }
+  close(sock);
 }
 
 static void BM_lookupEventTagNum_logd_new(int iters) {
-    fprintf(stderr, "WARNING: "
-            "This test can cause logd to grow in size and hit DOS limiter\n");
-    // Make copies
-    static const char empty_event_log_tags[] = "# content owned by logd\n";
-    static const char dev_event_log_tags_path[] = "/dev/event-log-tags";
-    std::string dev_event_log_tags;
-    if (android::base::ReadFileToString(dev_event_log_tags_path,
-                                        &dev_event_log_tags) &&
-            (dev_event_log_tags.length() == 0)) {
-        dev_event_log_tags = empty_event_log_tags;
-    }
-    static const char data_event_log_tags_path[] = "/data/misc/logd/event-log-tags";
-    std::string data_event_log_tags;
-    if (android::base::ReadFileToString(data_event_log_tags_path,
-                                        &data_event_log_tags) &&
-            (data_event_log_tags.length() == 0)) {
-        data_event_log_tags = empty_event_log_tags;
-    }
+  fprintf(stderr,
+          "WARNING: "
+          "This test can cause logd to grow in size and hit DOS limiter\n");
+  // Make copies
+  static const char empty_event_log_tags[] = "# content owned by logd\n";
+  static const char dev_event_log_tags_path[] = "/dev/event-log-tags";
+  std::string dev_event_log_tags;
+  if (android::base::ReadFileToString(dev_event_log_tags_path,
+                                      &dev_event_log_tags) &&
+      (dev_event_log_tags.length() == 0)) {
+    dev_event_log_tags = empty_event_log_tags;
+  }
+  static const char data_event_log_tags_path[] =
+      "/data/misc/logd/event-log-tags";
+  std::string data_event_log_tags;
+  if (android::base::ReadFileToString(data_event_log_tags_path,
+                                      &data_event_log_tags) &&
+      (data_event_log_tags.length() == 0)) {
+    data_event_log_tags = empty_event_log_tags;
+  }
 
-    for (int i = 0; i < iters; ++i) {
-        char buffer[256];
-        memset(buffer, 0, sizeof(buffer));
-        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);
-        StartBenchmarkTiming();
-        send_to_control(buffer, sizeof(buffer));
-        StopBenchmarkTiming();
-    }
+  for (int i = 0; i < iters; ++i) {
+    char buffer[256];
+    memset(buffer, 0, sizeof(buffer));
+    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);
+    StartBenchmarkTiming();
+    send_to_control(buffer, sizeof(buffer));
+    StopBenchmarkTiming();
+  }
 
-    // Restore copies (logd still know about them, until crash or reboot)
-    if (dev_event_log_tags.length() &&
-            !android::base::WriteStringToFile(dev_event_log_tags,
-                                              dev_event_log_tags_path)) {
-        fprintf(stderr, "WARNING: "
-                "failed to restore %s\n", dev_event_log_tags_path);
-    }
-    if (data_event_log_tags.length() &&
-            !android::base::WriteStringToFile(data_event_log_tags,
-                                              data_event_log_tags_path)) {
-        fprintf(stderr, "WARNING: "
-                "failed to restore %s\n", data_event_log_tags_path);
-    }
-    fprintf(stderr, "WARNING: "
-            "Restarting logd to make it forget what we just did\n");
-    system("stop logd ; start logd");
+  // Restore copies (logd still know about them, until crash or reboot)
+  if (dev_event_log_tags.length() &&
+      !android::base::WriteStringToFile(dev_event_log_tags,
+                                        dev_event_log_tags_path)) {
+    fprintf(stderr,
+            "WARNING: "
+            "failed to restore %s\n",
+            dev_event_log_tags_path);
+  }
+  if (data_event_log_tags.length() &&
+      !android::base::WriteStringToFile(data_event_log_tags,
+                                        data_event_log_tags_path)) {
+    fprintf(stderr,
+            "WARNING: "
+            "failed to restore %s\n",
+            data_event_log_tags_path);
+  }
+  fprintf(stderr,
+          "WARNING: "
+          "Restarting logd to make it forget what we just did\n");
+  system("stop logd ; start logd");
 }
 BENCHMARK(BM_lookupEventTagNum_logd_new);
 
 static void BM_lookupEventTagNum_logd_existing(int iters) {
-    prechargeEventMap();
+  prechargeEventMap();
 
-    std::unordered_set<uint32_t>::const_iterator it = set.begin();
+  std::unordered_set<uint32_t>::const_iterator it = set.begin();
 
-    for (int i = 0; i < iters; ++i) {
-        size_t len;
-        const char* name = android_lookupEventTag_len(map, &len, (*it));
-        std::string Name(name, len);
-        const char* format = android_lookupEventFormat_len(map, &len, (*it));
-        std::string Format(format, len);
+  for (int i = 0; i < iters; ++i) {
+    size_t len;
+    const char* name = android_lookupEventTag_len(map, &len, (*it));
+    std::string Name(name, len);
+    const char* format = android_lookupEventFormat_len(map, &len, (*it));
+    std::string Format(format, len);
 
-        char buffer[256];
-        snprintf(buffer, sizeof(buffer),
-                 "getEventTag name=%s format=\"%s\"",
-                 Name.c_str(), Format.c_str());
+    char buffer[256];
+    snprintf(buffer, sizeof(buffer), "getEventTag name=%s format=\"%s\"",
+             Name.c_str(), Format.c_str());
 
-        StartBenchmarkTiming();
-        send_to_control(buffer, sizeof(buffer));
-        StopBenchmarkTiming();
-        ++it;
-        if (it == set.end()) it = set.begin();
-    }
+    StartBenchmarkTiming();
+    send_to_control(buffer, sizeof(buffer));
+    StopBenchmarkTiming();
+    ++it;
+    if (it == set.end()) it = set.begin();
+  }
 }
 BENCHMARK(BM_lookupEventTagNum_logd_existing);
diff --git a/liblog/tests/liblog_test.cpp b/liblog/tests/liblog_test.cpp
index bc0ea4c..d68ca46 100644
--- a/liblog/tests/liblog_test.cpp
+++ b/liblog/tests/liblog_test.cpp
@@ -31,24 +31,25 @@
 
 #include <android-base/file.h>
 #include <android-base/stringprintf.h>
-#ifdef __ANDROID__ // includes sys/properties.h which does not exist outside
+#ifdef __ANDROID__  // includes sys/properties.h which does not exist outside
 #include <cutils/properties.h>
 #endif
 #include <gtest/gtest.h>
-#include <log/logprint.h>
 #include <log/log_event_list.h>
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
+#include <log/logprint.h>
 #include <private/android_filesystem_config.h>
 #include <private/android_logger.h>
 
 #ifndef TEST_PREFIX
-#ifdef __ANDROID__ // make sure we always run code if compiled for android
+#ifdef __ANDROID__  // make sure we always run code if compiled for android
 #define TEST_PREFIX
 #endif
 #endif
 
-#if (!defined(USING_LOGGER_DEFAULT) || !defined(USING_LOGGER_LOCAL))
-#ifdef liblog // a binary clue that we are overriding the test names
+#if (!defined(USING_LOGGER_DEFAULT) || !defined(USING_LOGGER_LOCAL) || \
+     !defined(USING_LOGGER_STDERR))
+#ifdef liblog  // a binary clue that we are overriding the test names
 // Does not support log reading blocking feature yet
 // Does not support LOG_ID_SECURITY (unless we set LOGGER_LOCAL | LOGGER_LOGD)
 // Assume some common aspects are tested by USING_LOGGER_DEFAULT:
@@ -62,105 +63,105 @@
 #define USING_LOGGER_DEFAULT
 #endif
 #endif
+#ifdef USING_LOGGER_STDERR
+#define SUPPORTS_END_TO_END 0
+#else
+#define SUPPORTS_END_TO_END 1
+#endif
 
 // enhanced version of LOG_FAILURE_RETRY to add support for EAGAIN and
 // non-syscall libs. Since we are only using this in the emergency of
 // a signal to stuff a terminating code into the logs, we will spin rather
 // than try a usleep.
-#define LOG_FAILURE_RETRY(exp) ({  \
-    typeof (exp) _rc;              \
-    do {                           \
-        _rc = (exp);               \
-    } while (((_rc == -1)          \
-           && ((errno == EINTR)    \
-            || (errno == EAGAIN))) \
-          || (_rc == -EINTR)       \
-          || (_rc == -EAGAIN));    \
-    _rc; })
+#define LOG_FAILURE_RETRY(exp)                                           \
+  ({                                                                     \
+    typeof(exp) _rc;                                                     \
+    do {                                                                 \
+      _rc = (exp);                                                       \
+    } while (((_rc == -1) && ((errno == EINTR) || (errno == EAGAIN))) || \
+             (_rc == -EINTR) || (_rc == -EAGAIN));                       \
+    _rc;                                                                 \
+  })
 
 TEST(liblog, __android_log_btwrite) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
+  TEST_PREFIX
 #endif
-    int intBuf = 0xDEADBEEF;
-    EXPECT_LT(0, __android_log_btwrite(0,
-                                      EVENT_TYPE_INT,
-                                      &intBuf, sizeof(intBuf)));
-    long long longBuf = 0xDEADBEEFA55A5AA5;
-    EXPECT_LT(0, __android_log_btwrite(0,
-                                      EVENT_TYPE_LONG,
-                                      &longBuf, sizeof(longBuf)));
-    usleep(1000);
-    char Buf[] = "\20\0\0\0DeAdBeEfA55a5aA5";
-    EXPECT_LT(0, __android_log_btwrite(0,
-                                      EVENT_TYPE_STRING,
-                                      Buf, sizeof(Buf) - 1));
-    usleep(1000);
+  int intBuf = 0xDEADBEEF;
+  EXPECT_LT(0,
+            __android_log_btwrite(0, EVENT_TYPE_INT, &intBuf, sizeof(intBuf)));
+  long long longBuf = 0xDEADBEEFA55A5AA5;
+  EXPECT_LT(
+      0, __android_log_btwrite(0, EVENT_TYPE_LONG, &longBuf, sizeof(longBuf)));
+  usleep(1000);
+  char Buf[] = "\20\0\0\0DeAdBeEfA55a5aA5";
+  EXPECT_LT(0,
+            __android_log_btwrite(0, EVENT_TYPE_STRING, Buf, sizeof(Buf) - 1));
+  usleep(1000);
 }
 
-#if (defined(__ANDROID__) && !defined(USING_LOGGER_LOCAL))
+#if (defined(__ANDROID__) && defined(USING_LOGGER_DEFAULT))
 static std::string popenToString(std::string command) {
-    std::string ret;
+  std::string ret;
 
-    FILE* fp = popen(command.c_str(), "r");
-    if (fp) {
-        if (!android::base::ReadFdToString(fileno(fp), &ret)) ret = "";
-        pclose(fp);
-    }
-    return ret;
+  FILE* fp = popen(command.c_str(), "r");
+  if (fp) {
+    if (!android::base::ReadFdToString(fileno(fp), &ret)) ret = "";
+    pclose(fp);
+  }
+  return ret;
 }
 
 static bool isPmsgActive() {
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    std::string myPidFds = popenToString(android::base::StringPrintf(
-                                             "ls -l /proc/%d/fd", pid));
-    if (myPidFds.length() == 0) return true; // guess it is?
+  std::string myPidFds =
+      popenToString(android::base::StringPrintf("ls -l /proc/%d/fd", pid));
+  if (myPidFds.length() == 0) return true;  // guess it is?
 
-    return std::string::npos != myPidFds.find(" -> /dev/pmsg0");
+  return std::string::npos != myPidFds.find(" -> /dev/pmsg0");
 }
 
 static bool isLogdwActive() {
-    std::string logdwSignature = popenToString(
-        "grep /dev/socket/logdw /proc/net/unix");
-    size_t beginning = logdwSignature.find(" ");
-    if (beginning == std::string::npos) return true;
-    beginning = logdwSignature.find(" ", beginning + 1);
-    if (beginning == std::string::npos) return true;
-    size_t end = logdwSignature.find(" ", beginning + 1);
-    if (end == std::string::npos) return true;
-    end = logdwSignature.find(" ", end + 1);
-    if (end == std::string::npos) return true;
-    end = logdwSignature.find(" ", end + 1);
-    if (end == std::string::npos) return true;
-    end = logdwSignature.find(" ", end + 1);
-    if (end == std::string::npos) return true;
-    std::string allLogdwEndpoints = popenToString(
-        "grep ' 00000002" +
-        logdwSignature.substr(beginning, end - beginning) +
-        " ' /proc/net/unix | " +
-        "sed -n 's/.* \\([0-9][0-9]*\\)$/ -> socket:[\\1]/p'");
-    if (allLogdwEndpoints.length() == 0) return true;
+  std::string logdwSignature =
+      popenToString("grep /dev/socket/logdw /proc/net/unix");
+  size_t beginning = logdwSignature.find(" ");
+  if (beginning == std::string::npos) return true;
+  beginning = logdwSignature.find(" ", beginning + 1);
+  if (beginning == std::string::npos) return true;
+  size_t end = logdwSignature.find(" ", beginning + 1);
+  if (end == std::string::npos) return true;
+  end = logdwSignature.find(" ", end + 1);
+  if (end == std::string::npos) return true;
+  end = logdwSignature.find(" ", end + 1);
+  if (end == std::string::npos) return true;
+  end = logdwSignature.find(" ", end + 1);
+  if (end == std::string::npos) return true;
+  std::string allLogdwEndpoints = popenToString(
+      "grep ' 00000002" + logdwSignature.substr(beginning, end - beginning) +
+      " ' /proc/net/unix | " +
+      "sed -n 's/.* \\([0-9][0-9]*\\)$/ -> socket:[\\1]/p'");
+  if (allLogdwEndpoints.length() == 0) return true;
 
-    // NB: allLogdwEndpoints has some false positives in it, but those
-    // strangers do not overlap with the simplistic activities inside this
-    // test suite.
+  // NB: allLogdwEndpoints has some false positives in it, but those
+  // strangers do not overlap with the simplistic activities inside this
+  // test suite.
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    std::string myPidFds = popenToString(android::base::StringPrintf(
-        "ls -l /proc/%d/fd", pid));
-    if (myPidFds.length() == 0) return true;
+  std::string myPidFds =
+      popenToString(android::base::StringPrintf("ls -l /proc/%d/fd", pid));
+  if (myPidFds.length() == 0) return true;
 
-    // NB: fgrep with multiple strings is broken in Android
-    for (beginning = 0;
-         (end = allLogdwEndpoints.find("\n", beginning)) != std::string::npos;
-         beginning = end + 1) {
-        if (myPidFds.find(allLogdwEndpoints.substr(beginning,
-                                                   end - beginning)) !=
-            std::string::npos) return true;
-    }
-    return false;
+  // NB: fgrep with multiple strings is broken in Android
+  for (beginning = 0;
+       (end = allLogdwEndpoints.find("\n", beginning)) != std::string::npos;
+       beginning = end + 1) {
+    if (myPidFds.find(allLogdwEndpoints.substr(beginning, end - beginning)) !=
+        std::string::npos)
+      return true;
+  }
+  return false;
 }
 
 static bool tested__android_log_close;
@@ -168,387 +169,455 @@
 
 TEST(liblog, __android_log_btwrite__android_logger_list_read) {
 #if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL))
-    struct logger_list *logger_list;
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
-    log_time ts(CLOCK_MONOTONIC);
-    ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-#ifndef USING_LOGGER_LOCAL
-    // Check that we can close and reopen the logger
-    bool pmsgActiveAfter__android_log_btwrite;
-    bool logdwActiveAfter__android_log_btwrite;
-    if (getuid() == AID_ROOT) {
-        tested__android_log_close = true;
-        pmsgActiveAfter__android_log_btwrite = isPmsgActive();
-        logdwActiveAfter__android_log_btwrite = isLogdwActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
-        EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
-    } else if (!tested__android_log_close) {
-        fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-    }
-    __android_log_close();
-    if (getuid() == AID_ROOT) {
-        bool pmsgActiveAfter__android_log_close = isPmsgActive();
-        bool logdwActiveAfter__android_log_close = isLogdwActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-        EXPECT_FALSE(logdwActiveAfter__android_log_close);
-    }
+  log_time ts(CLOCK_MONOTONIC);
+  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+#ifdef USING_LOGGER_DEFAULT
+  // Check that we can close and reopen the logger
+  bool pmsgActiveAfter__android_log_btwrite;
+  bool logdwActiveAfter__android_log_btwrite;
+  if (getuid() == AID_ROOT) {
+    tested__android_log_close = true;
+    pmsgActiveAfter__android_log_btwrite = isPmsgActive();
+    logdwActiveAfter__android_log_btwrite = isLogdwActive();
+    EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
+    EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
+  } else if (!tested__android_log_close) {
+    fprintf(stderr, "WARNING: can not test __android_log_close()\n");
+  }
+  __android_log_close();
+  if (getuid() == AID_ROOT) {
+    bool pmsgActiveAfter__android_log_close = isPmsgActive();
+    bool logdwActiveAfter__android_log_close = isLogdwActive();
+    EXPECT_FALSE(pmsgActiveAfter__android_log_close);
+    EXPECT_FALSE(logdwActiveAfter__android_log_close);
+  }
 #endif
 
-    log_time ts1(CLOCK_MONOTONIC);
-    ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
-#ifndef USING_LOGGER_LOCAL
-    if (getuid() == AID_ROOT) {
-        pmsgActiveAfter__android_log_btwrite = isPmsgActive();
-        logdwActiveAfter__android_log_btwrite = isLogdwActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
-        EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
-    }
+  log_time ts1(CLOCK_MONOTONIC);
+  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts1, sizeof(ts1)));
+#ifdef USING_LOGGER_DEFAULT
+  if (getuid() == AID_ROOT) {
+    pmsgActiveAfter__android_log_btwrite = isPmsgActive();
+    logdwActiveAfter__android_log_btwrite = isLogdwActive();
+    EXPECT_TRUE(pmsgActiveAfter__android_log_btwrite);
+    EXPECT_TRUE(logdwActiveAfter__android_log_btwrite);
+  }
 #endif
-    usleep(1000000);
+  usleep(1000000);
 
-    int count = 0;
-    int second_count = 0;
+  int count = 0;
+  int second_count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        ASSERT_EQ(log_msg.entry.pid, pid);
-
-        if ((log_msg.entry.len != sizeof(android_log_event_long_t))
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
-
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-        if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-            continue;
-        }
-
-        log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-        if (ts == tx) {
-            ++count;
-        } else if (ts1 == tx) {
-            ++second_count;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    EXPECT_EQ(1, count);
-    EXPECT_EQ(1, second_count);
+    EXPECT_EQ(log_msg.entry.pid, pid);
 
-    android_logger_list_close(logger_list);
+    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
+
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+
+    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
+      continue;
+    }
+
+    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
+    if (ts == tx) {
+      ++count;
+    } else if (ts1 == tx) {
+      ++second_count;
+    }
+  }
+
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, second_count);
+
+  android_logger_list_close(logger_list);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
+#if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL))
+static void print_transport(const char* prefix, int logger) {
+  static const char orstr[] = " | ";
+
+  if (!prefix) {
+    prefix = "";
+  }
+  if (logger < 0) {
+    fprintf(stderr, "%s%s\n", prefix, strerror(-logger));
+    return;
+  }
+
+  if (logger == LOGGER_DEFAULT) {
+    fprintf(stderr, "%sLOGGER_DEFAULT", prefix);
+    prefix = orstr;
+  }
+  if (logger & LOGGER_LOGD) {
+    fprintf(stderr, "%sLOGGER_LOGD", prefix);
+    prefix = orstr;
+  }
+  if (logger & LOGGER_KERNEL) {
+    fprintf(stderr, "%sLOGGER_KERNEL", prefix);
+    prefix = orstr;
+  }
+  if (logger & LOGGER_NULL) {
+    fprintf(stderr, "%sLOGGER_NULL", prefix);
+    prefix = orstr;
+  }
+  if (logger & LOGGER_LOCAL) {
+    fprintf(stderr, "%sLOGGER_LOCAL", prefix);
+    prefix = orstr;
+  }
+  if (logger & LOGGER_STDERR) {
+    fprintf(stderr, "%sLOGGER_STDERR", prefix);
+    prefix = orstr;
+  }
+  logger &= ~(LOGGER_LOGD | LOGGER_KERNEL | LOGGER_NULL | LOGGER_LOCAL |
+              LOGGER_STDERR);
+  if (logger) {
+    fprintf(stderr, "%s0x%x", prefix, logger);
+    prefix = orstr;
+  }
+  if (prefix == orstr) {
+    fprintf(stderr, "\n");
+  }
+}
+#endif
+
 // This test makes little sense standalone, and requires the tests ahead
 // and behind us, to make us whole.  We could incorporate a prefix and
 // suffix test to make this standalone, but opted to not complicate this.
-TEST(liblog, android_set_log_frontend) {
+TEST(liblog, android_set_log_transport) {
 #if (defined(__ANDROID__) || defined(USING_LOGGER_LOCAL))
 #ifdef TEST_PREFIX
-    TEST_PREFIX
+  TEST_PREFIX
 #endif
 
-    int logger = android_get_log_frontend();
-    EXPECT_NE(LOGGER_NULL, logger);
+  int logger = android_get_log_transport();
+  print_transport("android_get_log_transport = ", logger);
+  EXPECT_NE(LOGGER_NULL, logger);
 
-    EXPECT_EQ(LOGGER_NULL, android_set_log_frontend(LOGGER_NULL));
-    EXPECT_EQ(LOGGER_NULL, android_get_log_frontend());
+  int ret;
+  EXPECT_EQ(LOGGER_NULL, ret = android_set_log_transport(LOGGER_NULL));
+  print_transport("android_set_log_transport = ", ret);
+  EXPECT_EQ(LOGGER_NULL, ret = android_get_log_transport());
+  print_transport("android_get_log_transport = ", ret);
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    struct logger_list *logger_list;
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  struct logger_list* logger_list;
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
-    log_time ts(CLOCK_MONOTONIC);
-    ASSERT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+  log_time ts(CLOCK_MONOTONIC);
+  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
 
-    usleep(1000000);
+  usleep(1000000);
 
-    int count = 0;
+  int count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        ASSERT_EQ(log_msg.entry.pid, pid);
-
-        if ((log_msg.entry.len != sizeof(android_log_event_long_t))
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
-
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-
-        if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-            continue;
-        }
-
-        log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-        if (ts == tx) {
-            ++count;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    android_logger_list_close(logger_list);
+    EXPECT_EQ(log_msg.entry.pid, pid);
 
-    EXPECT_EQ(logger, android_set_log_frontend(logger));
-    EXPECT_EQ(logger, android_get_log_frontend());
+    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
 
-    // False negative if liblog.__android_log_btwrite__android_logger_list_read
-    // fails above, so we will likely succeed. But we will have so many
-    // failures elsewhere that it is probably not worthwhile for us to
-    // highlight yet another disappointment.
-    EXPECT_EQ(0, count);
-    // We also expect failures in the following tests if the set does not
-    // react in an appropriate manner internally, yet passes, so we depend
-    // on this test being in the middle of a series of tests performed in
-    // the same process.
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+
+    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
+      continue;
+    }
+
+    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
+    if (ts == tx) {
+      ++count;
+    }
+  }
+
+  android_logger_list_close(logger_list);
+
+  EXPECT_EQ(logger, ret = android_set_log_transport(logger));
+  print_transport("android_set_log_transport = ", ret);
+  EXPECT_EQ(logger, ret = android_get_log_transport());
+  print_transport("android_get_log_transport = ", ret);
+
+  // False negative if liblog.__android_log_btwrite__android_logger_list_read
+  // fails above, so we will likely succeed. But we will have so many
+  // failures elsewhere that it is probably not worthwhile for us to
+  // highlight yet another disappointment.
+  //
+  // We also expect failures in the following tests if the set does not
+  // react in an appropriate manner internally, yet passes, so we depend
+  // on this test being in the middle of a series of tests performed in
+  // the same process.
+  EXPECT_EQ(0, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 #ifdef TEST_PREFIX
 static inline uint32_t get4LE(const uint8_t* src) {
-    return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
+  return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
 }
 
 static inline uint32_t get4LE(const char* src) {
-    return get4LE(reinterpret_cast<const uint8_t*>(src));
+  return get4LE(reinterpret_cast<const uint8_t*>(src));
 }
 #endif
 
-static void bswrite_test(const char *message) {
+static void bswrite_test(const char* message) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    struct logger_list *logger_list;
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
 #ifdef __ANDROID__
-    log_time ts(android_log_clockid());
+  log_time ts(android_log_clockid());
 #else
-    log_time ts(CLOCK_REALTIME);
+  log_time ts(CLOCK_REALTIME);
 #endif
 
-    ASSERT_LT(0, __android_log_bswrite(0, message));
-    size_t num_lines = 1, size = 0, length = 0, total = 0;
-    const char *cp = message;
-    while (*cp) {
-        if (*cp == '\n') {
-            if (cp[1]) {
-                ++num_lines;
-            }
-        } else {
-            ++size;
-        }
-        ++cp;
-        ++total;
-        ++length;
-        if ((LOGGER_ENTRY_MAX_PAYLOAD - 4 - 1 - 4) <= length) {
-            break;
-        }
+  EXPECT_LT(0, __android_log_bswrite(0, message));
+  size_t num_lines = 1, size = 0, length = 0, total = 0;
+  const char* cp = message;
+  while (*cp) {
+    if (*cp == '\n') {
+      if (cp[1]) {
+        ++num_lines;
+      }
+    } else {
+      ++size;
     }
-    while (*cp) {
-        ++cp;
-        ++total;
+    ++cp;
+    ++total;
+    ++length;
+    if ((LOGGER_ENTRY_MAX_PAYLOAD - 4 - 1 - 4) <= length) {
+      break;
     }
-    usleep(1000000);
+  }
+  while (*cp) {
+    ++cp;
+    ++total;
+  }
+  usleep(1000000);
 
-    int count = 0;
+  int count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
+    }
 
-        ASSERT_EQ(log_msg.entry.pid, pid);
+    EXPECT_EQ(log_msg.entry.pid, pid);
 
-        if ((log_msg.entry.sec < (ts.tv_sec - 1))
-         || ((ts.tv_sec + 1) < log_msg.entry.sec)
-         || ((size_t)log_msg.entry.len != (sizeof(android_log_event_string_t) +
-                                           length))
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
+    if ((log_msg.entry.sec < (ts.tv_sec - 1)) ||
+        ((ts.tv_sec + 1) < log_msg.entry.sec) ||
+        ((size_t)log_msg.entry.len !=
+         (sizeof(android_log_event_string_t) + length)) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
 
-        android_log_event_string_t* eventData;
-        eventData = reinterpret_cast<android_log_event_string_t*>(log_msg.msg());
+    android_log_event_string_t* eventData;
+    eventData = reinterpret_cast<android_log_event_string_t*>(log_msg.msg());
 
-        if (!eventData || (eventData->type != EVENT_TYPE_STRING)) {
-            continue;
-        }
+    if (!eventData || (eventData->type != EVENT_TYPE_STRING)) {
+      continue;
+    }
 
-        size_t len = get4LE(reinterpret_cast<char*>(&eventData->length));
-        if (len == total) {
-            ++count;
+    size_t len = get4LE(reinterpret_cast<char*>(&eventData->length));
+    if (len == total) {
+      ++count;
 
-            AndroidLogFormat *logformat = android_log_format_new();
-            EXPECT_TRUE(NULL != logformat);
-            AndroidLogEntry entry;
-            char msgBuf[1024];
-            if (length != total) {
-                fprintf(stderr, "Expect \"Binary log entry conversion failed\"\n");
-            }
-            int processBinaryLogBuffer = android_log_processBinaryLogBuffer(
-                &log_msg.entry_v1, &entry, NULL, msgBuf, sizeof(msgBuf));
-            EXPECT_EQ((length == total) ? 0 : -1, processBinaryLogBuffer);
-            if (processBinaryLogBuffer == 0) {
-                size_t line_overhead = 20;
-                if (pid > 99999) ++line_overhead;
-                if (pid > 999999) ++line_overhead;
-                fflush(stderr);
-                EXPECT_EQ((int)((line_overhead * num_lines) + size),
+      AndroidLogFormat* logformat = android_log_format_new();
+      EXPECT_TRUE(NULL != logformat);
+      AndroidLogEntry entry;
+      char msgBuf[1024];
+      if (length != total) {
+        fprintf(stderr, "Expect \"Binary log entry conversion failed\"\n");
+      }
+      int processBinaryLogBuffer = android_log_processBinaryLogBuffer(
+          &log_msg.entry_v1, &entry, NULL, msgBuf, sizeof(msgBuf));
+      EXPECT_EQ((length == total) ? 0 : -1, processBinaryLogBuffer);
+      if ((processBinaryLogBuffer == 0) || entry.message) {
+        size_t line_overhead = 20;
+        if (pid > 99999) ++line_overhead;
+        if (pid > 999999) ++line_overhead;
+        fflush(stderr);
+        if (processBinaryLogBuffer) {
+          EXPECT_GT((int)((line_overhead * num_lines) + size),
                     android_log_printLogLine(logformat, fileno(stderr), &entry));
-            }
-            android_log_format_free(logformat);
+        } else {
+          EXPECT_EQ((int)((line_overhead * num_lines) + size),
+                    android_log_printLogLine(logformat, fileno(stderr), &entry));
         }
+      }
+      android_log_format_free(logformat);
     }
+  }
 
-    EXPECT_EQ(1, count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 
-    android_logger_list_close(logger_list);
+  android_logger_list_close(logger_list);
 #else
-    message = NULL;
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  message = NULL;
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, __android_log_bswrite_and_print) {
-    bswrite_test("Hello World");
+  bswrite_test("Hello World");
 }
 
 TEST(liblog, __android_log_bswrite_and_print__empty_string) {
-    bswrite_test("");
+  bswrite_test("");
 }
 
 TEST(liblog, __android_log_bswrite_and_print__newline_prefix) {
-    bswrite_test("\nHello World\n");
+  bswrite_test("\nHello World\n");
 }
 
 TEST(liblog, __android_log_bswrite_and_print__newline_space_prefix) {
-    bswrite_test("\n Hello World \n");
+  bswrite_test("\n Hello World \n");
 }
 
 TEST(liblog, __android_log_bswrite_and_print__multiple_newline) {
-    bswrite_test("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten");
+  bswrite_test("one\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten");
 }
 
-static void buf_write_test(const char *message) {
+static void buf_write_test(const char* message) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    struct logger_list *logger_list;
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(
+      NULL !=
+      (logger_list = android_logger_list_open(
+           LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
 
-    static const char tag[] = "TEST__android_log_buf_write";
+  static const char tag[] = "TEST__android_log_buf_write";
 #ifdef __ANDROID__
-    log_time ts(android_log_clockid());
+  log_time ts(android_log_clockid());
 #else
-    log_time ts(CLOCK_REALTIME);
+  log_time ts(CLOCK_REALTIME);
 #endif
 
-    EXPECT_LT(0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                         tag, message));
-    size_t num_lines = 1, size = 0, length = 0;
-    const char *cp = message;
-    while (*cp) {
-        if (*cp == '\n') {
-            if (cp[1]) {
-                ++num_lines;
-            }
-        } else {
-            ++size;
-        }
-        ++length;
-        if ((LOGGER_ENTRY_MAX_PAYLOAD - 2 - sizeof(tag)) <= length) {
-            break;
-        }
-        ++cp;
+  EXPECT_LT(
+      0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO, tag, message));
+  size_t num_lines = 1, size = 0, length = 0;
+  const char* cp = message;
+  while (*cp) {
+    if (*cp == '\n') {
+      if (cp[1]) {
+        ++num_lines;
+      }
+    } else {
+      ++size;
     }
-    usleep(1000000);
+    ++length;
+    if ((LOGGER_ENTRY_MAX_PAYLOAD - 2 - sizeof(tag)) <= length) {
+      break;
+    }
+    ++cp;
+  }
+  usleep(1000000);
 
-    int count = 0;
+  int count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
+    }
 
-        ASSERT_EQ(log_msg.entry.pid, pid);
+    ASSERT_EQ(log_msg.entry.pid, pid);
 
-        if ((log_msg.entry.sec < (ts.tv_sec - 1))
-         || ((ts.tv_sec + 1) < log_msg.entry.sec)
-         || ((size_t)log_msg.entry.len != (sizeof(tag) + length + 2))
-         || (log_msg.id() != LOG_ID_MAIN)) {
-            continue;
-        }
+    if ((log_msg.entry.sec < (ts.tv_sec - 1)) ||
+        ((ts.tv_sec + 1) < log_msg.entry.sec) ||
+        ((size_t)log_msg.entry.len != (sizeof(tag) + length + 2)) ||
+        (log_msg.id() != LOG_ID_MAIN)) {
+      continue;
+    }
 
-        ++count;
+    ++count;
 
-        AndroidLogFormat *logformat = android_log_format_new();
-        EXPECT_TRUE(NULL != logformat);
-        AndroidLogEntry entry;
-        int processLogBuffer = android_log_processLogBuffer(&log_msg.entry_v1,
-                                                            &entry);
-        EXPECT_EQ(0, processLogBuffer);
-        if (processLogBuffer == 0) {
-            size_t line_overhead = 11;
-            if (pid > 99999) ++line_overhead;
-            if (pid > 999999) ++line_overhead;
-            fflush(stderr);
-            EXPECT_EQ((int)(((line_overhead + sizeof(tag)) * num_lines) + size),
+    AndroidLogFormat* logformat = android_log_format_new();
+    EXPECT_TRUE(NULL != logformat);
+    AndroidLogEntry entry;
+    int processLogBuffer =
+        android_log_processLogBuffer(&log_msg.entry_v1, &entry);
+    EXPECT_EQ(0, processLogBuffer);
+    if (processLogBuffer == 0) {
+      size_t line_overhead = 11;
+      if (pid > 99999) ++line_overhead;
+      if (pid > 999999) ++line_overhead;
+      fflush(stderr);
+      EXPECT_EQ((int)(((line_overhead + sizeof(tag)) * num_lines) + size),
                 android_log_printLogLine(logformat, fileno(stderr), &entry));
-        }
-        android_log_format_free(logformat);
     }
+    android_log_format_free(logformat);
+  }
 
-    EXPECT_EQ(1, count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 
-    android_logger_list_close(logger_list);
+  android_logger_list_close(logger_list);
 #else
-    message = NULL;
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  message = NULL;
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, __android_log_buf_write_and_print__empty) {
-    buf_write_test("");
+  buf_write_test("");
 }
 
 TEST(liblog, __android_log_buf_write_and_print__newline_prefix) {
-    buf_write_test("\nHello World\n");
+  buf_write_test("\nHello World\n");
 }
 
 TEST(liblog, __android_log_buf_write_and_print__newline_space_prefix) {
-    buf_write_test("\n Hello World \n");
+  buf_write_test("\n Hello World \n");
 }
 
-#ifndef USING_LOGGER_LOCAL // requires blocking reader functionality
+#ifndef USING_LOGGER_LOCAL  // requires blocking reader functionality
 #ifdef TEST_PREFIX
 static unsigned signaled;
 static log_time signal_time;
@@ -559,148 +628,147 @@
  * should catch any regressions in that effort. The odds of a logged message
  * in a signal handler causing a lockup problem should be _very_ small.
  */
-static void caught_blocking_signal(int /*signum*/)
-{
-    unsigned long long v = 0xDEADBEEFA55A0000ULL;
+static void caught_blocking_signal(int /*signum*/) {
+  unsigned long long v = 0xDEADBEEFA55A0000ULL;
 
-    v += getpid() & 0xFFFF;
+  v += getpid() & 0xFFFF;
 
-    ++signaled;
-    if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
-        signal_time = log_time(CLOCK_MONOTONIC);
-        signal_time.tv_sec += 2;
-    }
+  ++signaled;
+  if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
+    signal_time = log_time(CLOCK_MONOTONIC);
+    signal_time.tv_sec += 2;
+  }
 
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
+  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
 }
 
 // Fill in current process user and system time in 10ms increments
-static void get_ticks(unsigned long long *uticks, unsigned long long *sticks)
-{
+static void get_ticks(unsigned long long* uticks, unsigned long long* sticks) {
+  *uticks = *sticks = 0;
+
+  pid_t pid = getpid();
+
+  char buffer[512];
+  snprintf(buffer, sizeof(buffer), "/proc/%u/stat", pid);
+
+  FILE* fp = fopen(buffer, "r");
+  if (!fp) {
+    return;
+  }
+
+  char* cp = fgets(buffer, sizeof(buffer), fp);
+  fclose(fp);
+  if (!cp) {
+    return;
+  }
+
+  pid_t d;
+  char s[sizeof(buffer)];
+  char c;
+  long long ll;
+  unsigned long long ull;
+
+  if (15 != sscanf(buffer,
+                   "%d %s %c %lld %lld %lld %lld %lld %llu %llu %llu %llu %llu "
+                   "%llu %llu ",
+                   &d, s, &c, &ll, &ll, &ll, &ll, &ll, &ull, &ull, &ull, &ull,
+                   &ull, uticks, sticks)) {
     *uticks = *sticks = 0;
-
-    pid_t pid = getpid();
-
-    char buffer[512];
-    snprintf(buffer, sizeof(buffer), "/proc/%u/stat", pid);
-
-    FILE *fp = fopen(buffer, "r");
-    if (!fp) {
-        return;
-    }
-
-    char *cp = fgets(buffer, sizeof(buffer), fp);
-    fclose(fp);
-    if (!cp) {
-        return;
-    }
-
-    pid_t d;
-    char s[sizeof(buffer)];
-    char c;
-    long long ll;
-    unsigned long long ull;
-
-    if (15 != sscanf(buffer,
-      "%d %s %c %lld %lld %lld %lld %lld %llu %llu %llu %llu %llu %llu %llu ",
-      &d, s, &c, &ll, &ll, &ll, &ll, &ll, &ull, &ull, &ull, &ull, &ull,
-      uticks, sticks)) {
-        *uticks = *sticks = 0;
-    }
+  }
 }
 #endif
 
 TEST(liblog, android_logger_list_read__cpu_signal) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    struct logger_list *logger_list;
-    unsigned long long v = 0xDEADBEEFA55A0000ULL;
+  TEST_PREFIX
+  struct logger_list* logger_list;
+  unsigned long long v = 0xDEADBEEFA55A0000ULL;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    v += pid & 0xFFFF;
+  v += pid & 0xFFFF;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 1000, pid)));
+  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
+                           LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 1000, pid)));
 
-    int count = 0;
+  int count = 0;
 
-    int signals = 0;
+  int signals = 0;
 
-    unsigned long long uticks_start;
-    unsigned long long sticks_start;
-    get_ticks(&uticks_start, &sticks_start);
+  unsigned long long uticks_start;
+  unsigned long long sticks_start;
+  get_ticks(&uticks_start, &sticks_start);
 
-    const unsigned alarm_time = 10;
+  const unsigned alarm_time = 10;
 
-    memset(&signal_time, 0, sizeof(signal_time));
+  memset(&signal_time, 0, sizeof(signal_time));
 
-    signal(SIGALRM, caught_blocking_signal);
+  signal(SIGALRM, caught_blocking_signal);
+  alarm(alarm_time);
+
+  signaled = 0;
+
+  do {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
+    }
+
     alarm(alarm_time);
 
-    signaled = 0;
+    ++count;
 
-    do {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
+    ASSERT_EQ(log_msg.entry.pid, pid);
 
-        alarm(alarm_time);
+    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
 
-        ++count;
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
 
-        ASSERT_EQ(log_msg.entry.pid, pid);
+    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
+      continue;
+    }
 
-        if ((log_msg.entry.len != sizeof(android_log_event_long_t))
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
+    char* cp = reinterpret_cast<char*>(&eventData->payload.data);
+    unsigned long long l = cp[0] & 0xFF;
+    l |= (unsigned long long)(cp[1] & 0xFF) << 8;
+    l |= (unsigned long long)(cp[2] & 0xFF) << 16;
+    l |= (unsigned long long)(cp[3] & 0xFF) << 24;
+    l |= (unsigned long long)(cp[4] & 0xFF) << 32;
+    l |= (unsigned long long)(cp[5] & 0xFF) << 40;
+    l |= (unsigned long long)(cp[6] & 0xFF) << 48;
+    l |= (unsigned long long)(cp[7] & 0xFF) << 56;
 
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+    if (l == v) {
+      ++signals;
+      break;
+    }
+  } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
+  alarm(0);
+  signal(SIGALRM, SIG_DFL);
 
-        if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-            continue;
-        }
+  EXPECT_LE(1, count);
 
-        char* cp = reinterpret_cast<char*>(&eventData->payload.data);
-        unsigned long long l = cp[0] & 0xFF;
-        l |= (unsigned long long) (cp[1] & 0xFF) << 8;
-        l |= (unsigned long long) (cp[2] & 0xFF) << 16;
-        l |= (unsigned long long) (cp[3] & 0xFF) << 24;
-        l |= (unsigned long long) (cp[4] & 0xFF) << 32;
-        l |= (unsigned long long) (cp[5] & 0xFF) << 40;
-        l |= (unsigned long long) (cp[6] & 0xFF) << 48;
-        l |= (unsigned long long) (cp[7] & 0xFF) << 56;
+  EXPECT_EQ(1, signals);
 
-        if (l == v) {
-            ++signals;
-            break;
-        }
-    } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
-    alarm(0);
-    signal(SIGALRM, SIG_DFL);
+  android_logger_list_close(logger_list);
 
-    EXPECT_LE(1, count);
+  unsigned long long uticks_end;
+  unsigned long long sticks_end;
+  get_ticks(&uticks_end, &sticks_end);
 
-    EXPECT_EQ(1, signals);
-
-    android_logger_list_close(logger_list);
-
-    unsigned long long uticks_end;
-    unsigned long long sticks_end;
-    get_ticks(&uticks_end, &sticks_end);
-
-    // Less than 1% in either user or system time, or both
-    const unsigned long long one_percent_ticks = alarm_time;
-    unsigned long long user_ticks = uticks_end - uticks_start;
-    unsigned long long system_ticks = sticks_end - sticks_start;
-    EXPECT_GT(one_percent_ticks, user_ticks);
-    EXPECT_GT(one_percent_ticks, system_ticks);
-    EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
+  // Less than 1% in either user or system time, or both
+  const unsigned long long one_percent_ticks = alarm_time;
+  unsigned long long user_ticks = uticks_end - uticks_start;
+  unsigned long long system_ticks = sticks_end - sticks_start;
+  EXPECT_GT(one_percent_ticks, user_ticks);
+  EXPECT_GT(one_percent_ticks, system_ticks);
+  EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
@@ -712,165 +780,164 @@
  */
 static sem_t thread_trigger;
 
-static void caught_blocking_thread(int /*signum*/)
-{
-    sem_post(&thread_trigger);
+static void caught_blocking_thread(int /*signum*/) {
+  sem_post(&thread_trigger);
 }
 
-static void *running_thread(void *) {
-    unsigned long long v = 0xDEADBEAFA55A0000ULL;
+static void* running_thread(void*) {
+  unsigned long long v = 0xDEADBEAFA55A0000ULL;
 
-    v += getpid() & 0xFFFF;
+  v += getpid() & 0xFFFF;
 
-    struct timespec timeout;
-    clock_gettime(CLOCK_REALTIME, &timeout);
-    timeout.tv_sec += 55;
-    sem_timedwait(&thread_trigger, &timeout);
+  struct timespec timeout;
+  clock_gettime(CLOCK_REALTIME, &timeout);
+  timeout.tv_sec += 55;
+  sem_timedwait(&thread_trigger, &timeout);
 
-    ++signaled;
-    if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
-        signal_time = log_time(CLOCK_MONOTONIC);
-        signal_time.tv_sec += 2;
-    }
+  ++signaled;
+  if ((signal_time.tv_sec == 0) && (signal_time.tv_nsec == 0)) {
+    signal_time = log_time(CLOCK_MONOTONIC);
+    signal_time.tv_sec += 2;
+  }
 
-    LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
+  LOG_FAILURE_RETRY(__android_log_btwrite(0, EVENT_TYPE_LONG, &v, sizeof(v)));
 
-    return NULL;
+  return NULL;
 }
 
-static int start_thread()
-{
-    sem_init(&thread_trigger, 0, 0);
+static int start_thread() {
+  sem_init(&thread_trigger, 0, 0);
 
-    pthread_attr_t attr;
-    if (pthread_attr_init(&attr)) {
-        return -1;
-    }
+  pthread_attr_t attr;
+  if (pthread_attr_init(&attr)) {
+    return -1;
+  }
 
-    struct sched_param param;
+  struct sched_param param;
 
-    memset(&param, 0, sizeof(param));
-    pthread_attr_setschedparam(&attr, &param);
-    pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
+  memset(&param, 0, sizeof(param));
+  pthread_attr_setschedparam(&attr, &param);
+  pthread_attr_setschedpolicy(&attr, SCHED_BATCH);
 
-    if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
-        pthread_attr_destroy(&attr);
-        return -1;
-    }
-
-    pthread_t thread;
-    if (pthread_create(&thread, &attr, running_thread, NULL)) {
-        pthread_attr_destroy(&attr);
-        return -1;
-    }
-
+  if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) {
     pthread_attr_destroy(&attr);
-    return 0;
+    return -1;
+  }
+
+  pthread_t thread;
+  if (pthread_create(&thread, &attr, running_thread, NULL)) {
+    pthread_attr_destroy(&attr);
+    return -1;
+  }
+
+  pthread_attr_destroy(&attr);
+  return 0;
 }
 #endif
 
 TEST(liblog, android_logger_list_read__cpu_thread) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    struct logger_list *logger_list;
-    unsigned long long v = 0xDEADBEAFA55A0000ULL;
+  TEST_PREFIX
+  struct logger_list* logger_list;
+  unsigned long long v = 0xDEADBEAFA55A0000ULL;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    v += pid & 0xFFFF;
+  v += pid & 0xFFFF;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 1000, pid)));
+  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
+                           LOG_ID_EVENTS, ANDROID_LOG_RDONLY, 1000, pid)));
 
-    int count = 0;
+  int count = 0;
 
-    int signals = 0;
+  int signals = 0;
 
-    unsigned long long uticks_start;
-    unsigned long long sticks_start;
-    get_ticks(&uticks_start, &sticks_start);
+  unsigned long long uticks_start;
+  unsigned long long sticks_start;
+  get_ticks(&uticks_start, &sticks_start);
 
-    const unsigned alarm_time = 10;
+  const unsigned alarm_time = 10;
 
-    memset(&signal_time, 0, sizeof(signal_time));
+  memset(&signal_time, 0, sizeof(signal_time));
 
-    signaled = 0;
-    EXPECT_EQ(0, start_thread());
+  signaled = 0;
+  EXPECT_EQ(0, start_thread());
 
-    signal(SIGALRM, caught_blocking_thread);
+  signal(SIGALRM, caught_blocking_thread);
+  alarm(alarm_time);
+
+  do {
+    log_msg log_msg;
+    if (LOG_FAILURE_RETRY(android_logger_list_read(logger_list, &log_msg)) <= 0) {
+      break;
+    }
+
     alarm(alarm_time);
 
-    do {
-        log_msg log_msg;
-        if (LOG_FAILURE_RETRY(android_logger_list_read(logger_list, &log_msg)) <= 0) {
-            break;
-        }
+    ++count;
 
-        alarm(alarm_time);
+    ASSERT_EQ(log_msg.entry.pid, pid);
 
-        ++count;
+    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
 
-        ASSERT_EQ(log_msg.entry.pid, pid);
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
 
-        if ((log_msg.entry.len != sizeof(android_log_event_long_t))
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
+    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
+      continue;
+    }
 
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+    char* cp = reinterpret_cast<char*>(&eventData->payload.data);
+    unsigned long long l = cp[0] & 0xFF;
+    l |= (unsigned long long)(cp[1] & 0xFF) << 8;
+    l |= (unsigned long long)(cp[2] & 0xFF) << 16;
+    l |= (unsigned long long)(cp[3] & 0xFF) << 24;
+    l |= (unsigned long long)(cp[4] & 0xFF) << 32;
+    l |= (unsigned long long)(cp[5] & 0xFF) << 40;
+    l |= (unsigned long long)(cp[6] & 0xFF) << 48;
+    l |= (unsigned long long)(cp[7] & 0xFF) << 56;
 
-        if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-            continue;
-        }
+    if (l == v) {
+      ++signals;
+      break;
+    }
+  } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
+  alarm(0);
+  signal(SIGALRM, SIG_DFL);
 
-        char* cp = reinterpret_cast<char*>(&eventData->payload.data);
-        unsigned long long l = cp[0] & 0xFF;
-        l |= (unsigned long long) (cp[1] & 0xFF) << 8;
-        l |= (unsigned long long) (cp[2] & 0xFF) << 16;
-        l |= (unsigned long long) (cp[3] & 0xFF) << 24;
-        l |= (unsigned long long) (cp[4] & 0xFF) << 32;
-        l |= (unsigned long long) (cp[5] & 0xFF) << 40;
-        l |= (unsigned long long) (cp[6] & 0xFF) << 48;
-        l |= (unsigned long long) (cp[7] & 0xFF) << 56;
+  EXPECT_LE(1, count);
 
-        if (l == v) {
-            ++signals;
-            break;
-        }
-    } while (!signaled || (log_time(CLOCK_MONOTONIC) < signal_time));
-    alarm(0);
-    signal(SIGALRM, SIG_DFL);
+  EXPECT_EQ(1, signals);
 
-    EXPECT_LE(1, count);
+  android_logger_list_close(logger_list);
 
-    EXPECT_EQ(1, signals);
+  unsigned long long uticks_end;
+  unsigned long long sticks_end;
+  get_ticks(&uticks_end, &sticks_end);
 
-    android_logger_list_close(logger_list);
-
-    unsigned long long uticks_end;
-    unsigned long long sticks_end;
-    get_ticks(&uticks_end, &sticks_end);
-
-    // Less than 1% in either user or system time, or both
-    const unsigned long long one_percent_ticks = alarm_time;
-    unsigned long long user_ticks = uticks_end - uticks_start;
-    unsigned long long system_ticks = sticks_end - sticks_start;
-    EXPECT_GT(one_percent_ticks, user_ticks);
-    EXPECT_GT(one_percent_ticks, system_ticks);
-    EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
+  // Less than 1% in either user or system time, or both
+  const unsigned long long one_percent_ticks = alarm_time;
+  unsigned long long user_ticks = uticks_end - uticks_start;
+  unsigned long long system_ticks = sticks_end - sticks_start;
+  EXPECT_GT(one_percent_ticks, user_ticks);
+  EXPECT_GT(one_percent_ticks, system_ticks);
+  EXPECT_GT(one_percent_ticks, user_ticks + system_ticks);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // !USING_LOGGER_LOCAL
 
 #ifdef TEST_PREFIX
 static const char max_payload_tag[] = "TEST_max_payload_and_longish_tag_XXXX";
-#define SIZEOF_MAX_PAYLOAD_BUF (LOGGER_ENTRY_MAX_PAYLOAD - \
-                                sizeof(max_payload_tag) - 1)
+#define SIZEOF_MAX_PAYLOAD_BUF \
+  (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(max_payload_tag) - 1)
 #endif
-static const char max_payload_buf[] = "LEONATO\n\
+static const char max_payload_buf[] =
+    "LEONATO\n\
 I learn in this letter that Don Peter of Arragon\n\
 comes this night to Messina\n\
 MESSENGER\n\
@@ -1003,323 +1070,342 @@
 
 TEST(liblog, max_payload) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    pid_t pid = getpid();
-    char tag[sizeof(max_payload_tag)];
-    memcpy(tag, max_payload_tag, sizeof(tag));
-    snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
+  TEST_PREFIX
+  pid_t pid = getpid();
+  char tag[sizeof(max_payload_tag)];
+  memcpy(tag, max_payload_tag, sizeof(tag));
+  snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
 
-    LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
-                                              tag, max_payload_buf));
-    sleep(2);
+  LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
+                                            tag, max_payload_buf));
+  sleep(2);
 
-    struct logger_list *logger_list;
+  struct logger_list* logger_list;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_SYSTEM, ANDROID_LOG_RDONLY, 100, 0)));
+  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
+                           LOG_ID_SYSTEM, ANDROID_LOG_RDONLY, 100, 0)));
 
-    bool matches = false;
-    ssize_t max_len = 0;
+  bool matches = false;
+  ssize_t max_len = 0;
 
-    for(;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        if ((log_msg.entry.pid != pid) || (log_msg.id() != LOG_ID_SYSTEM)) {
-            continue;
-        }
-
-        char *data = log_msg.msg();
-
-        if (!data || strcmp(++data, tag)) {
-            continue;
-        }
-
-        data += strlen(data) + 1;
-
-        const char *left = data;
-        const char *right = max_payload_buf;
-        while (*left && *right && (*left == *right)) {
-            ++left;
-            ++right;
-        }
-
-        if (max_len <= (left - data)) {
-            max_len = left - data + 1;
-        }
-
-        if (max_len > 512) {
-            matches = true;
-            break;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    android_logger_list_close(logger_list);
+    if ((log_msg.entry.pid != pid) || (log_msg.id() != LOG_ID_SYSTEM)) {
+      continue;
+    }
 
-    EXPECT_EQ(true, matches);
+    char* data = log_msg.msg();
 
-    EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
+    if (!data || strcmp(++data, tag)) {
+      continue;
+    }
+
+    data += strlen(data) + 1;
+
+    const char* left = data;
+    const char* right = max_payload_buf;
+    while (*left && *right && (*left == *right)) {
+      ++left;
+      ++right;
+    }
+
+    if (max_len <= (left - data)) {
+      max_len = left - data + 1;
+    }
+
+    if (max_len > 512) {
+      matches = true;
+      break;
+    }
+  }
+
+  android_logger_list_close(logger_list);
+
+#if SUPPORTS_END_TO_END
+  EXPECT_EQ(true, matches);
+
+  EXPECT_LE(SIZEOF_MAX_PAYLOAD_BUF, static_cast<size_t>(max_len));
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  EXPECT_EQ(false, matches);
+#endif
+#else
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, __android_log_buf_print__maxtag) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    struct logger_list *logger_list;
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(
+      NULL !=
+      (logger_list = android_logger_list_open(
+           LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
 
 #ifdef __ANDROID__
-    log_time ts(android_log_clockid());
+  log_time ts(android_log_clockid());
 #else
-    log_time ts(CLOCK_REALTIME);
+  log_time ts(CLOCK_REALTIME);
 #endif
 
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                         max_payload_buf, max_payload_buf));
-    usleep(1000000);
+  EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
+                                       max_payload_buf, max_payload_buf));
+  usleep(1000000);
 
-    int count = 0;
+  int count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        ASSERT_EQ(log_msg.entry.pid, pid);
-
-        if ((log_msg.entry.sec < (ts.tv_sec - 1))
-         || ((ts.tv_sec + 1) < log_msg.entry.sec)
-         || ((size_t)log_msg.entry.len < LOGGER_ENTRY_MAX_PAYLOAD)
-         || (log_msg.id() != LOG_ID_MAIN)) {
-            continue;
-        }
-
-        ++count;
-
-        AndroidLogFormat *logformat = android_log_format_new();
-        EXPECT_TRUE(NULL != logformat);
-        AndroidLogEntry entry;
-        int processLogBuffer = android_log_processLogBuffer(&log_msg.entry_v1,
-                                                            &entry);
-        EXPECT_EQ(0, processLogBuffer);
-        if (processLogBuffer == 0) {
-            fflush(stderr);
-            int printLogLine =
-                    android_log_printLogLine(logformat, fileno(stderr), &entry);
-            // Legacy tag truncation
-            EXPECT_LE(128, printLogLine);
-            // Measured maximum if we try to print part of the tag as message
-            EXPECT_GT(LOGGER_ENTRY_MAX_PAYLOAD * 13 / 8, printLogLine);
-        }
-        android_log_format_free(logformat);
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    EXPECT_EQ(1, count);
+    ASSERT_EQ(log_msg.entry.pid, pid);
 
-    android_logger_list_close(logger_list);
+    if ((log_msg.entry.sec < (ts.tv_sec - 1)) ||
+        ((ts.tv_sec + 1) < log_msg.entry.sec) ||
+        ((size_t)log_msg.entry.len < LOGGER_ENTRY_MAX_PAYLOAD) ||
+        (log_msg.id() != LOG_ID_MAIN)) {
+      continue;
+    }
+
+    ++count;
+
+    AndroidLogFormat* logformat = android_log_format_new();
+    EXPECT_TRUE(NULL != logformat);
+    AndroidLogEntry entry;
+    int processLogBuffer =
+        android_log_processLogBuffer(&log_msg.entry_v1, &entry);
+    EXPECT_EQ(0, processLogBuffer);
+    if (processLogBuffer == 0) {
+      fflush(stderr);
+      int printLogLine =
+          android_log_printLogLine(logformat, fileno(stderr), &entry);
+      // Legacy tag truncation
+      EXPECT_LE(128, printLogLine);
+      // Measured maximum if we try to print part of the tag as message
+      EXPECT_GT(LOGGER_ENTRY_MAX_PAYLOAD * 13 / 8, printLogLine);
+    }
+    android_log_format_free(logformat);
+  }
+
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
+
+  android_logger_list_close(logger_list);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, too_big_payload) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    pid_t pid = getpid();
-    static const char big_payload_tag[] = "TEST_big_payload_XXXX";
-    char tag[sizeof(big_payload_tag)];
-    memcpy(tag, big_payload_tag, sizeof(tag));
-    snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
+  TEST_PREFIX
+  pid_t pid = getpid();
+  static const char big_payload_tag[] = "TEST_big_payload_XXXX";
+  char tag[sizeof(big_payload_tag)];
+  memcpy(tag, big_payload_tag, sizeof(tag));
+  snprintf(tag + sizeof(tag) - 5, 5, "%04X", pid & 0xFFFF);
 
-    std::string longString(3266519, 'x');
+  std::string longString(3266519, 'x');
 
-    ssize_t ret = LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_SYSTEM,
-                                    ANDROID_LOG_INFO, tag, longString.c_str()));
+  ssize_t ret = LOG_FAILURE_RETRY(__android_log_buf_write(
+      LOG_ID_SYSTEM, ANDROID_LOG_INFO, tag, longString.c_str()));
 
-    struct logger_list *logger_list;
+  struct logger_list* logger_list;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_SYSTEM, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 100, 0)));
+  ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
+                           LOG_ID_SYSTEM,
+                           ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 100, 0)));
 
-    ssize_t max_len = 0;
+  ssize_t max_len = 0;
 
-    for(;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        if ((log_msg.entry.pid != pid) || (log_msg.id() != LOG_ID_SYSTEM)) {
-            continue;
-        }
-
-        char *data = log_msg.msg();
-
-        if (!data || strcmp(++data, tag)) {
-            continue;
-        }
-
-        data += strlen(data) + 1;
-
-        const char *left = data;
-        const char *right = longString.c_str();
-        while (*left && *right && (*left == *right)) {
-            ++left;
-            ++right;
-        }
-
-        if (max_len <= (left - data)) {
-            max_len = left - data + 1;
-        }
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    android_logger_list_close(logger_list);
-
-    EXPECT_LE(LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag),
-              static_cast<size_t>(max_len));
-
-    // SLOP: Allow the underlying interface to optionally place a
-    // terminating nul at the LOGGER_ENTRY_MAX_PAYLOAD's last byte
-    // or not.
-    if (ret == (max_len + static_cast<ssize_t>(sizeof(big_payload_tag)) - 1)) {
-        --max_len;
+    if ((log_msg.entry.pid != pid) || (log_msg.id() != LOG_ID_SYSTEM)) {
+      continue;
     }
-    EXPECT_EQ(ret, max_len + static_cast<ssize_t>(sizeof(big_payload_tag)));
+
+    char* data = log_msg.msg();
+
+    if (!data || strcmp(++data, tag)) {
+      continue;
+    }
+
+    data += strlen(data) + 1;
+
+    const char* left = data;
+    const char* right = longString.c_str();
+    while (*left && *right && (*left == *right)) {
+      ++left;
+      ++right;
+    }
+
+    if (max_len <= (left - data)) {
+      max_len = left - data + 1;
+    }
+  }
+
+  android_logger_list_close(logger_list);
+
+#if !SUPPORTS_END_TO_END
+  max_len =
+      max_len ? max_len : LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag);
+#endif
+  EXPECT_LE(LOGGER_ENTRY_MAX_PAYLOAD - sizeof(big_payload_tag),
+            static_cast<size_t>(max_len));
+
+  // SLOP: Allow the underlying interface to optionally place a
+  // terminating nul at the LOGGER_ENTRY_MAX_PAYLOAD's last byte
+  // or not.
+  if (ret == (max_len + static_cast<ssize_t>(sizeof(big_payload_tag)) - 1)) {
+    --max_len;
+  }
+  EXPECT_EQ(ret, max_len + static_cast<ssize_t>(sizeof(big_payload_tag)));
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, dual_reader) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
+  TEST_PREFIX
 
-    static const int num = 25;
+  static const int num = 25;
 
-    for (int i = 25; i > 0; --i) {
-        static const char fmt[] = "dual_reader %02d";
-        char buffer[sizeof(fmt) + 8];
-        snprintf(buffer, sizeof(buffer), fmt, i);
-        LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_MAIN,
-                                                  ANDROID_LOG_INFO,
-                                                  "liblog", buffer));
-    }
-    usleep(1000000);
+  for (int i = 25; i > 0; --i) {
+    static const char fmt[] = "dual_reader %02d";
+    char buffer[sizeof(fmt) + 8];
+    snprintf(buffer, sizeof(buffer), fmt, i);
+    LOG_FAILURE_RETRY(__android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
+                                              "liblog", buffer));
+  }
+  usleep(1000000);
 
-    struct logger_list *logger_list1;
-    ASSERT_TRUE(NULL != (logger_list1 = android_logger_list_open(
-        LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, num, 0)));
+  struct logger_list* logger_list1;
+  ASSERT_TRUE(NULL != (logger_list1 = android_logger_list_open(
+                           LOG_ID_MAIN,
+                           ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, num, 0)));
 
-    struct logger_list *logger_list2;
+  struct logger_list* logger_list2;
 
-    if (NULL == (logger_list2 = android_logger_list_open(
-            LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, num - 10, 0))) {
-        android_logger_list_close(logger_list1);
-        ASSERT_TRUE(NULL != logger_list2);
-    }
-
-    int count1 = 0;
-    bool done1 = false;
-    int count2 = 0;
-    bool done2 = false;
-
-    do {
-        log_msg log_msg;
-
-        if (!done1) {
-            if (android_logger_list_read(logger_list1, &log_msg) <= 0) {
-                done1 = true;
-            } else {
-                ++count1;
-            }
-        }
-
-        if (!done2) {
-            if (android_logger_list_read(logger_list2, &log_msg) <= 0) {
-                done2 = true;
-            } else {
-                ++count2;
-            }
-        }
-    } while ((!done1) || (!done2));
-
+  if (NULL == (logger_list2 = android_logger_list_open(
+                   LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   num - 10, 0))) {
     android_logger_list_close(logger_list1);
-    android_logger_list_close(logger_list2);
+    ASSERT_TRUE(NULL != logger_list2);
+  }
 
-    EXPECT_EQ(num, count1);
-    EXPECT_EQ(num - 10, count2);
+  int count1 = 0;
+  bool done1 = false;
+  int count2 = 0;
+  bool done2 = false;
+
+  do {
+    log_msg log_msg;
+
+    if (!done1) {
+      if (android_logger_list_read(logger_list1, &log_msg) <= 0) {
+        done1 = true;
+      } else {
+        ++count1;
+      }
+    }
+
+    if (!done2) {
+      if (android_logger_list_read(logger_list2, &log_msg) <= 0) {
+        done2 = true;
+      } else {
+        ++count2;
+      }
+    }
+  } while ((!done1) || (!done2));
+
+  android_logger_list_close(logger_list1);
+  android_logger_list_close(logger_list2);
+
+  EXPECT_EQ(num * SUPPORTS_END_TO_END, count1);
+  EXPECT_EQ((num - 10) * SUPPORTS_END_TO_END, count2);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-#ifndef USING_LOGGER_LOCAL // Do not retest logprint
-static bool checkPriForTag(AndroidLogFormat *p_format, const char *tag, android_LogPriority pri) {
-    return android_log_shouldPrintLine(p_format, tag, pri)
-        && !android_log_shouldPrintLine(p_format, tag, (android_LogPriority)(pri - 1));
+#ifdef USING_LOGGER_DEFAULT  // Do not retest logprint
+static bool checkPriForTag(AndroidLogFormat* p_format, const char* tag,
+                           android_LogPriority pri) {
+  return android_log_shouldPrintLine(p_format, tag, pri) &&
+         !android_log_shouldPrintLine(p_format, tag,
+                                      (android_LogPriority)(pri - 1));
 }
 
 TEST(liblog, filterRule) {
-    static const char tag[] = "random";
+  static const char tag[] = "random";
 
-    AndroidLogFormat *p_format = android_log_format_new();
+  AndroidLogFormat* p_format = android_log_format_new();
 
-    android_log_addFilterRule(p_format,"*:i");
+  android_log_addFilterRule(p_format, "*:i");
 
-    EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) == 0);
-    android_log_addFilterRule(p_format, "*");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-    android_log_addFilterRule(p_format, "*:v");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-    android_log_addFilterRule(p_format, "*:i");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) == 0);
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
+              0);
+  android_log_addFilterRule(p_format, "*");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
+  android_log_addFilterRule(p_format, "*:v");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
+  android_log_addFilterRule(p_format, "*:i");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_INFO));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
+              0);
 
-    android_log_addFilterRule(p_format, tag);
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-    android_log_addFilterRule(p_format, "random:v");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-    android_log_addFilterRule(p_format, "random:d");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
-    android_log_addFilterRule(p_format, "random:w");
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) == 0);
+  android_log_addFilterRule(p_format, tag);
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
+  android_log_addFilterRule(p_format, "random:v");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_VERBOSE));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
+  android_log_addFilterRule(p_format, "random:d");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) > 0);
+  android_log_addFilterRule(p_format, "random:w");
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
+              0);
 
-    android_log_addFilterRule(p_format, "crap:*");
-    EXPECT_TRUE (checkPriForTag(p_format, "crap", ANDROID_LOG_VERBOSE));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, "crap", ANDROID_LOG_VERBOSE) > 0);
+  android_log_addFilterRule(p_format, "crap:*");
+  EXPECT_TRUE(checkPriForTag(p_format, "crap", ANDROID_LOG_VERBOSE));
+  EXPECT_TRUE(
+      android_log_shouldPrintLine(p_format, "crap", ANDROID_LOG_VERBOSE) > 0);
 
-    // invalid expression
-    EXPECT_TRUE (android_log_addFilterRule(p_format, "random:z") < 0);
-    EXPECT_TRUE (checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
-    EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) == 0);
+  // invalid expression
+  EXPECT_TRUE(android_log_addFilterRule(p_format, "random:z") < 0);
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
+  EXPECT_TRUE(android_log_shouldPrintLine(p_format, tag, ANDROID_LOG_DEBUG) ==
+              0);
 
-    // Issue #550946
-    EXPECT_TRUE(android_log_addFilterString(p_format, " ") == 0);
-    EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
+  // Issue #550946
+  EXPECT_TRUE(android_log_addFilterString(p_format, " ") == 0);
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_WARN));
 
-    // note trailing space
-    EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:d ") == 0);
-    EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
+  // note trailing space
+  EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:d ") == 0);
+  EXPECT_TRUE(checkPriForTag(p_format, tag, ANDROID_LOG_DEBUG));
 
-    EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:z") < 0);
+  EXPECT_TRUE(android_log_addFilterString(p_format, "*:s random:z") < 0);
 
-#if 0 // bitrot, seek update
+#if 0  // bitrot, seek update
     char defaultBuffer[512];
 
     android_log_formatLogLine(p_format,
@@ -1329,1790 +1415,1811 @@
     fprintf(stderr, "%s\n", defaultBuffer);
 #endif
 
-    android_log_format_free(p_format);
+  android_log_format_free(p_format);
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
-#ifndef USING_LOGGER_LOCAL // Do not retest property handling
+#ifdef USING_LOGGER_DEFAULT  // Do not retest property handling
 TEST(liblog, is_loggable) {
 #ifdef __ANDROID__
-    static const char tag[] = "is_loggable";
-    static const char log_namespace[] = "persist.log.tag.";
-    static const size_t base_offset = 8; /* skip "persist." */
-    // sizeof("string") = strlen("string") + 1
-    char key[sizeof(log_namespace) + sizeof(tag) - 1];
-    char hold[4][PROP_VALUE_MAX];
-    static const struct {
-        int level;
-        char type;
-    } levels[] = {
-        { ANDROID_LOG_VERBOSE, 'v' },
-        { ANDROID_LOG_DEBUG  , 'd' },
-        { ANDROID_LOG_INFO   , 'i' },
-        { ANDROID_LOG_WARN   , 'w' },
-        { ANDROID_LOG_ERROR  , 'e' },
-        { ANDROID_LOG_FATAL  , 'a' },
-        { -1                 , 's' },
-        { -2                 , 'g' }, // Illegal value, resort to default
-    };
+  static const char tag[] = "is_loggable";
+  static const char log_namespace[] = "persist.log.tag.";
+  static const size_t base_offset = 8; /* skip "persist." */
+  // sizeof("string") = strlen("string") + 1
+  char key[sizeof(log_namespace) + sizeof(tag) - 1];
+  char hold[4][PROP_VALUE_MAX];
+  static const struct {
+    int level;
+    char type;
+  } levels[] = {
+    { ANDROID_LOG_VERBOSE, 'v' },
+    { ANDROID_LOG_DEBUG, 'd' },
+    { ANDROID_LOG_INFO, 'i' },
+    { ANDROID_LOG_WARN, 'w' },
+    { ANDROID_LOG_ERROR, 'e' },
+    { ANDROID_LOG_FATAL, 'a' },
+    { -1, 's' },
+    { -2, 'g' },  // Illegal value, resort to default
+  };
 
-    // Set up initial test condition
-    memset(hold, 0, sizeof(hold));
-    snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-    property_get(key, hold[0], "");
-    property_set(key, "");
-    property_get(key + base_offset, hold[1], "");
-    property_set(key + base_offset, "");
-    strcpy(key, log_namespace);
-    key[sizeof(log_namespace) - 2] = '\0';
-    property_get(key, hold[2], "");
-    property_set(key, "");
-    property_get(key, hold[3], "");
-    property_set(key + base_offset, "");
+  // Set up initial test condition
+  memset(hold, 0, sizeof(hold));
+  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
+  property_get(key, hold[0], "");
+  property_set(key, "");
+  property_get(key + base_offset, hold[1], "");
+  property_set(key + base_offset, "");
+  strcpy(key, log_namespace);
+  key[sizeof(log_namespace) - 2] = '\0';
+  property_get(key, hold[2], "");
+  property_set(key, "");
+  property_get(key, hold[3], "");
+  property_set(key + base_offset, "");
 
-    // All combinations of level and defaults
-    for(size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-        if (levels[i].level == -2) {
-            continue;
-        }
-        for(size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-            if (levels[j].level == -2) {
-                continue;
-            }
-            fprintf(stderr, "i=%zu j=%zu\r", i, j);
-            bool android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), levels[j].level);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), levels[j].level));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), levels[j].level));
-                }
-            }
-        }
+  // All combinations of level and defaults
+  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
+    if (levels[i].level == -2) {
+      continue;
     }
-
-    // All combinations of level and tag and global properties
-    for(size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-        if (levels[i].level == -2) {
-            continue;
+    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
+      if (levels[j].level == -2) {
+        continue;
+      }
+      fprintf(stderr, "i=%zu j=%zu\r", i, j);
+      bool android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), levels[j].level);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1)) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
         }
-        for(size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-            char buf[2];
-            buf[0] = levels[j].type;
-            buf[1] = '\0';
-
-            snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key, buf);
-            usleep(20000);
-            property_set(key, buf);
-            bool android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_DEBUG)
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key, "");
-
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key + base_offset, buf);
-            property_set(key + base_offset, buf);
-            android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_DEBUG)
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key + base_offset, "");
-
-            strcpy(key, log_namespace);
-            key[sizeof(log_namespace) - 2] = '\0';
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key, buf);
-            property_set(key, buf);
-            android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_DEBUG)
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key, "");
-
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key + base_offset, buf);
-            property_set(key + base_offset, buf);
-            android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_DEBUG)
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key + base_offset, "");
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), levels[j].level));
         }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), levels[j].level));
+        }
+      }
     }
+  }
 
-    // All combinations of level and tag properties, but with global set to INFO
-    strcpy(key, log_namespace);
-    key[sizeof(log_namespace) - 2] = '\0';
-    usleep(20000);
-    property_set(key, "I");
-    snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-    for(size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
-        if (levels[i].level == -2) {
-            continue;
-        }
-        for(size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
-            char buf[2];
-            buf[0] = levels[j].type;
-            buf[1] = '\0';
-
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key, buf);
-            usleep(20000);
-            property_set(key, buf);
-            bool android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_INFO) // Yes INFO
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key, "");
-
-            fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r",
-                    i, j, key + base_offset, buf);
-            property_set(key + base_offset, buf);
-            android_log_is_loggable = __android_log_is_loggable_len(
-                levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
-            if ((levels[i].level < levels[j].level)
-                    || (levels[j].level == -1)
-                    || ((levels[i].level < ANDROID_LOG_INFO) // Yes INFO
-                        && (levels[j].level == -2))) {
-                if (android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_FALSE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_FALSE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            } else {
-                if (!android_log_is_loggable) {
-                    fprintf(stderr, "\n");
-                }
-                EXPECT_TRUE(android_log_is_loggable);
-                for(size_t k = 10; k; --k) {
-                    EXPECT_TRUE(__android_log_is_loggable_len(
-                        levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
-                }
-            }
-            usleep(20000);
-            property_set(key + base_offset, "");
-        }
+  // All combinations of level and tag and global properties
+  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
+    if (levels[i].level == -2) {
+      continue;
     }
+    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
+      char buf[2];
+      buf[0] = levels[j].type;
+      buf[1] = '\0';
 
-    // reset parms
-    snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
-    usleep(20000);
-    property_set(key, hold[0]);
-    property_set(key + base_offset, hold[1]);
-    strcpy(key, log_namespace);
-    key[sizeof(log_namespace) - 2] = '\0';
-    property_set(key, hold[2]);
-    property_set(key + base_offset, hold[3]);
+      snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
+              buf);
+      usleep(20000);
+      property_set(key, buf);
+      bool android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key, "");
+
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
+              key + base_offset, buf);
+      property_set(key + base_offset, buf);
+      android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key + base_offset, "");
+
+      strcpy(key, log_namespace);
+      key[sizeof(log_namespace) - 2] = '\0';
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
+              buf);
+      property_set(key, buf);
+      android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key, "");
+
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
+              key + base_offset, buf);
+      property_set(key + base_offset, buf);
+      android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_DEBUG) && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key + base_offset, "");
+    }
+  }
+
+  // All combinations of level and tag properties, but with global set to INFO
+  strcpy(key, log_namespace);
+  key[sizeof(log_namespace) - 2] = '\0';
+  usleep(20000);
+  property_set(key, "I");
+  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
+  for (size_t i = 0; i < (sizeof(levels) / sizeof(levels[0])); ++i) {
+    if (levels[i].level == -2) {
+      continue;
+    }
+    for (size_t j = 0; j < (sizeof(levels) / sizeof(levels[0])); ++j) {
+      char buf[2];
+      buf[0] = levels[j].type;
+      buf[1] = '\0';
+
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j, key,
+              buf);
+      usleep(20000);
+      property_set(key, buf);
+      bool android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_INFO)  // Yes INFO
+           && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key, "");
+
+      fprintf(stderr, "i=%zu j=%zu property_set(\"%s\",\"%s\")\r", i, j,
+              key + base_offset, buf);
+      property_set(key + base_offset, buf);
+      android_log_is_loggable = __android_log_is_loggable_len(
+          levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG);
+      if ((levels[i].level < levels[j].level) || (levels[j].level == -1) ||
+          ((levels[i].level < ANDROID_LOG_INFO)  // Yes INFO
+           && (levels[j].level == -2))) {
+        if (android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_FALSE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_FALSE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      } else {
+        if (!android_log_is_loggable) {
+          fprintf(stderr, "\n");
+        }
+        EXPECT_TRUE(android_log_is_loggable);
+        for (size_t k = 10; k; --k) {
+          EXPECT_TRUE(__android_log_is_loggable_len(
+              levels[i].level, tag, strlen(tag), ANDROID_LOG_DEBUG));
+        }
+      }
+      usleep(20000);
+      property_set(key + base_offset, "");
+    }
+  }
+
+  // reset parms
+  snprintf(key, sizeof(key), "%s%s", log_namespace, tag);
+  usleep(20000);
+  property_set(key, hold[0]);
+  property_set(key + base_offset, hold[1]);
+  strcpy(key, log_namespace);
+  key[sizeof(log_namespace) - 2] = '\0';
+  property_set(key, hold[2]);
+  property_set(key + base_offset, hold[3]);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
 // Following tests the specific issues surrounding error handling wrt logd.
 // Kills logd and toss all collected data, equivalent to logcat -b all -c,
 // except we also return errors to the logging callers.
-#ifndef USING_LOGGER_LOCAL
+#ifdef USING_LOGGER_DEFAULT
 #ifdef TEST_PREFIX
 // helper to liblog.enoent to count end-to-end matching logging messages.
 static int count_matching_ts(log_time ts) {
-    usleep(1000000);
+  usleep(1000000);
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    struct logger_list* logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid);
+  struct logger_list* logger_list = android_logger_list_open(
+      LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid);
 
-    int count = 0;
-    if (logger_list == NULL) return count;
+  int count = 0;
+  if (logger_list == NULL) return count;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
 
-        if (log_msg.entry.len != sizeof(android_log_event_long_t)) continue;
-        if (log_msg.id() != LOG_ID_EVENTS) continue;
+    if (log_msg.entry.len != sizeof(android_log_event_long_t)) continue;
+    if (log_msg.id() != LOG_ID_EVENTS) continue;
 
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
-        if (!eventData) continue;
-        if (eventData->payload.type != EVENT_TYPE_LONG) continue;
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+    if (!eventData) continue;
+    if (eventData->payload.type != EVENT_TYPE_LONG) continue;
 
-        log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-        if (ts != tx) continue;
+    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
+    if (ts != tx) continue;
 
-        // found event message with matching timestamp signature in payload
-        ++count;
-    }
-    android_logger_list_close(logger_list);
+    // found event message with matching timestamp signature in payload
+    ++count;
+  }
+  android_logger_list_close(logger_list);
 
-    return count;
+  return count;
 }
 
 // meant to be handed to ASSERT_TRUE / EXPECT_TRUE only to expand the message
-static testing::AssertionResult IsOk(bool ok, std::string &message) {
-    return ok ?
-        testing::AssertionSuccess() :
-        (testing::AssertionFailure() << message);
+static testing::AssertionResult IsOk(bool ok, std::string& message) {
+  return ok ? testing::AssertionSuccess()
+            : (testing::AssertionFailure() << message);
 }
-#endif // TEST_PREFIX
+#endif  // TEST_PREFIX
 
 TEST(liblog, enoent) {
 #ifdef TEST_PREFIX
-    TEST_PREFIX
-    log_time ts(CLOCK_MONOTONIC);
-    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-    EXPECT_EQ(1, count_matching_ts(ts));
+  TEST_PREFIX
+  log_time ts(CLOCK_MONOTONIC);
+  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+  EXPECT_EQ(SUPPORTS_END_TO_END, count_matching_ts(ts));
 
-    // This call will fail if we are setuid(AID_SYSTEM), beware of any
-    // test prior to this one playing with setuid and causing interference.
-    // We need to run before these tests so that they do not interfere with
-    // this test.
-    //
-    // Stopping the logger can affect some other test's expectations as they
-    // count on the log buffers filled with existing content, and this
-    // effectively does a logcat -c emptying it.  So we want this test to be
-    // as near as possible to the bottom of the file.  For example
-    // liblog.android_logger_get_ is one of those tests that has no recourse
-    // and that would be adversely affected by emptying the log if it was run
-    // right after this test.
-    system("stop logd");
-    usleep(1000000);
+  // This call will fail if we are setuid(AID_SYSTEM), beware of any
+  // test prior to this one playing with setuid and causing interference.
+  // We need to run before these tests so that they do not interfere with
+  // this test.
+  //
+  // Stopping the logger can affect some other test's expectations as they
+  // count on the log buffers filled with existing content, and this
+  // effectively does a logcat -c emptying it.  So we want this test to be
+  // as near as possible to the bottom of the file.  For example
+  // liblog.android_logger_get_ is one of those tests that has no recourse
+  // and that would be adversely affected by emptying the log if it was run
+  // right after this test.
+  system("stop logd");
+  usleep(1000000);
 
-    // A clean stop like we are testing returns -ENOENT, but in the _real_
-    // world we could get -ENOTCONN or -ECONNREFUSED depending on timing.
-    // Alas we can not test these other return values; accept that they
-    // are treated equally within the open-retry logic in liblog.
-    ts = log_time(CLOCK_MONOTONIC);
-    int ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
-    std::string content = android::base::StringPrintf(
-        "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
-        ret, strerror(-ret));
-    EXPECT_TRUE(IsOk((ret == -ENOENT) ||
-                     (ret == -ENOTCONN) ||
-                     (ret == -ECONNREFUSED), content));
-    ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
-    content = android::base::StringPrintf(
-        "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
-        ret, strerror(-ret));
-    EXPECT_TRUE(IsOk((ret == -ENOENT) ||
-                     (ret == -ENOTCONN) ||
-                     (ret == -ECONNREFUSED), content));
-    EXPECT_EQ(0, count_matching_ts(ts));
+  // A clean stop like we are testing returns -ENOENT, but in the _real_
+  // world we could get -ENOTCONN or -ECONNREFUSED depending on timing.
+  // Alas we can not test these other return values; accept that they
+  // are treated equally within the open-retry logic in liblog.
+  ts = log_time(CLOCK_MONOTONIC);
+  int ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
+  std::string content = android::base::StringPrintf(
+      "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
+      ret, strerror(-ret));
+  EXPECT_TRUE(
+      IsOk((ret == -ENOENT) || (ret == -ENOTCONN) || (ret == -ECONNREFUSED),
+           content));
+  ret = __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts));
+  content = android::base::StringPrintf(
+      "__android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)) = %d %s\n",
+      ret, strerror(-ret));
+  EXPECT_TRUE(
+      IsOk((ret == -ENOENT) || (ret == -ENOTCONN) || (ret == -ECONNREFUSED),
+           content));
+  EXPECT_EQ(0, count_matching_ts(ts));
 
-    system("start logd");
-    usleep(1000000);
+  system("start logd");
+  usleep(1000000);
 
-    EXPECT_EQ(0, count_matching_ts(ts));
+  EXPECT_EQ(0, count_matching_ts(ts));
 
-    ts = log_time(CLOCK_MONOTONIC);
-    EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
-    EXPECT_EQ(1, count_matching_ts(ts));
+  ts = log_time(CLOCK_MONOTONIC);
+  EXPECT_LT(0, __android_log_btwrite(0, EVENT_TYPE_LONG, &ts, sizeof(ts)));
+  EXPECT_EQ(SUPPORTS_END_TO_END, count_matching_ts(ts));
 
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOCAL_LOGGER
+#endif  // USING_LOCAL_LOGD
 
 // Below this point we run risks of setuid(AID_SYSTEM) which may affect others.
 
 // Do not retest properties, and cannot log into LOG_ID_SECURITY
-#ifndef USING_LOGGER_LOCAL
+#ifdef USING_LOGGER_DEFAULT
 TEST(liblog, __security) {
 #ifdef __ANDROID__
-    static const char persist_key[] = "persist.logd.security";
-    static const char readonly_key[] = "ro.device_owner";
-    // A silly default value that can never be in readonly_key so
-    // that it can be determined the property is not set.
-    static const char nothing_val[] = "_NOTHING_TO_SEE_HERE_";
-    char persist[PROP_VALUE_MAX];
-    char readonly[PROP_VALUE_MAX];
+  static const char persist_key[] = "persist.logd.security";
+  static const char readonly_key[] = "ro.device_owner";
+  // A silly default value that can never be in readonly_key so
+  // that it can be determined the property is not set.
+  static const char nothing_val[] = "_NOTHING_TO_SEE_HERE_";
+  char persist[PROP_VALUE_MAX];
+  char readonly[PROP_VALUE_MAX];
 
-    property_get(persist_key, persist, "");
-    property_get(readonly_key, readonly, nothing_val);
+  property_get(persist_key, persist, "");
+  property_get(readonly_key, readonly, nothing_val);
 
-    if (!strcmp(readonly, nothing_val)) {
-        EXPECT_FALSE(__android_log_security());
-        fprintf(stderr, "Warning, setting ro.device_owner to a domain\n");
-        property_set(readonly_key, "com.google.android.SecOps.DeviceOwner");
-    } else if (!strcasecmp(readonly, "false") || !readonly[0]) {
-        EXPECT_FALSE(__android_log_security());
-        return;
-    }
+  if (!strcmp(readonly, nothing_val)) {
+    EXPECT_FALSE(__android_log_security());
+    fprintf(stderr, "Warning, setting ro.device_owner to a domain\n");
+    property_set(readonly_key, "com.google.android.SecOps.DeviceOwner");
+  } else if (!strcasecmp(readonly, "false") || !readonly[0]) {
+    EXPECT_FALSE(__android_log_security());
+    return;
+  }
 
-    if (!strcasecmp(persist, "true")) {
-        EXPECT_TRUE(__android_log_security());
-    } else {
-        EXPECT_FALSE(__android_log_security());
-    }
-    property_set(persist_key, "TRUE");
+  if (!strcasecmp(persist, "true")) {
     EXPECT_TRUE(__android_log_security());
-    property_set(persist_key, "FALSE");
+  } else {
     EXPECT_FALSE(__android_log_security());
-    property_set(persist_key, "true");
-    EXPECT_TRUE(__android_log_security());
-    property_set(persist_key, "false");
-    EXPECT_FALSE(__android_log_security());
-    property_set(persist_key, "");
-    EXPECT_FALSE(__android_log_security());
-    property_set(persist_key, persist);
+  }
+  property_set(persist_key, "TRUE");
+  EXPECT_TRUE(__android_log_security());
+  property_set(persist_key, "FALSE");
+  EXPECT_FALSE(__android_log_security());
+  property_set(persist_key, "true");
+  EXPECT_TRUE(__android_log_security());
+  property_set(persist_key, "false");
+  EXPECT_FALSE(__android_log_security());
+  property_set(persist_key, "");
+  EXPECT_FALSE(__android_log_security());
+  property_set(persist_key, persist);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, __security_buffer) {
 #ifdef __ANDROID__
-    struct logger_list *logger_list;
-    android_event_long_t buffer;
+  struct logger_list* logger_list;
+  android_event_long_t buffer;
 
-    static const char persist_key[] = "persist.logd.security";
-    char persist[PROP_VALUE_MAX];
-    bool set_persist = false;
-    bool allow_security = false;
+  static const char persist_key[] = "persist.logd.security";
+  char persist[PROP_VALUE_MAX];
+  bool set_persist = false;
+  bool allow_security = false;
 
-    if (__android_log_security()) {
+  if (__android_log_security()) {
+    allow_security = true;
+  } else {
+    property_get(persist_key, persist, "");
+    if (strcasecmp(persist, "true")) {
+      property_set(persist_key, "TRUE");
+      if (__android_log_security()) {
         allow_security = true;
-    } else {
-        property_get(persist_key, persist, "");
-        if (strcasecmp(persist, "true")) {
-            property_set(persist_key, "TRUE");
-            if (__android_log_security()) {
-                allow_security = true;
-                set_persist = true;
-            } else {
-                property_set(persist_key, persist);
-            }
-        }
+        set_persist = true;
+      } else {
+        property_set(persist_key, persist);
+      }
     }
+  }
 
-    if (!allow_security) {
-        fprintf(stderr, "WARNING: "
-                "security buffer disabled, bypassing end-to-end test\n");
-
-        log_time ts(CLOCK_MONOTONIC);
-
-        buffer.type = EVENT_TYPE_LONG;
-        buffer.data = *(static_cast<uint64_t *>((void *)&ts));
-
-        // expect failure!
-        ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-
-        return;
-    }
-
-    /* Matches clientHasLogCredentials() in logd */
-    uid_t uid = getuid();
-    gid_t gid = getgid();
-    bool clientHasLogCredentials = true;
-    if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG)
-     && (gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
-        uid_t euid = geteuid();
-        if ((euid != AID_SYSTEM) && (euid != AID_ROOT) && (euid != AID_LOG)) {
-            gid_t egid = getegid();
-            if ((egid != AID_SYSTEM) && (egid != AID_ROOT) && (egid != AID_LOG)) {
-                int num_groups = getgroups(0, NULL);
-                if (num_groups > 0) {
-                    gid_t groups[num_groups];
-                    num_groups = getgroups(num_groups, groups);
-                    while (num_groups > 0) {
-                        if (groups[num_groups - 1] == AID_LOG) {
-                            break;
-                        }
-                        --num_groups;
-                    }
-                }
-                if (num_groups <= 0) {
-                    clientHasLogCredentials = false;
-                }
-            }
-        }
-    }
-    if (!clientHasLogCredentials) {
-        fprintf(stderr, "WARNING: "
-                "not in system context, bypassing end-to-end test\n");
-
-        log_time ts(CLOCK_MONOTONIC);
-
-        buffer.type = EVENT_TYPE_LONG;
-        buffer.data = *(static_cast<uint64_t *>((void *)&ts));
-
-        // expect failure!
-        ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-
-        return;
-    }
-
-    EXPECT_EQ(0, setuid(AID_SYSTEM)); // only one that can read security buffer
-
-    pid_t pid = getpid();
-
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_SECURITY, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
-        1000, pid)));
+  if (!allow_security) {
+    fprintf(stderr,
+            "WARNING: "
+            "security buffer disabled, bypassing end-to-end test\n");
 
     log_time ts(CLOCK_MONOTONIC);
 
     buffer.type = EVENT_TYPE_LONG;
-    buffer.data = *(static_cast<uint64_t *>((void *)&ts));
+    buffer.data = *(static_cast<uint64_t*>((void*)&ts));
 
-    ASSERT_LT(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
-    usleep(1000000);
+    // expect failure!
+    ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
 
-    int count = 0;
+    return;
+  }
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
+  /* Matches clientHasLogCredentials() in logd */
+  uid_t uid = getuid();
+  gid_t gid = getgid();
+  bool clientHasLogCredentials = true;
+  if ((uid != AID_SYSTEM) && (uid != AID_ROOT) && (uid != AID_LOG) &&
+      (gid != AID_SYSTEM) && (gid != AID_ROOT) && (gid != AID_LOG)) {
+    uid_t euid = geteuid();
+    if ((euid != AID_SYSTEM) && (euid != AID_ROOT) && (euid != AID_LOG)) {
+      gid_t egid = getegid();
+      if ((egid != AID_SYSTEM) && (egid != AID_ROOT) && (egid != AID_LOG)) {
+        int num_groups = getgroups(0, NULL);
+        if (num_groups > 0) {
+          gid_t groups[num_groups];
+          num_groups = getgroups(num_groups, groups);
+          while (num_groups > 0) {
+            if (groups[num_groups - 1] == AID_LOG) {
+              break;
+            }
+            --num_groups;
+          }
         }
-
-        ASSERT_EQ(log_msg.entry.pid, pid);
-
-        if ((log_msg.entry.len != sizeof(android_log_event_long_t))
-         || (log_msg.id() != LOG_ID_SECURITY)) {
-            continue;
+        if (num_groups <= 0) {
+          clientHasLogCredentials = false;
         }
+      }
+    }
+  }
+  if (!clientHasLogCredentials) {
+    fprintf(stderr,
+            "WARNING: "
+            "not in system context, bypassing end-to-end test\n");
 
-        android_log_event_long_t* eventData;
-        eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
+    log_time ts(CLOCK_MONOTONIC);
 
-        if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
-            continue;
-        }
+    buffer.type = EVENT_TYPE_LONG;
+    buffer.data = *(static_cast<uint64_t*>((void*)&ts));
 
-        log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
-        if (ts == tx) {
-            ++count;
-        }
+    // expect failure!
+    ASSERT_GE(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
+
+    return;
+  }
+
+  EXPECT_EQ(0, setuid(AID_SYSTEM));  // only one that can read security buffer
+
+  pid_t pid = getpid();
+
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_SECURITY, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
+
+  log_time ts(CLOCK_MONOTONIC);
+
+  buffer.type = EVENT_TYPE_LONG;
+  buffer.data = *(static_cast<uint64_t*>((void*)&ts));
+
+  ASSERT_LT(0, __android_log_security_bwrite(0, &buffer, sizeof(buffer)));
+  usleep(1000000);
+
+  int count = 0;
+
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    if (set_persist) {
-        property_set(persist_key, persist);
+    ASSERT_EQ(log_msg.entry.pid, pid);
+
+    if ((log_msg.entry.len != sizeof(android_log_event_long_t)) ||
+        (log_msg.id() != LOG_ID_SECURITY)) {
+      continue;
     }
 
-    android_logger_list_close(logger_list);
+    android_log_event_long_t* eventData;
+    eventData = reinterpret_cast<android_log_event_long_t*>(log_msg.msg());
 
-    bool clientHasSecurityCredentials = (uid == AID_SYSTEM) || (gid == AID_SYSTEM);
-    if (!clientHasSecurityCredentials) {
-        fprintf(stderr, "WARNING: "
-                "not system, content submitted but can not check end-to-end\n");
+    if (!eventData || (eventData->payload.type != EVENT_TYPE_LONG)) {
+      continue;
     }
-    EXPECT_EQ(clientHasSecurityCredentials ? 1 : 0, count);
+
+    log_time tx(reinterpret_cast<char*>(&eventData->payload.data));
+    if (ts == tx) {
+      ++count;
+    }
+  }
+
+  if (set_persist) {
+    property_set(persist_key, persist);
+  }
+
+  android_logger_list_close(logger_list);
+
+  bool clientHasSecurityCredentials = (uid == AID_SYSTEM) || (gid == AID_SYSTEM);
+  if (!clientHasSecurityCredentials) {
+    fprintf(stderr,
+            "WARNING: "
+            "not system, content submitted but can not check end-to-end\n");
+  }
+  EXPECT_EQ(clientHasSecurityCredentials ? 1 : 0, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
 #ifdef TEST_PREFIX
 static void android_errorWriteWithInfoLog_helper(int TAG, const char* SUBTAG,
                                                  int UID, const char* payload,
                                                  int DATA_LEN, int& count) {
-    TEST_PREFIX
-    struct logger_list *logger_list;
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    count = 0;
+  count = 0;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
-    int retval_android_errorWriteWithinInfoLog = android_errorWriteWithInfoLog(
-            TAG, SUBTAG, UID, payload, DATA_LEN);
-    if (payload) {
-        ASSERT_LT(0, retval_android_errorWriteWithinInfoLog);
-    } else {
-        ASSERT_GT(0, retval_android_errorWriteWithinInfoLog);
+  int retval_android_errorWriteWithinInfoLog =
+      android_errorWriteWithInfoLog(TAG, SUBTAG, UID, payload, DATA_LEN);
+  if (payload) {
+    ASSERT_LT(0, retval_android_errorWriteWithinInfoLog);
+  } else {
+    ASSERT_GT(0, retval_android_errorWriteWithinInfoLog);
+  }
+
+  sleep(2);
+
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    sleep(2);
-
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        char *eventData = log_msg.msg();
-        if (!eventData) {
-            continue;
-        }
-
-        char *original = eventData;
-
-        // Tag
-        int tag = get4LE(eventData);
-        eventData += 4;
-
-        if (tag != TAG) {
-            continue;
-        }
-
-        if (!payload) {
-            // This tag should not have been written because the data was null
-            ++count;
-            break;
-        }
-
-        // List type
-        ASSERT_EQ(EVENT_TYPE_LIST, eventData[0]);
-        eventData++;
-
-        // Number of elements in list
-        ASSERT_EQ(3, eventData[0]);
-        eventData++;
-
-        // Element #1: string type for subtag
-        ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
-        eventData++;
-
-        unsigned subtag_len = strlen(SUBTAG);
-        if (subtag_len > 32) subtag_len = 32;
-        ASSERT_EQ(subtag_len, get4LE(eventData));
-        eventData += 4;
-
-        if (memcmp(SUBTAG, eventData, subtag_len)) {
-            continue;
-        }
-        eventData += subtag_len;
-
-        // Element #2: int type for uid
-        ASSERT_EQ(EVENT_TYPE_INT, eventData[0]);
-        eventData++;
-
-        ASSERT_EQ(UID, (int)get4LE(eventData));
-        eventData += 4;
-
-        // Element #3: string type for data
-        ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
-        eventData++;
-
-        size_t dataLen = get4LE(eventData);
-        eventData += 4;
-        if (DATA_LEN < 512) ASSERT_EQ(DATA_LEN, (int)dataLen);
-
-        if (memcmp(payload, eventData, dataLen)) {
-            continue;
-        }
-
-        if (DATA_LEN >= 512) {
-            eventData += dataLen;
-            // 4 bytes for the tag, and max_payload_buf should be truncated.
-            ASSERT_LE(4 + 512, eventData - original);      // worst expectations
-            ASSERT_GT(4 + DATA_LEN, eventData - original); // must be truncated
-        }
-
-        ++count;
+    char* eventData = log_msg.msg();
+    if (!eventData) {
+      continue;
     }
 
-    android_logger_list_close(logger_list);
+    char* original = eventData;
+
+    // Tag
+    int tag = get4LE(eventData);
+    eventData += 4;
+
+    if (tag != TAG) {
+      continue;
+    }
+
+    if (!payload) {
+      // This tag should not have been written because the data was null
+      ++count;
+      break;
+    }
+
+    // List type
+    ASSERT_EQ(EVENT_TYPE_LIST, eventData[0]);
+    eventData++;
+
+    // Number of elements in list
+    ASSERT_EQ(3, eventData[0]);
+    eventData++;
+
+    // Element #1: string type for subtag
+    ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
+    eventData++;
+
+    unsigned subtag_len = strlen(SUBTAG);
+    if (subtag_len > 32) subtag_len = 32;
+    ASSERT_EQ(subtag_len, get4LE(eventData));
+    eventData += 4;
+
+    if (memcmp(SUBTAG, eventData, subtag_len)) {
+      continue;
+    }
+    eventData += subtag_len;
+
+    // Element #2: int type for uid
+    ASSERT_EQ(EVENT_TYPE_INT, eventData[0]);
+    eventData++;
+
+    ASSERT_EQ(UID, (int)get4LE(eventData));
+    eventData += 4;
+
+    // Element #3: string type for data
+    ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
+    eventData++;
+
+    size_t dataLen = get4LE(eventData);
+    eventData += 4;
+    if (DATA_LEN < 512) ASSERT_EQ(DATA_LEN, (int)dataLen);
+
+    if (memcmp(payload, eventData, dataLen)) {
+      continue;
+    }
+
+    if (DATA_LEN >= 512) {
+      eventData += dataLen;
+      // 4 bytes for the tag, and max_payload_buf should be truncated.
+      ASSERT_LE(4 + 512, eventData - original);       // worst expectations
+      ASSERT_GT(4 + DATA_LEN, eventData - original);  // must be truncated
+    }
+
+    ++count;
+  }
+
+  android_logger_list_close(logger_list);
 }
 #endif
 
 TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__typical) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteWithInfoLog_helper(
-            123456781,
-            "test-subtag",
-            -1,
-            max_payload_buf,
-            200,
-            count);
-    EXPECT_EQ(1, count);
+  int count;
+  android_errorWriteWithInfoLog_helper(123456781, "test-subtag", -1,
+                                       max_payload_buf, 200, count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) {
+TEST(liblog,
+     android_errorWriteWithInfoLog__android_logger_list_read__data_too_large) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteWithInfoLog_helper(
-            123456782,
-            "test-subtag",
-            -1,
-            max_payload_buf,
-            sizeof(max_payload_buf),
-            count);
-    EXPECT_EQ(1, count);
+  int count;
+  android_errorWriteWithInfoLog_helper(123456782, "test-subtag", -1,
+                                       max_payload_buf, sizeof(max_payload_buf),
+                                       count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__null_data) {
+TEST(liblog,
+     android_errorWriteWithInfoLog__android_logger_list_read__null_data) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteWithInfoLog_helper(
-            123456783,
-            "test-subtag",
-            -1,
-            NULL,
-            200,
-            count);
-    EXPECT_EQ(0, count);
+  int count;
+  android_errorWriteWithInfoLog_helper(123456783, "test-subtag", -1, NULL, 200,
+                                       count);
+  EXPECT_EQ(0, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-TEST(liblog, android_errorWriteWithInfoLog__android_logger_list_read__subtag_too_long) {
+TEST(liblog,
+     android_errorWriteWithInfoLog__android_logger_list_read__subtag_too_long) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteWithInfoLog_helper(
-            123456784,
-            "abcdefghijklmnopqrstuvwxyz now i know my abc",
-            -1,
-            max_payload_buf,
-            200,
-            count);
-    EXPECT_EQ(1, count);
+  int count;
+  android_errorWriteWithInfoLog_helper(
+      123456784, "abcdefghijklmnopqrstuvwxyz now i know my abc", -1,
+      max_payload_buf, 200, count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, __android_log_bswrite_and_print___max) {
-    bswrite_test(max_payload_buf);
+  bswrite_test(max_payload_buf);
 }
 
 TEST(liblog, __android_log_buf_write_and_print__max) {
-    buf_write_test(max_payload_buf);
+  buf_write_test(max_payload_buf);
 }
 
 #ifdef TEST_PREFIX
-static void android_errorWriteLog_helper(int TAG, const char *SUBTAG, int& count) {
-    TEST_PREFIX
-    struct logger_list *logger_list;
+static void android_errorWriteLog_helper(int TAG, const char* SUBTAG,
+                                         int& count) {
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    count = 0;
+  count = 0;
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  // Do a Before and After on the count to measure the effect. Decrement
+  // what we find in Before to set the stage.
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
-    int retval_android_errorWriteLog = android_errorWriteLog(TAG, SUBTAG);
-    if (SUBTAG) {
-        ASSERT_LT(0, retval_android_errorWriteLog);
-    } else {
-        ASSERT_GT(0, retval_android_errorWriteLog);
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
+
+    char* eventData = log_msg.msg();
+    if (!eventData) continue;
+
+    // Tag
+    int tag = get4LE(eventData);
+    eventData += 4;
+
+    if (tag != TAG) continue;
+
+    if (!SUBTAG) {
+      // This tag should not have been written because the data was null
+      --count;
+      break;
     }
 
-    sleep(2);
+    // List type
+    eventData++;
+    // Number of elements in list
+    eventData++;
+    // Element #1: string type for subtag
+    eventData++;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
+    eventData += 4;
 
-        char *eventData = log_msg.msg();
-        if (!eventData) {
-            continue;
-        }
+    if (memcmp(SUBTAG, eventData, strlen(SUBTAG))) continue;
+    --count;
+  }
 
-        // Tag
-        int tag = get4LE(eventData);
-        eventData += 4;
+  android_logger_list_close(logger_list);
 
-        if (tag != TAG) {
-            continue;
-        }
+  // Do an After on the count to measure the effect.
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
-        if (!SUBTAG) {
-            // This tag should not have been written because the data was null
-            ++count;
-            break;
-        }
+  int retval_android_errorWriteLog = android_errorWriteLog(TAG, SUBTAG);
+  if (SUBTAG) {
+    ASSERT_LT(0, retval_android_errorWriteLog);
+  } else {
+    ASSERT_GT(0, retval_android_errorWriteLog);
+  }
 
-        // List type
-        ASSERT_EQ(EVENT_TYPE_LIST, eventData[0]);
-        eventData++;
+  sleep(2);
 
-        // Number of elements in list
-        ASSERT_EQ(3, eventData[0]);
-        eventData++;
-
-        // Element #1: string type for subtag
-        ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
-        eventData++;
-
-        ASSERT_EQ(strlen(SUBTAG), get4LE(eventData));
-        eventData +=4;
-
-        if (memcmp(SUBTAG, eventData, strlen(SUBTAG))) {
-            continue;
-        }
-        ++count;
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
     }
 
-    android_logger_list_close(logger_list);
+    char* eventData = log_msg.msg();
+    if (!eventData) {
+      continue;
+    }
+
+    // Tag
+    int tag = get4LE(eventData);
+    eventData += 4;
+
+    if (tag != TAG) {
+      continue;
+    }
+
+    if (!SUBTAG) {
+      // This tag should not have been written because the data was null
+      ++count;
+      break;
+    }
+
+    // List type
+    ASSERT_EQ(EVENT_TYPE_LIST, eventData[0]);
+    eventData++;
+
+    // Number of elements in list
+    ASSERT_EQ(3, eventData[0]);
+    eventData++;
+
+    // Element #1: string type for subtag
+    ASSERT_EQ(EVENT_TYPE_STRING, eventData[0]);
+    eventData++;
+
+    ASSERT_EQ(strlen(SUBTAG), get4LE(eventData));
+    eventData += 4;
+
+    if (memcmp(SUBTAG, eventData, strlen(SUBTAG))) {
+      continue;
+    }
+    ++count;
+  }
+
+  android_logger_list_close(logger_list);
 }
 #endif
 
 TEST(liblog, android_errorWriteLog__android_logger_list_read__success) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteLog_helper(123456785, "test-subtag", count);
-    EXPECT_EQ(1, count);
+  int count;
+  android_errorWriteLog_helper(123456785, "test-subtag", count);
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, android_errorWriteLog__android_logger_list_read__null_subtag) {
 #ifdef TEST_PREFIX
-    int count;
-    android_errorWriteLog_helper(123456786, NULL, count);
-    EXPECT_EQ(0, count);
+  int count;
+  android_errorWriteLog_helper(123456786, NULL, count);
+  EXPECT_EQ(0, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 // Do not retest logger list handling
 #if (defined(TEST_PREFIX) || !defined(USING_LOGGER_LOCAL))
 static int is_real_element(int type) {
-    return ((type == EVENT_TYPE_INT) ||
-            (type == EVENT_TYPE_LONG) ||
-            (type == EVENT_TYPE_STRING) ||
-            (type == EVENT_TYPE_FLOAT));
+  return ((type == EVENT_TYPE_INT) || (type == EVENT_TYPE_LONG) ||
+          (type == EVENT_TYPE_STRING) || (type == EVENT_TYPE_FLOAT));
 }
 
-static int android_log_buffer_to_string(const char *msg, size_t len,
-                                        char *strOut, size_t strOutLen) {
-    android_log_context context = create_android_log_parser(msg, len);
-    android_log_list_element elem;
-    bool overflow = false;
-    /* Reserve 1 byte for null terminator. */
-    size_t origStrOutLen = strOutLen--;
+static int android_log_buffer_to_string(const char* msg, size_t len,
+                                        char* strOut, size_t strOutLen) {
+  android_log_context context = create_android_log_parser(msg, len);
+  android_log_list_element elem;
+  bool overflow = false;
+  /* Reserve 1 byte for null terminator. */
+  size_t origStrOutLen = strOutLen--;
 
-    if (!context) {
-        return -EBADF;
-    }
+  if (!context) {
+    return -EBADF;
+  }
 
-    memset(&elem, 0, sizeof(elem));
+  memset(&elem, 0, sizeof(elem));
 
-    size_t outCount;
+  size_t outCount;
 
-    do {
-        elem = android_log_read_next(context);
-        switch ((int)elem.type) {
-        case EVENT_TYPE_LIST:
-            if (strOutLen == 0) {
-                overflow = true;
-            } else {
-                *strOut++ = '[';
-                strOutLen--;
-            }
-            break;
+  do {
+    elem = android_log_read_next(context);
+    switch ((int)elem.type) {
+      case EVENT_TYPE_LIST:
+        if (strOutLen == 0) {
+          overflow = true;
+        } else {
+          *strOut++ = '[';
+          strOutLen--;
+        }
+        break;
 
-        case EVENT_TYPE_LIST_STOP:
-            if (strOutLen == 0) {
-                overflow = true;
-            } else {
-                *strOut++ = ']';
-                strOutLen--;
-            }
-            break;
+      case EVENT_TYPE_LIST_STOP:
+        if (strOutLen == 0) {
+          overflow = true;
+        } else {
+          *strOut++ = ']';
+          strOutLen--;
+        }
+        break;
 
-        case EVENT_TYPE_INT:
-            /*
-             * snprintf also requires room for the null terminator, which
-             * we don't care about  but we have allocated enough room for
-             * that
-             */
-            outCount = snprintf(strOut, strOutLen + 1,
-                                "%" PRId32, elem.data.int32);
-            if (outCount <= strOutLen) {
-                strOut += outCount;
-                strOutLen -= outCount;
-            } else {
-                overflow = true;
-            }
-            break;
+      case EVENT_TYPE_INT:
+        /*
+         * snprintf also requires room for the null terminator, which
+         * we don't care about  but we have allocated enough room for
+         * that
+         */
+        outCount = snprintf(strOut, strOutLen + 1, "%" PRId32, elem.data.int32);
+        if (outCount <= strOutLen) {
+          strOut += outCount;
+          strOutLen -= outCount;
+        } else {
+          overflow = true;
+        }
+        break;
 
-        case EVENT_TYPE_LONG:
-            /*
-             * snprintf also requires room for the null terminator, which
-             * we don't care about but we have allocated enough room for
-             * that
-             */
-            outCount = snprintf(strOut, strOutLen + 1,
-                                "%" PRId64, elem.data.int64);
-            if (outCount <= strOutLen) {
-                strOut += outCount;
-                strOutLen -= outCount;
-            } else {
-                overflow = true;
-            }
-            break;
+      case EVENT_TYPE_LONG:
+        /*
+         * snprintf also requires room for the null terminator, which
+         * we don't care about but we have allocated enough room for
+         * that
+         */
+        outCount = snprintf(strOut, strOutLen + 1, "%" PRId64, elem.data.int64);
+        if (outCount <= strOutLen) {
+          strOut += outCount;
+          strOutLen -= outCount;
+        } else {
+          overflow = true;
+        }
+        break;
 
-        case EVENT_TYPE_FLOAT:
-            /*
-             * snprintf also requires room for the null terminator, which
-             * we don't care about but we have allocated enough room for
-             * that
-             */
-            outCount = snprintf(strOut, strOutLen + 1, "%f", elem.data.float32);
-            if (outCount <= strOutLen) {
-                strOut += outCount;
-                strOutLen -= outCount;
-            } else {
-                overflow = true;
-            }
-            break;
+      case EVENT_TYPE_FLOAT:
+        /*
+         * snprintf also requires room for the null terminator, which
+         * we don't care about but we have allocated enough room for
+         * that
+         */
+        outCount = snprintf(strOut, strOutLen + 1, "%f", elem.data.float32);
+        if (outCount <= strOutLen) {
+          strOut += outCount;
+          strOutLen -= outCount;
+        } else {
+          overflow = true;
+        }
+        break;
 
-        default:
-            elem.complete = true;
-            break;
+      default:
+        elem.complete = true;
+        break;
 
-        case EVENT_TYPE_UNKNOWN:
-#if 0 // Ideal purity in the test, we want to complain about UNKNOWN showing up
+      case EVENT_TYPE_UNKNOWN:
+#if 0  // Ideal purity in the test, we want to complain about UNKNOWN showing up
             if (elem.complete) {
                 break;
             }
 #endif
-            elem.data.string = const_cast<char *>("<unknown>");
-            elem.len = strlen(elem.data.string);
-            /* FALLTHRU */
-        case EVENT_TYPE_STRING:
-            if (elem.len <= strOutLen) {
-                memcpy(strOut, elem.data.string, elem.len);
-                strOut += elem.len;
-                strOutLen -= elem.len;
-            } else if (strOutLen > 0) {
-                /* copy what we can */
-                memcpy(strOut, elem.data.string, strOutLen);
-                strOut += strOutLen;
-                strOutLen = 0;
-                overflow = true;
-            }
-            break;
+        elem.data.string = const_cast<char*>("<unknown>");
+        elem.len = strlen(elem.data.string);
+      /* FALLTHRU */
+      case EVENT_TYPE_STRING:
+        if (elem.len <= strOutLen) {
+          memcpy(strOut, elem.data.string, elem.len);
+          strOut += elem.len;
+          strOutLen -= elem.len;
+        } else if (strOutLen > 0) {
+          /* copy what we can */
+          memcpy(strOut, elem.data.string, strOutLen);
+          strOut += strOutLen;
+          strOutLen = 0;
+          overflow = true;
         }
+        break;
+    }
 
-        if (elem.complete) {
-            break;
-        }
-        /* Determine whether to put a comma or not. */
-        if (!overflow && (is_real_element(elem.type) ||
-                (elem.type == EVENT_TYPE_LIST_STOP))) {
-            android_log_list_element next = android_log_peek_next(context);
-            if (!next.complete && (is_real_element(next.type) ||
-                    (next.type == EVENT_TYPE_LIST))) {
-                if (strOutLen == 0) {
-                    overflow = true;
-                } else {
-                    *strOut++ = ',';
-                    strOutLen--;
-                }
-            }
-        }
-    } while ((elem.type != EVENT_TYPE_UNKNOWN) && !overflow && !elem.complete);
-
-    android_log_destroy(&context);
-
-    if (overflow) {
-        if (strOutLen < origStrOutLen) {
-            /* leave an indicator */
-            *(strOut-1) = '!';
+    if (elem.complete) {
+      break;
+    }
+    /* Determine whether to put a comma or not. */
+    if (!overflow &&
+        (is_real_element(elem.type) || (elem.type == EVENT_TYPE_LIST_STOP))) {
+      android_log_list_element next = android_log_peek_next(context);
+      if (!next.complete &&
+          (is_real_element(next.type) || (next.type == EVENT_TYPE_LIST))) {
+        if (strOutLen == 0) {
+          overflow = true;
         } else {
-            /* nothing was written at all */
-            *strOut++ = '!';
+          *strOut++ = ',';
+          strOutLen--;
         }
+      }
     }
-    *strOut++ = '\0';
+  } while ((elem.type != EVENT_TYPE_UNKNOWN) && !overflow && !elem.complete);
 
-    if ((elem.type == EVENT_TYPE_UNKNOWN) && !elem.complete) {
-        fprintf(stderr, "Binary log entry conversion failed\n");
-        return -EINVAL;
+  android_log_destroy(&context);
+
+  if (overflow) {
+    if (strOutLen < origStrOutLen) {
+      /* leave an indicator */
+      *(strOut - 1) = '!';
+    } else {
+      /* nothing was written at all */
+      *strOut++ = '!';
     }
+  }
+  *strOut++ = '\0';
 
-    return 0;
+  if ((elem.type == EVENT_TYPE_UNKNOWN) && !elem.complete) {
+    fprintf(stderr, "Binary log entry conversion failed\n");
+    return -EINVAL;
+  }
+
+  return 0;
 }
-#endif // TEST_PREFIX || !USING_LOGGER_LOCAL
+#endif  // TEST_PREFIX || !USING_LOGGER_LOCAL
 
 #ifdef TEST_PREFIX
-static const char *event_test_int32(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_int32(uint32_t tag, size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint32_t);
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t);
 
-    return "1076895760";
+  return "1076895760";
 }
 
-static const char *event_test_int64(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_int64(uint32_t tag, size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint64_t);
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint64_t);
 
-    return "-9191740941672636400";
+  return "-9191740941672636400";
 }
 
-static const char *event_test_list_int64(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_list_int64(uint32_t tag, size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint8_t) +
-                       sizeof(uint8_t) + sizeof(uint64_t);
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint8_t) + sizeof(uint64_t);
 
-    return "[-9191740941672636400]";
+  return "[-9191740941672636400]";
 }
 
-static const char *event_test_simple_automagic_list(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_simple_automagic_list(uint32_t tag,
+                                                    size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    // The convenience API where we allow a simple list to be
-    // created without explicit begin or end calls.
-    EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
-    EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  // The convenience API where we allow a simple list to be
+  // created without explicit begin or end calls.
+  EXPECT_LE(0, android_log_write_int32(ctx, 0x40302010));
+  EXPECT_LE(0, android_log_write_int64(ctx, 0x8070605040302010));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint8_t) +
-                       sizeof(uint8_t) + sizeof(uint32_t) +
-                       sizeof(uint8_t) + sizeof(uint64_t);
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
+                 sizeof(uint64_t);
 
-    return "[1076895760,-9191740941672636400]";
+  return "[1076895760,-9191740941672636400]";
 }
 
-static const char *event_test_list_empty(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_list_empty(uint32_t tag, size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint8_t);
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t);
 
-    return "[]";
+  return "[]";
 }
 
-static const char *event_test_complex_nested_list(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_complex_nested_list(uint32_t tag,
+                                                  size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
 
-    EXPECT_LE(0, android_log_write_list_begin(ctx)); // [
-    EXPECT_LE(0, android_log_write_int32(ctx, 0x01020304));
-    EXPECT_LE(0, android_log_write_int64(ctx, 0x0102030405060708));
-    EXPECT_LE(0, android_log_write_string8(ctx, "Hello World"));
-    EXPECT_LE(0, android_log_write_list_begin(ctx)); // [
-    EXPECT_LE(0, android_log_write_int32(ctx, 1));
-    EXPECT_LE(0, android_log_write_int32(ctx, 2));
-    EXPECT_LE(0, android_log_write_int32(ctx, 3));
-    EXPECT_LE(0, android_log_write_int32(ctx, 4));
-    EXPECT_LE(0, android_log_write_list_end(ctx));   // ]
-    EXPECT_LE(0, android_log_write_float32(ctx, 1.0102030405060708));
-    EXPECT_LE(0, android_log_write_list_end(ctx));   // ]
+  EXPECT_LE(0, android_log_write_list_begin(ctx));  // [
+  EXPECT_LE(0, android_log_write_int32(ctx, 0x01020304));
+  EXPECT_LE(0, android_log_write_int64(ctx, 0x0102030405060708));
+  EXPECT_LE(0, android_log_write_string8(ctx, "Hello World"));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));  // [
+  EXPECT_LE(0, android_log_write_int32(ctx, 1));
+  EXPECT_LE(0, android_log_write_int32(ctx, 2));
+  EXPECT_LE(0, android_log_write_int32(ctx, 3));
+  EXPECT_LE(0, android_log_write_int32(ctx, 4));
+  EXPECT_LE(0, android_log_write_list_end(ctx));  // ]
+  EXPECT_LE(0, android_log_write_float32(ctx, 1.0102030405060708));
+  EXPECT_LE(0, android_log_write_list_end(ctx));  // ]
 
-    //
-    // This one checks for the automagic list creation because a list
-    // begin and end was missing for it! This is actually an <oops> corner
-    // case, and not the behavior we morally support. The automagic API is to
-    // allow for a simple case of a series of objects in a single list. e.g.
-    //   int32,int32,int32,string -> [int32,int32,int32,string]
-    //
-    EXPECT_LE(0, android_log_write_string8(ctx, "dlroW olleH"));
+  //
+  // This one checks for the automagic list creation because a list
+  // begin and end was missing for it! This is actually an <oops> corner
+  // case, and not the behavior we morally support. The automagic API is to
+  // allow for a simple case of a series of objects in a single list. e.g.
+  //   int32,int32,int32,string -> [int32,int32,int32,string]
+  //
+  EXPECT_LE(0, android_log_write_string8(ctx, "dlroW olleH"));
 
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) +
-                   sizeof(uint8_t) + sizeof(uint8_t) +
-                       sizeof(uint8_t) + sizeof(uint8_t) +
-                           sizeof(uint8_t) + sizeof(uint32_t) +
-                           sizeof(uint8_t) + sizeof(uint64_t) +
-                           sizeof(uint8_t) + sizeof(uint32_t) +
-                                             sizeof("Hello World") - 1 +
-                           sizeof(uint8_t) + sizeof(uint8_t) +
-                               4 * (sizeof(uint8_t) + sizeof(uint32_t)) +
-                           sizeof(uint8_t) + sizeof(uint32_t) +
-                       sizeof(uint8_t) + sizeof(uint32_t) +
-                                         sizeof("dlroW olleH") - 1;
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint64_t) +
+                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
+                 1 + sizeof(uint8_t) + sizeof(uint8_t) +
+                 4 * (sizeof(uint8_t) + sizeof(uint32_t)) + sizeof(uint8_t) +
+                 sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) +
+                 sizeof("dlroW olleH") - 1;
 
-    return "[[16909060,72623859790382856,Hello World,[1,2,3,4],1.010203],dlroW olleH]";
+  return "[[16909060,72623859790382856,Hello World,[1,2,3,4],1.010203],dlroW "
+         "olleH]";
 }
 
-static const char *event_test_7_level_prefix(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_7_level_prefix(uint32_t tag,
+                                             size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 1));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 2));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 3));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 4));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 5));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 6));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 7));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 1));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 2));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 3));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 4));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 5));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 6));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 7));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) + 7 *
-      (sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint32_t));
+  expected_len = sizeof(uint32_t) + 7 * (sizeof(uint8_t) + sizeof(uint8_t) +
+                                         sizeof(uint8_t) + sizeof(uint32_t));
 
-    return "[[[[[[[1],2],3],4],5],6],7]";
+  return "[[[[[[[1],2],3],4],5],6],7]";
 }
 
-static const char *event_test_7_level_suffix(uint32_t tag, size_t &expected_len) {
-    android_log_context ctx;
+static const char* event_test_7_level_suffix(uint32_t tag,
+                                             size_t& expected_len) {
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
-    if (!ctx) {
-        return NULL;
-    }
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 1));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 2));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 3));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 4));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 5));
-    EXPECT_LE(0, android_log_write_list_begin(ctx));
-    EXPECT_LE(0, android_log_write_int32(ctx, 6));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list_end(ctx));
-    EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
-    EXPECT_LE(0, android_log_destroy(&ctx));
-    EXPECT_TRUE(NULL == ctx);
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(tag)));
+  if (!ctx) {
+    return NULL;
+  }
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 1));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 2));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 3));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 4));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 5));
+  EXPECT_LE(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_write_int32(ctx, 6));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list_end(ctx));
+  EXPECT_LE(0, android_log_write_list(ctx, LOG_ID_EVENTS));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  EXPECT_TRUE(NULL == ctx);
 
-    expected_len = sizeof(uint32_t) + 6 *
-      (sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint8_t) + sizeof(uint32_t));
+  expected_len = sizeof(uint32_t) + 6 * (sizeof(uint8_t) + sizeof(uint8_t) +
+                                         sizeof(uint8_t) + sizeof(uint32_t));
 
-    return "[1,[2,[3,[4,[5,[6]]]]]]";
+  return "[1,[2,[3,[4,[5,[6]]]]]]";
 }
 
-static const char *event_test_android_log_error_write(uint32_t tag, size_t &expected_len) {
-    EXPECT_LE(0, __android_log_error_write(tag, "Hello World", 42, "dlroW olleH", 11));
+static const char* event_test_android_log_error_write(uint32_t tag,
+                                                      size_t& expected_len) {
+  EXPECT_LE(
+      0, __android_log_error_write(tag, "Hello World", 42, "dlroW olleH", 11));
 
-    expected_len = sizeof(uint32_t) +
-      sizeof(uint8_t) + sizeof(uint8_t) +
-          sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") - 1 +
-          sizeof(uint8_t) + sizeof(uint32_t) +
-          sizeof(uint8_t) + sizeof(uint32_t) + sizeof("dlroW olleH") - 1;
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
+                 1 + sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
+                 sizeof(uint32_t) + sizeof("dlroW olleH") - 1;
 
-    return "[Hello World,42,dlroW olleH]";
+  return "[Hello World,42,dlroW olleH]";
 }
 
-static const char *event_test_android_log_error_write_null(uint32_t tag, size_t &expected_len) {
-    EXPECT_LE(0, __android_log_error_write(tag, "Hello World", 42, NULL, 0));
+static const char* event_test_android_log_error_write_null(uint32_t tag,
+                                                           size_t& expected_len) {
+  EXPECT_LE(0, __android_log_error_write(tag, "Hello World", 42, NULL, 0));
 
-    expected_len = sizeof(uint32_t) +
-      sizeof(uint8_t) + sizeof(uint8_t) +
-          sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") - 1 +
-          sizeof(uint8_t) + sizeof(uint32_t) +
-          sizeof(uint8_t) + sizeof(uint32_t) + sizeof("") - 1;
+  expected_len = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint8_t) +
+                 sizeof(uint8_t) + sizeof(uint32_t) + sizeof("Hello World") -
+                 1 + sizeof(uint8_t) + sizeof(uint32_t) + sizeof(uint8_t) +
+                 sizeof(uint32_t) + sizeof("") - 1;
 
-    return "[Hello World,42,]";
+  return "[Hello World,42,]";
 }
 
 // make sure all user buffers are flushed
 static void print_barrier() {
-    std::cout.flush();
-    fflush(stdout);
-    std::cerr.flush();
-    fflush(stderr); // everything else is paranoia ...
+  std::cout.flush();
+  fflush(stdout);
+  std::cerr.flush();
+  fflush(stderr);  // everything else is paranoia ...
 }
 
-static void create_android_logger(const char *(*fn)(uint32_t tag, size_t &expected_len)) {
-    TEST_PREFIX
-    struct logger_list *logger_list;
+static void create_android_logger(const char* (*fn)(uint32_t tag,
+                                                    size_t& expected_len)) {
+  TEST_PREFIX
+  struct logger_list* logger_list;
 
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  ASSERT_TRUE(NULL !=
+              (logger_list = android_logger_list_open(
+                   LOG_ID_EVENTS, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK,
+                   1000, pid)));
 
 #ifdef __ANDROID__
-    log_time ts(android_log_clockid());
+  log_time ts(android_log_clockid());
 #else
-    log_time ts(CLOCK_REALTIME);
+  log_time ts(CLOCK_REALTIME);
 #endif
 
-    size_t expected_len;
-    const char *expected_string = (*fn)(1005, expected_len);
+  size_t expected_len;
+  const char* expected_string = (*fn)(1005, expected_len);
 
-    if (!expected_string) {
-        android_logger_list_close(logger_list);
-        return;
-    }
-
-    usleep(1000000);
-
-    int count = 0;
-
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) {
-            break;
-        }
-
-        ASSERT_EQ(log_msg.entry.pid, pid);
-
-        if ((log_msg.entry.sec < (ts.tv_sec - 1))
-         || ((ts.tv_sec + 1) < log_msg.entry.sec)
-         || ((size_t)log_msg.entry.len != expected_len)
-         || (log_msg.id() != LOG_ID_EVENTS)) {
-            continue;
-        }
-
-        char *eventData = log_msg.msg();
-
-        ++count;
-
-        AndroidLogFormat *logformat = android_log_format_new();
-        EXPECT_TRUE(NULL != logformat);
-        AndroidLogEntry entry;
-        char msgBuf[1024];
-        int processBinaryLogBuffer = android_log_processBinaryLogBuffer(
-            &log_msg.entry_v1, &entry, NULL, msgBuf, sizeof(msgBuf));
-        EXPECT_EQ(0, processBinaryLogBuffer);
-        if (processBinaryLogBuffer == 0) {
-            int line_overhead = 20;
-            if (pid > 99999) ++line_overhead;
-            if (pid > 999999) ++line_overhead;
-            print_barrier();
-            int printLogLine = android_log_printLogLine(
-                logformat, fileno(stderr), &entry);
-            print_barrier();
-            EXPECT_EQ(line_overhead + (int)strlen(expected_string),
-                      printLogLine);
-        }
-        android_log_format_free(logformat);
-
-        // test buffer reading API
-        int buffer_to_string = -1;
-        if (eventData) {
-            snprintf(msgBuf, sizeof(msgBuf),
-                     "I/[%" PRIu32 "]", get4LE(eventData));
-            print_barrier();
-            fprintf(stderr, "%-10s(%5u): ", msgBuf, pid);
-            memset(msgBuf, 0, sizeof(msgBuf));
-            buffer_to_string = android_log_buffer_to_string(
-                eventData + sizeof(uint32_t),
-                log_msg.entry.len - sizeof(uint32_t),
-                msgBuf, sizeof(msgBuf));
-            fprintf(stderr, "%s\n", msgBuf);
-            print_barrier();
-        }
-        EXPECT_EQ(0, buffer_to_string);
-        EXPECT_EQ(strlen(expected_string), strlen(msgBuf));
-        EXPECT_EQ(0, strcmp(expected_string, msgBuf));
-    }
-
-    EXPECT_EQ(1, count);
-
+  if (!expected_string) {
     android_logger_list_close(logger_list);
+    return;
+  }
+
+  usleep(1000000);
+
+  int count = 0;
+
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) {
+      break;
+    }
+
+    ASSERT_EQ(log_msg.entry.pid, pid);
+
+    if ((log_msg.entry.sec < (ts.tv_sec - 1)) ||
+        ((ts.tv_sec + 1) < log_msg.entry.sec) ||
+        ((size_t)log_msg.entry.len != expected_len) ||
+        (log_msg.id() != LOG_ID_EVENTS)) {
+      continue;
+    }
+
+    char* eventData = log_msg.msg();
+
+    ++count;
+
+    AndroidLogFormat* logformat = android_log_format_new();
+    EXPECT_TRUE(NULL != logformat);
+    AndroidLogEntry entry;
+    char msgBuf[1024];
+    int processBinaryLogBuffer = android_log_processBinaryLogBuffer(
+        &log_msg.entry_v1, &entry, NULL, msgBuf, sizeof(msgBuf));
+    EXPECT_EQ(0, processBinaryLogBuffer);
+    if (processBinaryLogBuffer == 0) {
+      int line_overhead = 20;
+      if (pid > 99999) ++line_overhead;
+      if (pid > 999999) ++line_overhead;
+      print_barrier();
+      int printLogLine =
+          android_log_printLogLine(logformat, fileno(stderr), &entry);
+      print_barrier();
+      EXPECT_EQ(line_overhead + (int)strlen(expected_string), printLogLine);
+    }
+    android_log_format_free(logformat);
+
+    // test buffer reading API
+    int buffer_to_string = -1;
+    if (eventData) {
+      snprintf(msgBuf, sizeof(msgBuf), "I/[%" PRIu32 "]", get4LE(eventData));
+      print_barrier();
+      fprintf(stderr, "%-10s(%5u): ", msgBuf, pid);
+      memset(msgBuf, 0, sizeof(msgBuf));
+      buffer_to_string = android_log_buffer_to_string(
+          eventData + sizeof(uint32_t), log_msg.entry.len - sizeof(uint32_t),
+          msgBuf, sizeof(msgBuf));
+      fprintf(stderr, "%s\n", msgBuf);
+      print_barrier();
+    }
+    EXPECT_EQ(0, buffer_to_string);
+    EXPECT_EQ(strlen(expected_string), strlen(msgBuf));
+    EXPECT_EQ(0, strcmp(expected_string, msgBuf));
+  }
+
+  EXPECT_EQ(SUPPORTS_END_TO_END, count);
+
+  android_logger_list_close(logger_list);
 }
 #endif
 
 TEST(liblog, create_android_logger_int32) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_int32);
+  create_android_logger(event_test_int32);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_int64) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_int64);
+  create_android_logger(event_test_int64);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_list_int64) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_list_int64);
+  create_android_logger(event_test_list_int64);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_simple_automagic_list) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_simple_automagic_list);
+  create_android_logger(event_test_simple_automagic_list);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_list_empty) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_list_empty);
+  create_android_logger(event_test_list_empty);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_complex_nested_list) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_complex_nested_list);
+  create_android_logger(event_test_complex_nested_list);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_7_level_prefix) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_7_level_prefix);
+  create_android_logger(event_test_7_level_prefix);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_7_level_suffix) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_7_level_suffix);
+  create_android_logger(event_test_7_level_suffix);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_android_log_error_write) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_android_log_error_write);
+  create_android_logger(event_test_android_log_error_write);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, create_android_logger_android_log_error_write_null) {
 #ifdef TEST_PREFIX
-    create_android_logger(event_test_android_log_error_write_null);
+  create_android_logger(event_test_android_log_error_write_null);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
-#ifndef USING_LOGGER_LOCAL // Do not retest logger list handling
+#ifdef USING_LOGGER_DEFAULT  // Do not retest logger list handling
 TEST(liblog, create_android_logger_overflow) {
-    android_log_context ctx;
+  android_log_context ctx;
 
-    EXPECT_TRUE(NULL != (ctx = create_android_logger(1005)));
-    if (ctx) {
-        for (size_t i = 0; i < ANDROID_MAX_LIST_NEST_DEPTH; ++i) {
-            EXPECT_LE(0, android_log_write_list_begin(ctx));
-        }
-        EXPECT_GT(0, android_log_write_list_begin(ctx));
-        /* One more for good measure, must be permanently unhappy */
-        EXPECT_GT(0, android_log_write_list_begin(ctx));
-        EXPECT_LE(0, android_log_destroy(&ctx));
-        EXPECT_TRUE(NULL == ctx);
-    }
-
-    ASSERT_TRUE(NULL != (ctx = create_android_logger(1005)));
+  EXPECT_TRUE(NULL != (ctx = create_android_logger(1005)));
+  if (ctx) {
     for (size_t i = 0; i < ANDROID_MAX_LIST_NEST_DEPTH; ++i) {
-        EXPECT_LE(0, android_log_write_list_begin(ctx));
-        EXPECT_LE(0, android_log_write_int32(ctx, i));
+      EXPECT_LE(0, android_log_write_list_begin(ctx));
     }
     EXPECT_GT(0, android_log_write_list_begin(ctx));
     /* One more for good measure, must be permanently unhappy */
     EXPECT_GT(0, android_log_write_list_begin(ctx));
     EXPECT_LE(0, android_log_destroy(&ctx));
-    ASSERT_TRUE(NULL == ctx);
+    EXPECT_TRUE(NULL == ctx);
+  }
+
+  ASSERT_TRUE(NULL != (ctx = create_android_logger(1005)));
+  for (size_t i = 0; i < ANDROID_MAX_LIST_NEST_DEPTH; ++i) {
+    EXPECT_LE(0, android_log_write_list_begin(ctx));
+    EXPECT_LE(0, android_log_write_int32(ctx, i));
+  }
+  EXPECT_GT(0, android_log_write_list_begin(ctx));
+  /* One more for good measure, must be permanently unhappy */
+  EXPECT_GT(0, android_log_write_list_begin(ctx));
+  EXPECT_LE(0, android_log_destroy(&ctx));
+  ASSERT_TRUE(NULL == ctx);
 }
 
 TEST(liblog, android_log_write_list_buffer) {
-    __android_log_event_list ctx(1005);
-    ctx << 1005 << "tag_def" << "(tag|1),(name|3),(format|3)";
-    std::string buffer(ctx);
-    ctx.close();
+  __android_log_event_list ctx(1005);
+  ctx << 1005 << "tag_def"
+      << "(tag|1),(name|3),(format|3)";
+  std::string buffer(ctx);
+  ctx.close();
 
-    char msgBuf[1024];
-    memset(msgBuf, 0, sizeof(msgBuf));
-    EXPECT_EQ(android_log_buffer_to_string(buffer.data(), buffer.length(),
-                                           msgBuf, sizeof(msgBuf)), 0);
-    EXPECT_STREQ(msgBuf, "[1005,tag_def,(tag|1),(name|3),(format|3)]");
+  char msgBuf[1024];
+  memset(msgBuf, 0, sizeof(msgBuf));
+  EXPECT_EQ(android_log_buffer_to_string(buffer.data(), buffer.length(), msgBuf,
+                                         sizeof(msgBuf)),
+            0);
+  EXPECT_STREQ(msgBuf, "[1005,tag_def,(tag|1),(name|3),(format|3)]");
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
-#ifndef USING_LOGGER_LOCAL // Do not retest pmsg functionality
+#ifdef USING_LOGGER_DEFAULT  // Do not retest pmsg functionality
 #ifdef __ANDROID__
 static const char __pmsg_file[] =
-        "/data/william-shakespeare/MuchAdoAboutNothing.txt";
+    "/data/william-shakespeare/MuchAdoAboutNothing.txt";
 #endif
 
 TEST(liblog, __android_log_pmsg_file_write) {
 #ifdef __ANDROID__
-    __android_log_close();
-    if (getuid() == AID_ROOT) {
-        tested__android_log_close = true;
-        bool pmsgActiveAfter__android_log_close = isPmsgActive();
-        bool logdwActiveAfter__android_log_close = isLogdwActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-        EXPECT_FALSE(logdwActiveAfter__android_log_close);
-    } else if (!tested__android_log_close) {
-        fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-    }
-    int return__android_log_pmsg_file_write = __android_log_pmsg_file_write(
-            LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
-            __pmsg_file, max_payload_buf, sizeof(max_payload_buf));
-    EXPECT_LT(0, return__android_log_pmsg_file_write);
-    if (return__android_log_pmsg_file_write == -ENOMEM) {
-        fprintf(stderr,
-                "Kernel does not have space allocated to pmsg pstore driver configured\n"
-               );
-    } else if (!return__android_log_pmsg_file_write) {
-        fprintf(stderr, "Reboot, ensure file %s matches\n"
-                        "with liblog.__android_log_msg_file_read test\n",
-                        __pmsg_file);
-    }
-    bool pmsgActiveAfter__android_pmsg_file_write;
-    bool logdwActiveAfter__android_pmsg_file_write;
-    if (getuid() == AID_ROOT) {
-        pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
-        logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_pmsg_file_write);
-        EXPECT_FALSE(logdwActiveAfter__android_pmsg_file_write);
-    }
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                         "TEST__android_log_pmsg_file_write",
-                                         "main"));
-    if (getuid() == AID_ROOT) {
-        bool pmsgActiveAfter__android_log_buf_print = isPmsgActive();
-        bool logdwActiveAfter__android_log_buf_print = isLogdwActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_log_buf_print);
-        EXPECT_TRUE(logdwActiveAfter__android_log_buf_print);
-    }
-    EXPECT_LT(0, __android_log_pmsg_file_write(
-            LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
-            __pmsg_file, max_payload_buf, sizeof(max_payload_buf)));
-    if (getuid() == AID_ROOT) {
-        pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
-        logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
-        EXPECT_TRUE(pmsgActiveAfter__android_pmsg_file_write);
-        EXPECT_TRUE(logdwActiveAfter__android_pmsg_file_write);
-    }
+  __android_log_close();
+  if (getuid() == AID_ROOT) {
+    tested__android_log_close = true;
+    bool pmsgActiveAfter__android_log_close = isPmsgActive();
+    bool logdwActiveAfter__android_log_close = isLogdwActive();
+    EXPECT_FALSE(pmsgActiveAfter__android_log_close);
+    EXPECT_FALSE(logdwActiveAfter__android_log_close);
+  } else if (!tested__android_log_close) {
+    fprintf(stderr, "WARNING: can not test __android_log_close()\n");
+  }
+  int return__android_log_pmsg_file_write = __android_log_pmsg_file_write(
+      LOG_ID_CRASH, ANDROID_LOG_VERBOSE, __pmsg_file, max_payload_buf,
+      sizeof(max_payload_buf));
+  EXPECT_LT(0, return__android_log_pmsg_file_write);
+  if (return__android_log_pmsg_file_write == -ENOMEM) {
+    fprintf(stderr,
+            "Kernel does not have space allocated to pmsg pstore driver "
+            "configured\n");
+  } else if (!return__android_log_pmsg_file_write) {
+    fprintf(stderr,
+            "Reboot, ensure file %s matches\n"
+            "with liblog.__android_log_msg_file_read test\n",
+            __pmsg_file);
+  }
+  bool pmsgActiveAfter__android_pmsg_file_write;
+  bool logdwActiveAfter__android_pmsg_file_write;
+  if (getuid() == AID_ROOT) {
+    pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
+    logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
+    EXPECT_FALSE(pmsgActiveAfter__android_pmsg_file_write);
+    EXPECT_FALSE(logdwActiveAfter__android_pmsg_file_write);
+  }
+  EXPECT_LT(
+      0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
+                                 "TEST__android_log_pmsg_file_write", "main"));
+  if (getuid() == AID_ROOT) {
+    bool pmsgActiveAfter__android_log_buf_print = isPmsgActive();
+    bool logdwActiveAfter__android_log_buf_print = isLogdwActive();
+    EXPECT_TRUE(pmsgActiveAfter__android_log_buf_print);
+    EXPECT_TRUE(logdwActiveAfter__android_log_buf_print);
+  }
+  EXPECT_LT(0, __android_log_pmsg_file_write(LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
+                                             __pmsg_file, max_payload_buf,
+                                             sizeof(max_payload_buf)));
+  if (getuid() == AID_ROOT) {
+    pmsgActiveAfter__android_pmsg_file_write = isPmsgActive();
+    logdwActiveAfter__android_pmsg_file_write = isLogdwActive();
+    EXPECT_TRUE(pmsgActiveAfter__android_pmsg_file_write);
+    EXPECT_TRUE(logdwActiveAfter__android_pmsg_file_write);
+  }
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 #ifdef __ANDROID__
-static ssize_t __pmsg_fn(log_id_t logId, char prio, const char *filename,
-                         const char *buf, size_t len, void *arg) {
-    EXPECT_TRUE(NULL == arg);
-    EXPECT_EQ(LOG_ID_CRASH, logId);
-    EXPECT_EQ(ANDROID_LOG_VERBOSE, prio);
-    EXPECT_FALSE(NULL == strstr(__pmsg_file, filename));
-    EXPECT_EQ(len, sizeof(max_payload_buf));
-    EXPECT_EQ(0, strcmp(max_payload_buf, buf));
+static ssize_t __pmsg_fn(log_id_t logId, char prio, const char* filename,
+                         const char* buf, size_t len, void* arg) {
+  EXPECT_TRUE(NULL == arg);
+  EXPECT_EQ(LOG_ID_CRASH, logId);
+  EXPECT_EQ(ANDROID_LOG_VERBOSE, prio);
+  EXPECT_FALSE(NULL == strstr(__pmsg_file, filename));
+  EXPECT_EQ(len, sizeof(max_payload_buf));
+  EXPECT_EQ(0, strcmp(max_payload_buf, buf));
 
-    ++signaled;
-    if ((len != sizeof(max_payload_buf)) ||
-            strcmp(max_payload_buf, buf)) {
-        fprintf(stderr, "comparison fails on content \"%s\"\n", buf);
-    }
-    return arg ||
-           (LOG_ID_CRASH != logId) ||
-           (ANDROID_LOG_VERBOSE != prio) ||
-           !strstr(__pmsg_file, filename) ||
-           (len != sizeof(max_payload_buf)) ||
-           !!strcmp(max_payload_buf, buf) ? -ENOEXEC : 1;
+  ++signaled;
+  if ((len != sizeof(max_payload_buf)) || strcmp(max_payload_buf, buf)) {
+    fprintf(stderr, "comparison fails on content \"%s\"\n", buf);
+  }
+  return arg || (LOG_ID_CRASH != logId) || (ANDROID_LOG_VERBOSE != prio) ||
+                 !strstr(__pmsg_file, filename) ||
+                 (len != sizeof(max_payload_buf)) ||
+                 !!strcmp(max_payload_buf, buf)
+             ? -ENOEXEC
+             : 1;
 }
 #endif
 
 TEST(liblog, __android_log_pmsg_file_read) {
 #ifdef __ANDROID__
-    signaled = 0;
+  signaled = 0;
 
-    __android_log_close();
-    if (getuid() == AID_ROOT) {
-        tested__android_log_close = true;
-        bool pmsgActiveAfter__android_log_close = isPmsgActive();
-        bool logdwActiveAfter__android_log_close = isLogdwActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_log_close);
-        EXPECT_FALSE(logdwActiveAfter__android_log_close);
-    } else if (!tested__android_log_close) {
-        fprintf(stderr, "WARNING: can not test __android_log_close()\n");
-    }
+  __android_log_close();
+  if (getuid() == AID_ROOT) {
+    tested__android_log_close = true;
+    bool pmsgActiveAfter__android_log_close = isPmsgActive();
+    bool logdwActiveAfter__android_log_close = isLogdwActive();
+    EXPECT_FALSE(pmsgActiveAfter__android_log_close);
+    EXPECT_FALSE(logdwActiveAfter__android_log_close);
+  } else if (!tested__android_log_close) {
+    fprintf(stderr, "WARNING: can not test __android_log_close()\n");
+  }
 
-    ssize_t ret = __android_log_pmsg_file_read(
-            LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
-            __pmsg_file, __pmsg_fn, NULL);
+  ssize_t ret = __android_log_pmsg_file_read(LOG_ID_CRASH, ANDROID_LOG_VERBOSE,
+                                             __pmsg_file, __pmsg_fn, NULL);
 
-    if (getuid() == AID_ROOT) {
-        bool pmsgActiveAfter__android_log_pmsg_file_read = isPmsgActive();
-        bool logdwActiveAfter__android_log_pmsg_file_read = isLogdwActive();
-        EXPECT_FALSE(pmsgActiveAfter__android_log_pmsg_file_read);
-        EXPECT_FALSE(logdwActiveAfter__android_log_pmsg_file_read);
-    }
+  if (getuid() == AID_ROOT) {
+    bool pmsgActiveAfter__android_log_pmsg_file_read = isPmsgActive();
+    bool logdwActiveAfter__android_log_pmsg_file_read = isLogdwActive();
+    EXPECT_FALSE(pmsgActiveAfter__android_log_pmsg_file_read);
+    EXPECT_FALSE(logdwActiveAfter__android_log_pmsg_file_read);
+  }
 
-    if (ret == -ENOENT) {
-        fprintf(stderr,
+  if (ret == -ENOENT) {
+    fprintf(stderr,
             "No pre-boot results of liblog.__android_log_mesg_file_write to "
             "compare with,\n"
             "false positive test result.\n");
-        return;
-    }
+    return;
+  }
 
-    EXPECT_LT(0, ret);
-    EXPECT_EQ(1U, signaled);
+  EXPECT_LT(0, ret);
+  EXPECT_EQ(1U, signaled);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
-#ifndef USING_LOGGER_LOCAL // Do not retest event mapping functionality
+#ifdef USING_LOGGER_DEFAULT  // Do not retest event mapping functionality
 #ifdef __ANDROID__
 // must be: '<needle:> 0 kB'
-static bool isZero(const std::string &content, std::string::size_type pos,
+static bool isZero(const std::string& content, std::string::size_type pos,
                    const char* needle) {
-    std::string::size_type offset = content.find(needle, pos);
-    return (offset != std::string::npos) &&
-           ((offset = content.find_first_not_of(" \t", offset +
-                      strlen(needle))) != std::string::npos) &&
-           (content.find_first_not_of("0", offset) != offset);
+  std::string::size_type offset = content.find(needle, pos);
+  return (offset != std::string::npos) &&
+         ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) !=
+          std::string::npos) &&
+         (content.find_first_not_of("0", offset) != offset);
 }
 
 // must not be: '<needle:> 0 kB'
-static bool isNotZero(const std::string &content, std::string::size_type pos,
+static bool isNotZero(const std::string& content, std::string::size_type pos,
                       const char* needle) {
-    std::string::size_type offset = content.find(needle, pos);
-    return (offset != std::string::npos) &&
-           ((offset = content.find_first_not_of(" \t", offset +
-                      strlen(needle))) != std::string::npos) &&
-           (content.find_first_not_of("123456789", offset) != offset);
+  std::string::size_type offset = content.find(needle, pos);
+  return (offset != std::string::npos) &&
+         ((offset = content.find_first_not_of(" \t", offset + strlen(needle))) !=
+          std::string::npos) &&
+         (content.find_first_not_of("123456789", offset) != offset);
 }
 
 static void event_log_tags_test_smap(pid_t pid) {
-    std::string filename = android::base::StringPrintf("/proc/%d/smaps", pid);
+  std::string filename = android::base::StringPrintf("/proc/%d/smaps", pid);
 
-    std::string content;
-    if (!android::base::ReadFileToString(filename, &content)) return;
+  std::string content;
+  if (!android::base::ReadFileToString(filename, &content)) return;
 
-    bool shared_ok = false;
-    bool private_ok = false;
-    bool anonymous_ok = false;
-    bool pass_ok = false;
+  bool shared_ok = false;
+  bool private_ok = false;
+  bool anonymous_ok = false;
+  bool pass_ok = false;
 
-    static const char event_log_tags[] = "event-log-tags";
-    std::string::size_type pos = 0;
-    while ((pos = content.find(event_log_tags, pos)) != std::string::npos) {
-        pos += strlen(event_log_tags);
+  static const char event_log_tags[] = "event-log-tags";
+  std::string::size_type pos = 0;
+  while ((pos = content.find(event_log_tags, pos)) != std::string::npos) {
+    pos += strlen(event_log_tags);
 
-        // must not be: 'Shared_Clean: 0 kB'
-        bool ok = isNotZero(content, pos, "Shared_Clean:") ||
-                  // If not /etc/event-log-tags, thus r/w, then half points
-                  // back for not 'Shared_Dirty: 0 kB'
-                  ((content.substr(pos - 5 - strlen(event_log_tags), 5) != "/etc/") &&
-                      isNotZero(content, pos, "Shared_Dirty:"));
-        if (ok && !pass_ok) {
-            shared_ok = true;
-        } else if (!ok) {
-            shared_ok = false;
-        }
-
-        // must be: 'Private_Dirty: 0 kB' and 'Private_Clean: 0 kB'
-        ok = isZero(content, pos, "Private_Dirty:") ||
-             isZero(content, pos, "Private_Clean:");
-        if (ok && !pass_ok) {
-            private_ok = true;
-        } else if (!ok) {
-            private_ok = false;
-        }
-
-        // must be: 'Anonymous: 0 kB'
-        ok = isZero(content, pos, "Anonymous:");
-        if (ok && !pass_ok) {
-            anonymous_ok = true;
-        } else if (!ok) {
-            anonymous_ok = false;
-        }
-
-        pass_ok = true;
+    // must not be: 'Shared_Clean: 0 kB'
+    bool ok =
+        isNotZero(content, pos, "Shared_Clean:") ||
+        // If not /etc/event-log-tags, thus r/w, then half points
+        // back for not 'Shared_Dirty: 0 kB'
+        ((content.substr(pos - 5 - strlen(event_log_tags), 5) != "/etc/") &&
+         isNotZero(content, pos, "Shared_Dirty:"));
+    if (ok && !pass_ok) {
+      shared_ok = true;
+    } else if (!ok) {
+      shared_ok = false;
     }
-    content = "";
 
-    if (!pass_ok) return;
-    if (shared_ok && anonymous_ok && private_ok) return;
+    // must be: 'Private_Dirty: 0 kB' and 'Private_Clean: 0 kB'
+    ok = isZero(content, pos, "Private_Dirty:") ||
+         isZero(content, pos, "Private_Clean:");
+    if (ok && !pass_ok) {
+      private_ok = true;
+    } else if (!ok) {
+      private_ok = false;
+    }
 
-    filename = android::base::StringPrintf("/proc/%d/comm", pid);
-    android::base::ReadFileToString(filename, &content);
-    content = android::base::StringPrintf("%d:%s",
-                  pid, content.substr(0, content.find("\n")).c_str());
+    // must be: 'Anonymous: 0 kB'
+    ok = isZero(content, pos, "Anonymous:");
+    if (ok && !pass_ok) {
+      anonymous_ok = true;
+    } else if (!ok) {
+      anonymous_ok = false;
+    }
 
-    EXPECT_TRUE(IsOk(shared_ok, content));
-    EXPECT_TRUE(IsOk(private_ok, content));
-    EXPECT_TRUE(IsOk(anonymous_ok, content));
+    pass_ok = true;
+  }
+  content = "";
+
+  if (!pass_ok) return;
+  if (shared_ok && anonymous_ok && private_ok) return;
+
+  filename = android::base::StringPrintf("/proc/%d/comm", pid);
+  android::base::ReadFileToString(filename, &content);
+  content = android::base::StringPrintf(
+      "%d:%s", pid, content.substr(0, content.find("\n")).c_str());
+
+  EXPECT_TRUE(IsOk(shared_ok, content));
+  EXPECT_TRUE(IsOk(private_ok, content));
+  EXPECT_TRUE(IsOk(anonymous_ok, content));
 }
-#endif // __ANDROID__
+#endif  // __ANDROID__
 
 TEST(liblog, event_log_tags) {
 #ifdef __ANDROID__
-    std::unique_ptr<DIR, int(*)(DIR*)> proc_dir(opendir("/proc"), closedir);
-    ASSERT_FALSE(!proc_dir);
+  std::unique_ptr<DIR, int (*)(DIR*)> proc_dir(opendir("/proc"), closedir);
+  ASSERT_FALSE(!proc_dir);
 
-    dirent* e;
-    while ((e = readdir(proc_dir.get()))) {
-        if (e->d_type != DT_DIR) continue;
-        if (!isdigit(e->d_name[0])) continue;
-        long long id = atoll(e->d_name);
-        if (id <= 0) continue;
-        pid_t pid = id;
-        if (id != pid) continue;
-        event_log_tags_test_smap(pid);
-    }
+  dirent* e;
+  while ((e = readdir(proc_dir.get()))) {
+    if (e->d_type != DT_DIR) continue;
+    if (!isdigit(e->d_name[0])) continue;
+    long long id = atoll(e->d_name);
+    if (id <= 0) continue;
+    pid_t pid = id;
+    if (id != pid) continue;
+    event_log_tags_test_smap(pid);
+  }
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
-#ifndef USING_LOGGER_LOCAL // Do not retest ratelimit
+#ifdef USING_LOGGER_DEFAULT  // Do not retest ratelimit
 TEST(liblog, __android_log_ratelimit) {
-    time_t state = 0;
+  time_t state = 0;
 
-    errno = 42;
-    // Prime
-    __android_log_ratelimit(3, &state);
-    EXPECT_EQ(errno, 42);
-    // Check
-    EXPECT_FALSE(__android_log_ratelimit(3, &state));
-    sleep(1);
-    EXPECT_FALSE(__android_log_ratelimit(3, &state));
-    sleep(4);
-    EXPECT_TRUE(__android_log_ratelimit(3, &state));
-    sleep(5);
-    EXPECT_TRUE(__android_log_ratelimit(3, &state));
+  errno = 42;
+  // Prime
+  __android_log_ratelimit(3, &state);
+  EXPECT_EQ(errno, 42);
+  // Check
+  EXPECT_FALSE(__android_log_ratelimit(3, &state));
+  sleep(1);
+  EXPECT_FALSE(__android_log_ratelimit(3, &state));
+  sleep(4);
+  EXPECT_TRUE(__android_log_ratelimit(3, &state));
+  sleep(5);
+  EXPECT_TRUE(__android_log_ratelimit(3, &state));
 
-    // API checks
-    IF_ALOG_RATELIMIT_LOCAL(3, &state) {
-        EXPECT_FALSE(0 != "IF_ALOG_RATELIMIT_LOCAL(3, &state)");
-    }
+  // API checks
+  IF_ALOG_RATELIMIT_LOCAL(3, &state) {
+    EXPECT_FALSE(0 != "IF_ALOG_RATELIMIT_LOCAL(3, &state)");
+  }
 
-    IF_ALOG_RATELIMIT() {
-        ;
-    } else {
-        EXPECT_TRUE(0 == "IF_ALOG_RATELIMIT()");
-    }
-    IF_ALOG_RATELIMIT() {
-        EXPECT_FALSE(0 != "IF_ALOG_RATELIMIT()");
-    }
-    // Do not test default seconds, to allow liblog to tune freely
+  IF_ALOG_RATELIMIT() {
+    ;
+  }
+  else {
+    EXPECT_TRUE(0 == "IF_ALOG_RATELIMIT()");
+  }
+  IF_ALOG_RATELIMIT() {
+    EXPECT_FALSE(0 != "IF_ALOG_RATELIMIT()");
+  }
+  // Do not test default seconds, to allow liblog to tune freely
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
 
-#ifndef USING_LOGGER_LOCAL // Do not retest event mapping functionality
+#ifdef USING_LOGGER_DEFAULT  // Do not retest event mapping functionality
 TEST(liblog, android_lookupEventTagNum) {
 #ifdef __ANDROID__
-    EventTagMap* map = android_openEventTagMap(NULL);
-    EXPECT_TRUE(NULL != map);
-    std::string Name = android::base::StringPrintf("a%d", getpid());
-    int tag = android_lookupEventTagNum(map, Name.c_str(), "(new|1)", ANDROID_LOG_UNKNOWN);
-    android_closeEventTagMap(map);
-    if (tag == -1) system("tail -3 /dev/event-log-tags >&2");
-    EXPECT_NE(-1, tag);
-    EXPECT_NE(0, tag);
-    EXPECT_GT(UINT32_MAX, (unsigned)tag);
+  EventTagMap* map = android_openEventTagMap(NULL);
+  EXPECT_TRUE(NULL != map);
+  std::string Name = android::base::StringPrintf("a%d", getpid());
+  int tag = android_lookupEventTagNum(map, Name.c_str(), "(new|1)",
+                                      ANDROID_LOG_UNKNOWN);
+  android_closeEventTagMap(map);
+  if (tag == -1) system("tail -3 /dev/event-log-tags >&2");
+  EXPECT_NE(-1, tag);
+  EXPECT_NE(0, tag);
+  EXPECT_GT(UINT32_MAX, (unsigned)tag);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-#endif // !USING_LOGGER_LOCAL
+#endif  // USING_LOGGER_DEFAULT
diff --git a/liblog/tests/liblog_test_default.cpp b/liblog/tests/liblog_test_default.cpp
index 079ba07..cbd0d25 100644
--- a/liblog/tests/liblog_test_default.cpp
+++ b/liblog/tests/liblog_test_default.cpp
@@ -1,5 +1,5 @@
 #ifdef __ANDROID__
-#include <log/log_frontend.h>
-#define TEST_PREFIX android_set_log_frontend(LOGGER_DEFAULT);
+#include <log/log_transport.h>
+#define TEST_PREFIX android_set_log_transport(LOGGER_DEFAULT);
 #endif
 #include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_local.cpp b/liblog/tests/liblog_test_local.cpp
index 5f7f645..9d7b3d7 100644
--- a/liblog/tests/liblog_test_local.cpp
+++ b/liblog/tests/liblog_test_local.cpp
@@ -1,4 +1,4 @@
-#include <log/log_frontend.h>
+#include <log/log_transport.h>
 #define liblog liblog_local
-#define TEST_PREFIX android_set_log_frontend(LOGGER_LOCAL);
+#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL);
 #include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_stderr.cpp b/liblog/tests/liblog_test_stderr.cpp
new file mode 100644
index 0000000..f9e4e1f
--- /dev/null
+++ b/liblog/tests/liblog_test_stderr.cpp
@@ -0,0 +1,5 @@
+#include <log/log_transport.h>
+#define liblog liblog_stderr
+#define TEST_PREFIX android_set_log_transport(LOGGER_STDERR);
+#define USING_LOGGER_STDERR
+#include "liblog_test.cpp"
diff --git a/liblog/tests/liblog_test_stderr_local.cpp b/liblog/tests/liblog_test_stderr_local.cpp
new file mode 100644
index 0000000..21406ca
--- /dev/null
+++ b/liblog/tests/liblog_test_stderr_local.cpp
@@ -0,0 +1,4 @@
+#include <log/log_transport.h>
+#define liblog liblog_stderr_local
+#define TEST_PREFIX android_set_log_transport(LOGGER_LOCAL | LOGGER_STDERR);
+#include "liblog_test.cpp"
diff --git a/liblog/tests/log_id_test.cpp b/liblog/tests/log_id_test.cpp
index b8223f1..c56fa8b 100644
--- a/liblog/tests/log_id_test.cpp
+++ b/liblog/tests/log_id_test.cpp
@@ -27,81 +27,76 @@
 // include file API purity.  We do however want to allow the _option_ that
 // log/log_id.h could include this file, or related content, in the future.
 #ifndef __android_LogPriority_defined
-# define ANDROID_LOG_INFO 4
+#define ANDROID_LOG_INFO 4
 #endif
 
 TEST(liblog, log_id) {
-    int count = 0;
+  int count = 0;
 
-    for(int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-        log_id_t id = static_cast<log_id_t>(i);
-        const char *name = android_log_id_to_name(id);
-        if (id != android_name_to_log_id(name)) {
-            continue;
-        }
-        ++count;
-        fprintf(stderr, "log buffer %s\r", name);
+  for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
+    log_id_t id = static_cast<log_id_t>(i);
+    const char* name = android_log_id_to_name(id);
+    if (id != android_name_to_log_id(name)) {
+      continue;
     }
-    ASSERT_EQ(LOG_ID_MAX, count);
+    ++count;
+    fprintf(stderr, "log buffer %s\r", name);
+  }
+  ASSERT_EQ(LOG_ID_MAX, count);
 }
 
 TEST(liblog, __android_log_buf_print) {
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_print",
-                                         "radio"));
-    usleep(1000);
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_print",
-                                         "system"));
-    usleep(1000);
-    EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_print",
-                                         "main"));
-    usleep(1000);
+  EXPECT_LT(0, __android_log_buf_print(LOG_ID_RADIO, ANDROID_LOG_INFO,
+                                       "TEST__android_log_buf_print", "radio"));
+  usleep(1000);
+  EXPECT_LT(0,
+            __android_log_buf_print(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
+                                    "TEST__android_log_buf_print", "system"));
+  usleep(1000);
+  EXPECT_LT(0, __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
+                                       "TEST__android_log_buf_print", "main"));
+  usleep(1000);
 }
 
 TEST(liblog, __android_log_buf_write) {
-    EXPECT_LT(0, __android_log_buf_write(LOG_ID_RADIO, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_write",
-                                         "radio"));
-    usleep(1000);
-    EXPECT_LT(0, __android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_write",
-                                         "system"));
-    usleep(1000);
-    EXPECT_LT(0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                         "TEST__android_log_buf_write",
-                                         "main"));
-    usleep(1000);
+  EXPECT_LT(0, __android_log_buf_write(LOG_ID_RADIO, ANDROID_LOG_INFO,
+                                       "TEST__android_log_buf_write", "radio"));
+  usleep(1000);
+  EXPECT_LT(0,
+            __android_log_buf_write(LOG_ID_SYSTEM, ANDROID_LOG_INFO,
+                                    "TEST__android_log_buf_write", "system"));
+  usleep(1000);
+  EXPECT_LT(0, __android_log_buf_write(LOG_ID_MAIN, ANDROID_LOG_INFO,
+                                       "TEST__android_log_buf_write", "main"));
+  usleep(1000);
 }
 
-static void* ConcurrentPrintFn(void *arg) {
-    int ret = __android_log_buf_print(LOG_ID_MAIN, ANDROID_LOG_INFO,
-                                  "TEST__android_log_print", "Concurrent %" PRIuPTR,
-                                  reinterpret_cast<uintptr_t>(arg));
-    return reinterpret_cast<void*>(ret);
+static void* ConcurrentPrintFn(void* arg) {
+  int ret = __android_log_buf_print(
+      LOG_ID_MAIN, ANDROID_LOG_INFO, "TEST__android_log_print",
+      "Concurrent %" PRIuPTR, reinterpret_cast<uintptr_t>(arg));
+  return reinterpret_cast<void*>(ret);
 }
 
 #define NUM_CONCURRENT 64
-#define _concurrent_name(a,n) a##__concurrent##n
-#define concurrent_name(a,n) _concurrent_name(a,n)
+#define _concurrent_name(a, n) a##__concurrent##n
+#define concurrent_name(a, n) _concurrent_name(a, n)
 
 TEST(liblog, concurrent_name(__android_log_buf_print, NUM_CONCURRENT)) {
-    pthread_t t[NUM_CONCURRENT];
-    int i;
-    for (i=0; i < NUM_CONCURRENT; i++) {
-        ASSERT_EQ(0, pthread_create(&t[i], NULL,
-                                    ConcurrentPrintFn,
-                                    reinterpret_cast<void *>(i)));
+  pthread_t t[NUM_CONCURRENT];
+  int i;
+  for (i = 0; i < NUM_CONCURRENT; i++) {
+    ASSERT_EQ(0, pthread_create(&t[i], NULL, ConcurrentPrintFn,
+                                reinterpret_cast<void*>(i)));
+  }
+  int ret = 0;
+  for (i = 0; i < NUM_CONCURRENT; i++) {
+    void* result;
+    ASSERT_EQ(0, pthread_join(t[i], &result));
+    int this_result = reinterpret_cast<uintptr_t>(result);
+    if ((0 == ret) && (0 != this_result)) {
+      ret = this_result;
     }
-    int ret = 0;
-    for (i=0; i < NUM_CONCURRENT; i++) {
-        void* result;
-        ASSERT_EQ(0, pthread_join(t[i], &result));
-        int this_result = reinterpret_cast<uintptr_t>(result);
-        if ((0 == ret) && (0 != this_result)) {
-            ret = this_result;
-        }
-    }
-    ASSERT_LT(0, ret);
+  }
+  ASSERT_LT(0, ret);
 }
diff --git a/liblog/tests/log_radio_test.cpp b/liblog/tests/log_radio_test.cpp
index ecba777..f202c67 100644
--- a/liblog/tests/log_radio_test.cpp
+++ b/liblog/tests/log_radio_test.cpp
@@ -27,91 +27,93 @@
 #include <log/log_radio.h>
 
 TEST(liblog, RLOG) {
-    static const char content[] = "log_radio.h";
-    static const char content_false[] = "log_radio.h false";
+  static const char content[] = "log_radio.h";
+  static const char content_false[] = "log_radio.h false";
 
-    // ratelimit content to 10/s to keep away from spam filters
-    // do not send identical content together to keep away from spam filters
+// ratelimit content to 10/s to keep away from spam filters
+// do not send identical content together to keep away from spam filters
 
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGV"
-    RLOGV(content);
-    usleep(100000);
+  RLOGV(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGD"
-    RLOGD(content);
-    usleep(100000);
+  RLOGD(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGI"
-    RLOGI(content);
-    usleep(100000);
+  RLOGI(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGW"
-    RLOGW(content);
-    usleep(100000);
+  RLOGW(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGE"
-    RLOGE(content);
-    usleep(100000);
+  RLOGE(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGV"
-    RLOGV_IF(true, content);
-    usleep(100000);
-    RLOGV_IF(false, content_false);
-    usleep(100000);
+  RLOGV_IF(true, content);
+  usleep(100000);
+  RLOGV_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGD"
-    RLOGD_IF(true, content);
-    usleep(100000);
-    RLOGD_IF(false, content_false);
-    usleep(100000);
+  RLOGD_IF(true, content);
+  usleep(100000);
+  RLOGD_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGI"
-    RLOGI_IF(true, content);
-    usleep(100000);
-    RLOGI_IF(false, content_false);
-    usleep(100000);
+  RLOGI_IF(true, content);
+  usleep(100000);
+  RLOGI_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGW"
-    RLOGW_IF(true, content);
-    usleep(100000);
-    RLOGW_IF(false, content_false);
-    usleep(100000);
+  RLOGW_IF(true, content);
+  usleep(100000);
+  RLOGW_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__RLOGE"
-    RLOGE_IF(true, content);
-    usleep(100000);
-    RLOGE_IF(false, content_false);
+  RLOGE_IF(true, content);
+  usleep(100000);
+  RLOGE_IF(false, content_false);
 
 #ifdef __ANDROID__
-    // give time for content to long-path through logger
-    sleep(1);
+  // give time for content to long-path through logger
+  sleep(1);
 
-    std::string buf = android::base::StringPrintf(
-        "logcat -b radio --pid=%u -d -s"
-            " TEST__RLOGV TEST__RLOGD TEST__RLOGI TEST__RLOGW TEST__RLOGE",
-        (unsigned)getpid());
-    FILE* fp = popen(buf.c_str(), "r");
-    int count = 0;
-    int count_false = 0;
-    if (fp) {
-        if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
-        pclose(fp);
-        for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos; ++pos) {
-            ++count;
-        }
-        for (size_t pos = 0; (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
-            ++count_false;
-        }
+  std::string buf = android::base::StringPrintf(
+      "logcat -b radio --pid=%u -d -s"
+      " TEST__RLOGV TEST__RLOGD TEST__RLOGI TEST__RLOGW TEST__RLOGE",
+      (unsigned)getpid());
+  FILE* fp = popen(buf.c_str(), "r");
+  int count = 0;
+  int count_false = 0;
+  if (fp) {
+    if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
+    pclose(fp);
+    for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos;
+         ++pos) {
+      ++count;
     }
-    EXPECT_EQ(0, count_false);
+    for (size_t pos = 0;
+         (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
+      ++count_false;
+    }
+  }
+  EXPECT_EQ(0, count_false);
 #if LOG_NDEBUG
-    ASSERT_EQ(8, count);
+  ASSERT_EQ(8, count);
 #else
-    ASSERT_EQ(10, count);
+  ASSERT_EQ(10, count);
 #endif
 
 #else
-    GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
+  GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
 #endif
 }
diff --git a/liblog/tests/log_read_test.cpp b/liblog/tests/log_read_test.cpp
index 2e02407..a63ab8e 100644
--- a/liblog/tests/log_read_test.cpp
+++ b/liblog/tests/log_read_test.cpp
@@ -20,8 +20,8 @@
 
 #include <string>
 
-#include <android/log.h> // minimal logging API
 #include <android-base/stringprintf.h>
+#include <android/log.h>  // minimal logging API
 #include <gtest/gtest.h>
 // Test the APIs in this standalone include file
 #include <log/log_read.h>
@@ -29,90 +29,90 @@
 
 TEST(liblog, __android_log_write__android_logger_list_read) {
 #ifdef __ANDROID__
-    pid_t pid = getpid();
+  pid_t pid = getpid();
 
-    struct logger_list *logger_list;
-    ASSERT_TRUE(NULL != (logger_list = android_logger_list_open(
-        LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
+  struct logger_list* logger_list;
+  ASSERT_TRUE(
+      NULL !=
+      (logger_list = android_logger_list_open(
+           LOG_ID_MAIN, ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK, 1000, pid)));
 
-    struct timespec ts;
-    clock_gettime(CLOCK_MONOTONIC, &ts);
-    std::string buf = android::base::StringPrintf("pid=%u ts=%ld.%09ld",
-                                                  pid, ts.tv_sec, ts.tv_nsec);
-    static const char tag[] = "liblog.__android_log_write__android_logger_list_read";
-    static const char prio = ANDROID_LOG_DEBUG;
-    ASSERT_LT(0, __android_log_write(prio, tag, buf.c_str()));
-    usleep(1000000);
+  struct timespec ts;
+  clock_gettime(CLOCK_MONOTONIC, &ts);
+  std::string buf = android::base::StringPrintf("pid=%u ts=%ld.%09ld", pid,
+                                                ts.tv_sec, ts.tv_nsec);
+  static const char tag[] =
+      "liblog.__android_log_write__android_logger_list_read";
+  static const char prio = ANDROID_LOG_DEBUG;
+  ASSERT_LT(0, __android_log_write(prio, tag, buf.c_str()));
+  usleep(1000000);
 
-    buf = std::string(&prio, sizeof(prio)) +
-          tag +
-          std::string("", 1) +
-          buf +
-          std::string("", 1);
+  buf = std::string(&prio, sizeof(prio)) + tag + std::string("", 1) + buf +
+        std::string("", 1);
 
-    int count = 0;
+  int count = 0;
 
-    for (;;) {
-        log_msg log_msg;
-        if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
+  for (;;) {
+    log_msg log_msg;
+    if (android_logger_list_read(logger_list, &log_msg) <= 0) break;
 
-        EXPECT_EQ(log_msg.entry.pid, pid);
-        // There may be a future where we leak "liblog" tagged LOG_ID_EVENT
-        // binary messages through so that logger losses can be correlated?
-        EXPECT_EQ(log_msg.id(), LOG_ID_MAIN);
+    EXPECT_EQ(log_msg.entry.pid, pid);
+    // There may be a future where we leak "liblog" tagged LOG_ID_EVENT
+    // binary messages through so that logger losses can be correlated?
+    EXPECT_EQ(log_msg.id(), LOG_ID_MAIN);
 
-        if (log_msg.entry.len != buf.length()) continue;
+    if (log_msg.entry.len != buf.length()) continue;
 
-        if (buf != std::string(log_msg.msg(), log_msg.entry.len)) continue;
+    if (buf != std::string(log_msg.msg(), log_msg.entry.len)) continue;
 
-        ++count;
-    }
-    android_logger_list_close(logger_list);
+    ++count;
+  }
+  android_logger_list_close(logger_list);
 
-    EXPECT_EQ(1, count);
+  EXPECT_EQ(1, count);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
 
 TEST(liblog, android_logger_get_) {
 #ifdef __ANDROID__
-    // This test assumes the log buffers are filled with noise from
-    // normal operations. It will fail if done immediately after a
-    // logcat -c.
-    struct logger_list * logger_list = android_logger_list_alloc(ANDROID_LOG_WRONLY, 0, 0);
+  // This test assumes the log buffers are filled with noise from
+  // normal operations. It will fail if done immediately after a
+  // logcat -c.
+  struct logger_list* logger_list =
+      android_logger_list_alloc(ANDROID_LOG_WRONLY, 0, 0);
 
-    for(int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
-        log_id_t id = static_cast<log_id_t>(i);
-        const char *name = android_log_id_to_name(id);
-        if (id != android_name_to_log_id(name)) {
-            continue;
-        }
-        fprintf(stderr, "log buffer %s\r", name);
-        struct logger * logger;
-        EXPECT_TRUE(NULL != (logger = android_logger_open(logger_list, id)));
-        EXPECT_EQ(id, android_logger_get_id(logger));
-        ssize_t get_log_size = android_logger_get_log_size(logger);
-        /* security buffer is allowed to be denied */
-        if (strcmp("security", name)) {
-            EXPECT_LT(0, get_log_size);
-            /* crash buffer is allowed to be empty, that is actually healthy! */
-            EXPECT_LE((strcmp("crash", name)) != 0,
-                      android_logger_get_log_readable_size(logger));
-        } else {
-            EXPECT_NE(0, get_log_size);
-            if (get_log_size < 0) {
-                EXPECT_GT(0, android_logger_get_log_readable_size(logger));
-            } else {
-                EXPECT_LE(0, android_logger_get_log_readable_size(logger));
-            }
-        }
-        EXPECT_LT(0, android_logger_get_log_version(logger));
+  for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
+    log_id_t id = static_cast<log_id_t>(i);
+    const char* name = android_log_id_to_name(id);
+    if (id != android_name_to_log_id(name)) {
+      continue;
     }
+    fprintf(stderr, "log buffer %s\r", name);
+    struct logger* logger;
+    EXPECT_TRUE(NULL != (logger = android_logger_open(logger_list, id)));
+    EXPECT_EQ(id, android_logger_get_id(logger));
+    ssize_t get_log_size = android_logger_get_log_size(logger);
+    /* security buffer is allowed to be denied */
+    if (strcmp("security", name)) {
+      EXPECT_LT(0, get_log_size);
+      /* crash buffer is allowed to be empty, that is actually healthy! */
+      EXPECT_LE((strcmp("crash", name)) != 0,
+                android_logger_get_log_readable_size(logger));
+    } else {
+      EXPECT_NE(0, get_log_size);
+      if (get_log_size < 0) {
+        EXPECT_GT(0, android_logger_get_log_readable_size(logger));
+      } else {
+        EXPECT_LE(0, android_logger_get_log_readable_size(logger));
+      }
+    }
+    EXPECT_LT(0, android_logger_get_log_version(logger));
+  }
 
-    android_logger_list_close(logger_list);
+  android_logger_list_close(logger_list);
 #else
-    GTEST_LOG_(INFO) << "This test does nothing.\n";
+  GTEST_LOG_(INFO) << "This test does nothing.\n";
 #endif
 }
-
diff --git a/liblog/tests/log_system_test.cpp b/liblog/tests/log_system_test.cpp
index 40e3a63..0656c0b 100644
--- a/liblog/tests/log_system_test.cpp
+++ b/liblog/tests/log_system_test.cpp
@@ -27,91 +27,93 @@
 #include <log/log_system.h>
 
 TEST(liblog, SLOG) {
-    static const char content[] = "log_system.h";
-    static const char content_false[] = "log_system.h false";
+  static const char content[] = "log_system.h";
+  static const char content_false[] = "log_system.h false";
 
-    // ratelimit content to 10/s to keep away from spam filters
-    // do not send identical content together to keep away from spam filters
+// ratelimit content to 10/s to keep away from spam filters
+// do not send identical content together to keep away from spam filters
 
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGV"
-    SLOGV(content);
-    usleep(100000);
+  SLOGV(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGD"
-    SLOGD(content);
-    usleep(100000);
+  SLOGD(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGI"
-    SLOGI(content);
-    usleep(100000);
+  SLOGI(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGW"
-    SLOGW(content);
-    usleep(100000);
+  SLOGW(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGE"
-    SLOGE(content);
-    usleep(100000);
+  SLOGE(content);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGV"
-    SLOGV_IF(true, content);
-    usleep(100000);
-    SLOGV_IF(false, content_false);
-    usleep(100000);
+  SLOGV_IF(true, content);
+  usleep(100000);
+  SLOGV_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGD"
-    SLOGD_IF(true, content);
-    usleep(100000);
-    SLOGD_IF(false, content_false);
-    usleep(100000);
+  SLOGD_IF(true, content);
+  usleep(100000);
+  SLOGD_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGI"
-    SLOGI_IF(true, content);
-    usleep(100000);
-    SLOGI_IF(false, content_false);
-    usleep(100000);
+  SLOGI_IF(true, content);
+  usleep(100000);
+  SLOGI_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGW"
-    SLOGW_IF(true, content);
-    usleep(100000);
-    SLOGW_IF(false, content_false);
-    usleep(100000);
+  SLOGW_IF(true, content);
+  usleep(100000);
+  SLOGW_IF(false, content_false);
+  usleep(100000);
 #undef LOG_TAG
 #define LOG_TAG "TEST__SLOGE"
-    SLOGE_IF(true, content);
-    usleep(100000);
-    SLOGE_IF(false, content_false);
+  SLOGE_IF(true, content);
+  usleep(100000);
+  SLOGE_IF(false, content_false);
 
 #ifdef __ANDROID__
-    // give time for content to long-path through logger
-    sleep(1);
+  // give time for content to long-path through logger
+  sleep(1);
 
-    std::string buf = android::base::StringPrintf(
-        "logcat -b system --pid=%u -d -s"
-            " TEST__SLOGV TEST__SLOGD TEST__SLOGI TEST__SLOGW TEST__SLOGE",
-        (unsigned)getpid());
-    FILE* fp = popen(buf.c_str(), "r");
-    int count = 0;
-    int count_false = 0;
-    if (fp) {
-        if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
-        pclose(fp);
-        for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos; ++pos) {
-            ++count;
-        }
-        for (size_t pos = 0; (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
-            ++count_false;
-        }
+  std::string buf = android::base::StringPrintf(
+      "logcat -b system --pid=%u -d -s"
+      " TEST__SLOGV TEST__SLOGD TEST__SLOGI TEST__SLOGW TEST__SLOGE",
+      (unsigned)getpid());
+  FILE* fp = popen(buf.c_str(), "r");
+  int count = 0;
+  int count_false = 0;
+  if (fp) {
+    if (!android::base::ReadFdToString(fileno(fp), &buf)) buf = "";
+    pclose(fp);
+    for (size_t pos = 0; (pos = buf.find(content, pos)) != std::string::npos;
+         ++pos) {
+      ++count;
     }
-    EXPECT_EQ(0, count_false);
+    for (size_t pos = 0;
+         (pos = buf.find(content_false, pos)) != std::string::npos; ++pos) {
+      ++count_false;
+    }
+  }
+  EXPECT_EQ(0, count_false);
 #if LOG_NDEBUG
-    ASSERT_EQ(8, count);
+  ASSERT_EQ(8, count);
 #else
-    ASSERT_EQ(10, count);
+  ASSERT_EQ(10, count);
 #endif
 
 #else
-    GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
+  GTEST_LOG_(INFO) << "This test does not test end-to-end.\n";
 #endif
 }
diff --git a/liblog/tests/log_time_test.cpp b/liblog/tests/log_time_test.cpp
index 59655ba..0ae1d18 100644
--- a/liblog/tests/log_time_test.cpp
+++ b/liblog/tests/log_time_test.cpp
@@ -22,16 +22,16 @@
 
 TEST(liblog, log_time) {
 #ifdef _SYSTEM_CORE_INCLUDE_PRIVATE_ANDROID_LOGGER_H_
-    log_time(CLOCK_MONOTONIC);
+  log_time(CLOCK_MONOTONIC);
 
-    EXPECT_EQ(log_time, log_time::EPOCH);
+  EXPECT_EQ(log_time, log_time::EPOCH);
 #endif
 
-    struct timespec ts;
-    clock_gettime(CLOCK_MONOTONIC, &ts);
-    log_time tl(ts);
+  struct timespec ts;
+  clock_gettime(CLOCK_MONOTONIC, &ts);
+  log_time tl(ts);
 
-    EXPECT_EQ(tl, ts);
-    EXPECT_GE(tl, ts);
-    EXPECT_LE(tl, ts);
+  EXPECT_EQ(tl, ts);
+  EXPECT_GE(tl, ts);
+  EXPECT_LE(tl, ts);
 }
diff --git a/liblog/uio.c b/liblog/uio.c
index ac0558f..e127202 100644
--- a/liblog/uio.c
+++ b/liblog/uio.c
@@ -22,58 +22,52 @@
 
 #include "log_portability.h"
 
-LIBLOG_ABI_PUBLIC int readv(int fd, struct iovec *vecs, int count)
-{
-    int   total = 0;
+LIBLOG_ABI_PUBLIC int readv(int fd, struct iovec* vecs, int count) {
+  int total = 0;
 
-    for ( ; count > 0; count--, vecs++ ) {
-        char*  buf = vecs->iov_base;
-        int    len = vecs->iov_len;
+  for (; count > 0; count--, vecs++) {
+    char* buf = vecs->iov_base;
+    int len = vecs->iov_len;
 
-        while (len > 0) {
-            int  ret = read( fd, buf, len );
-            if (ret < 0) {
-                if (total == 0)
-                    total = -1;
-                goto Exit;
-            }
-            if (ret == 0)
-                goto Exit;
+    while (len > 0) {
+      int ret = read(fd, buf, len);
+      if (ret < 0) {
+        if (total == 0) total = -1;
+        goto Exit;
+      }
+      if (ret == 0) goto Exit;
 
-            total += ret;
-            buf   += ret;
-            len   -= ret;
-        }
+      total += ret;
+      buf += ret;
+      len -= ret;
     }
+  }
 Exit:
-    return total;
+  return total;
 }
 
-LIBLOG_ABI_PUBLIC int writev(int fd, const struct iovec *vecs, int count)
-{
-    int   total = 0;
+LIBLOG_ABI_PUBLIC int writev(int fd, const struct iovec* vecs, int count) {
+  int total = 0;
 
-    for ( ; count > 0; count--, vecs++ ) {
-        const char*  buf = vecs->iov_base;
-        int          len = vecs->iov_len;
+  for (; count > 0; count--, vecs++) {
+    const char* buf = vecs->iov_base;
+    int len = vecs->iov_len;
 
-        while (len > 0) {
-            int  ret = write( fd, buf, len );
-            if (ret < 0) {
-                if (total == 0)
-                    total = -1;
-                goto Exit;
-            }
-            if (ret == 0)
-                goto Exit;
+    while (len > 0) {
+      int ret = write(fd, buf, len);
+      if (ret < 0) {
+        if (total == 0) total = -1;
+        goto Exit;
+      }
+      if (ret == 0) goto Exit;
 
-            total += ret;
-            buf   += ret;
-            len   -= ret;
-        }
+      total += ret;
+      buf += ret;
+      len -= ret;
     }
+  }
 Exit:
-    return total;
+  return total;
 }
 
 #endif
diff --git a/libutils/include/utils/Condition.h b/libutils/include/utils/Condition.h
index 2c80acd..3019a21 100644
--- a/libutils/include/utils/Condition.h
+++ b/libutils/include/utils/Condition.h
@@ -41,6 +41,11 @@
  * call wait(), then either re-wait() if things aren't quite what you want,
  * or unlock the mutex and continue.  All threads calling wait() must
  * use the same mutex for a given Condition.
+ *
+ * On Android and Apple platforms, these are implemented as a simple wrapper
+ * around pthread condition variables.  Care must be taken to abide by
+ * the pthreads semantics, in particular, a boolean predicate must
+ * be re-evaluated after a wake-up, as spurious wake-ups may happen.
  */
 class Condition {
 public:
@@ -58,10 +63,11 @@
     explicit Condition(int type);
     ~Condition();
     // Wait on the condition variable.  Lock the mutex before calling.
+    // Note that spurious wake-ups may happen.
     status_t wait(Mutex& mutex);
     // same with relative timeout
     status_t waitRelative(Mutex& mutex, nsecs_t reltime);
-    // Signal the condition variable, allowing exactly one thread to continue.
+    // Signal the condition variable, allowing one thread to continue.
     void signal();
     // Signal the condition variable, allowing one or all threads to continue.
     void signal(WakeUpType type) {
@@ -142,17 +148,6 @@
     return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts);
 }
 inline void Condition::signal() {
-    /*
-     * POSIX says pthread_cond_signal wakes up "one or more" waiting threads.
-     * However bionic follows the glibc guarantee which wakes up "exactly one"
-     * waiting thread.
-     *
-     * man 3 pthread_cond_signal
-     *   pthread_cond_signal restarts one of the threads that are waiting on
-     *   the condition variable cond. If no threads are waiting on cond,
-     *   nothing happens. If several threads are waiting on cond, exactly one
-     *   is restarted, but it is not specified which.
-     */
     pthread_cond_signal(&mCond);
 }
 inline void Condition::broadcast() {
diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h
index 07c4de7..f6433a8 100644
--- a/libutils/include/utils/String16.h
+++ b/libutils/include/utils/String16.h
@@ -67,7 +67,10 @@
 
     inline  const char16_t*     string() const;
 
+//TODO(b/35363681): remove
+private:
     static inline std::string   std_string(const String16& str);
+public:
             size_t              size() const;
             void                setTo(const String16& other);
             status_t            setTo(const char16_t* other);
diff --git a/libutils/include/utils/String8.h b/libutils/include/utils/String8.h
index 1d12994..f5f9219 100644
--- a/libutils/include/utils/String8.h
+++ b/libutils/include/utils/String8.h
@@ -64,8 +64,14 @@
     static String8              format(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
     static String8              formatV(const char* fmt, va_list args);
 
+    inline  const char*         c_str() const;
     inline  const char*         string() const;
+
+// TODO(b/35363681): remove
+private:
     static inline std::string   std_string(const String8& str);
+public:
+
     inline  size_t              size() const;
     inline  size_t              bytes() const;
     inline  bool                isEmpty() const;
@@ -259,6 +265,10 @@
     return String8();
 }
 
+inline const char* String8::c_str() const
+{
+    return mString;
+}
 inline const char* String8::string() const
 {
     return mString;
diff --git a/logcat/Android.mk b/logcat/Android.mk
index 723c35e..f564f0f 100644
--- a/logcat/Android.mk
+++ b/logcat/Android.mk
@@ -16,7 +16,7 @@
 include $(CLEAR_VARS)
 
 LOCAL_MODULE := liblogcat
-LOCAL_SRC_FILES := logcat.cpp logcat_system.cpp
+LOCAL_SRC_FILES := logcat.cpp getopt_long.cpp logcat_system.cpp
 LOCAL_SHARED_LIBRARIES := $(logcatLibs)
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
 LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
diff --git a/logcat/getopt_long.cpp b/logcat/getopt_long.cpp
new file mode 100644
index 0000000..5f8dd66
--- /dev/null
+++ b/logcat/getopt_long.cpp
@@ -0,0 +1,402 @@
+/* $OpenBSD: getopt_long.c,v 1.26 2013/06/08 22:47:56 millert Exp $ */
+/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $       */
+
+/*
+ * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Sponsored in part by the Defense Advanced Research Projects
+ * Agency (DARPA) and Air Force Research Laboratory, Air Force
+ * Materiel Command, USAF, under agreement number F39502-99-1-0512.
+ */
+/*-
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Dieter Baron and Thomas Klausner.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/cdefs.h>
+
+#include <log/getopt.h>
+
+#define PRINT_ERROR ((context->opterr) && (*options != ':'))
+
+#define FLAG_PERMUTE 0x01  // permute non-options to the end of argv
+#define FLAG_ALLARGS 0x02  // treat non-options as args to option "-1"
+
+// return values
+#define BADCH (int)'?'
+#define BADARG ((*options == ':') ? (int)':' : (int)'?')
+#define INORDER (int)1
+
+#define D_PREFIX 0
+#define DD_PREFIX 1
+#define W_PREFIX 2
+
+// Compute the greatest common divisor of a and b.
+static int gcd(int a, int b) {
+    int c = a % b;
+    while (c) {
+        a = b;
+        b = c;
+        c = a % b;
+    }
+    return b;
+}
+
+// Exchange the block from nonopt_start to nonopt_end with the block from
+// nonopt_end to opt_end (keeping the same order of arguments in each block).
+// Returns optind - (nonopt_end - nonopt_start) for convenience.
+static int permute_args(getopt_context* context, char* const* nargv) {
+    // compute lengths of blocks and number and size of cycles
+    int nnonopts = context->nonopt_end - context->nonopt_start;
+    int nopts = context->optind - context->nonopt_end;
+    int ncycle = gcd(nnonopts, nopts);
+    int cyclelen = (context->optind - context->nonopt_start) / ncycle;
+
+    for (int i = 0; i < ncycle; i++) {
+        int cstart = context->nonopt_end + i;
+        int pos = cstart;
+        for (int j = 0; j < cyclelen; j++) {
+            if (pos >= context->nonopt_end) {
+                pos -= nnonopts;
+            } else {
+                pos += nopts;
+            }
+            char* swap = nargv[pos];
+            const_cast<char**>(nargv)[pos] = nargv[cstart];
+            const_cast<char**>(nargv)[cstart] = swap;
+        }
+    }
+    return context->optind - (context->nonopt_end - context->nonopt_start);
+}
+
+// parse_long_options_r --
+//    Parse long options in argc/argv argument vector.
+// Returns -1 if short_too is set and the option does not match long_options.
+static int parse_long_options_r(char* const* nargv, const char* options,
+                                const struct option* long_options, int* idx,
+                                bool short_too, struct getopt_context* context) {
+    const char* current_argv = context->place;
+    const char* current_dash;
+    switch (context->dash_prefix) {
+        case D_PREFIX:
+            current_dash = "-";
+            break;
+        case DD_PREFIX:
+            current_dash = "--";
+            break;
+        case W_PREFIX:
+            current_dash = "-W ";
+            break;
+        default:
+            current_dash = "";
+            break;
+    }
+    context->optind++;
+
+    const char* has_equal;
+    size_t current_argv_len;
+    if (!!(has_equal = strchr(current_argv, '='))) {
+        // argument found (--option=arg)
+        current_argv_len = has_equal - current_argv;
+        has_equal++;
+    } else {
+        current_argv_len = strlen(current_argv);
+    }
+
+    int match = -1;
+    bool exact_match = false;
+    bool second_partial_match = false;
+    for (int i = 0; long_options[i].name; i++) {
+        // find matching long option
+        if (strncmp(current_argv, long_options[i].name, current_argv_len)) {
+            continue;
+        }
+
+        if (strlen(long_options[i].name) == current_argv_len) {
+            // exact match
+            match = i;
+            exact_match = true;
+            break;
+        }
+        // If this is a known short option, don't allow
+        // a partial match of a single character.
+        if (short_too && current_argv_len == 1) continue;
+
+        if (match == -1) {  // first partial match
+            match = i;
+        } else if (long_options[i].has_arg != long_options[match].has_arg ||
+                   long_options[i].flag != long_options[match].flag ||
+                   long_options[i].val != long_options[match].val) {
+            second_partial_match = true;
+        }
+    }
+    if (!exact_match && second_partial_match) {
+        // ambiguous abbreviation
+        if (PRINT_ERROR) {
+            fprintf(context->optstderr ?: stderr,
+                    "option `%s%.*s' is ambiguous", current_dash,
+                    (int)current_argv_len, current_argv);
+        }
+        context->optopt = 0;
+        return BADCH;
+    }
+    if (match != -1) {  // option found
+        if (long_options[match].has_arg == no_argument && has_equal) {
+            if (PRINT_ERROR) {
+                fprintf(context->optstderr ?: stderr,
+                        "option `%s%.*s' doesn't allow an argument",
+                        current_dash, (int)current_argv_len, current_argv);
+            }
+            // XXX: GNU sets optopt to val regardless of flag
+            context->optopt =
+                long_options[match].flag ? 0 : long_options[match].val;
+            return BADCH;
+        }
+        if (long_options[match].has_arg == required_argument ||
+            long_options[match].has_arg == optional_argument) {
+            if (has_equal) {
+                context->optarg = has_equal;
+            } else if (long_options[match].has_arg == required_argument) {
+                // optional argument doesn't use next nargv
+                context->optarg = nargv[context->optind++];
+            }
+        }
+        if ((long_options[match].has_arg == required_argument) &&
+            !context->optarg) {
+            // Missing argument; leading ':' indicates no error
+            // should be generated.
+            if (PRINT_ERROR) {
+                fprintf(context->optstderr ?: stderr,
+                        "option `%s%s' requires an argument", current_dash,
+                        current_argv);
+            }
+            // XXX: GNU sets optopt to val regardless of flag
+            context->optopt =
+                long_options[match].flag ? 0 : long_options[match].val;
+            context->optind--;
+            return BADARG;
+        }
+    } else {  // unknown option
+        if (short_too) {
+            context->optind--;
+            return -1;
+        }
+        if (PRINT_ERROR) {
+            fprintf(context->optstderr ?: stderr, "unrecognized option `%s%s'",
+                    current_dash, current_argv);
+        }
+        context->optopt = 0;
+        return BADCH;
+    }
+    if (idx) *idx = match;
+    if (long_options[match].flag) {
+        *long_options[match].flag = long_options[match].val;
+        return 0;
+    }
+    return long_options[match].val;
+}
+
+// getopt_long_r --
+//    Parse argc/argv argument vector.
+int getopt_long_r(int nargc, char* const* nargv, const char* options,
+                  const struct option* long_options, int* idx,
+                  struct getopt_context* context) {
+    if (!options) return -1;
+
+    // XXX Some GNU programs (like cvs) set optind to 0 instead of
+    // XXX using optreset.  Work around this braindamage.
+    if (!context->optind) context->optind = context->optreset = 1;
+
+    // Disable GNU extensions if options string begins with a '+'.
+    int flags = FLAG_PERMUTE;
+    if (*options == '-') {
+        flags |= FLAG_ALLARGS;
+    } else if (*options == '+') {
+        flags &= ~FLAG_PERMUTE;
+    }
+    if (*options == '+' || *options == '-') options++;
+
+    context->optarg = nullptr;
+    if (context->optreset) context->nonopt_start = context->nonopt_end = -1;
+start:
+    if (context->optreset || !*context->place) {  // update scanning pointer
+        context->optreset = 0;
+        if (context->optind >= nargc) {  // end of argument vector
+            context->place = EMSG;
+            if (context->nonopt_end != -1) {
+                // do permutation, if we have to
+                context->optind = permute_args(context, nargv);
+            } else if (context->nonopt_start != -1) {
+                // If we skipped non-options, set optind to the first of them.
+                context->optind = context->nonopt_start;
+            }
+            context->nonopt_start = context->nonopt_end = -1;
+            return -1;
+        }
+        if (*(context->place = nargv[context->optind]) != '-' ||
+            context->place[1] == '\0') {
+            context->place = EMSG;  // found non-option
+            if (flags & FLAG_ALLARGS) {
+                // GNU extension: return non-option as argument to option 1
+                context->optarg = nargv[context->optind++];
+                return INORDER;
+            }
+            if (!(flags & FLAG_PERMUTE)) {
+                // If no permutation wanted, stop parsing at first non-option.
+                return -1;
+            }
+            // do permutation
+            if (context->nonopt_start == -1) {
+                context->nonopt_start = context->optind;
+            } else if (context->nonopt_end != -1) {
+                context->nonopt_start = permute_args(context, nargv);
+                context->nonopt_end = -1;
+            }
+            context->optind++;
+            // process next argument
+            goto start;
+        }
+        if (context->nonopt_start != -1 && context->nonopt_end == -1) {
+            context->nonopt_end = context->optind;
+        }
+
+        // If we have "-" do nothing, if "--" we are done.
+        if (context->place[1] != '\0' && *++(context->place) == '-' &&
+            context->place[1] == '\0') {
+            context->optind++;
+            context->place = EMSG;
+            // We found an option (--), so if we skipped
+            // non-options, we have to permute.
+            if (context->nonopt_end != -1) {
+                context->optind = permute_args(context, nargv);
+            }
+            context->nonopt_start = context->nonopt_end = -1;
+            return -1;
+        }
+    }
+
+    int optchar;
+    // Check long options if:
+    //  1) we were passed some
+    //  2) the arg is not just "-"
+    //  3) either the arg starts with -- we are getopt_long_only()
+    if (long_options && context->place != nargv[context->optind] &&
+        (*context->place == '-')) {
+        bool short_too = false;
+        context->dash_prefix = D_PREFIX;
+        if (*context->place == '-') {
+            context->place++;  // --foo long option
+            context->dash_prefix = DD_PREFIX;
+        } else if (*context->place != ':' && strchr(options, *context->place)) {
+            short_too = true;  // could be short option too
+        }
+
+        optchar = parse_long_options_r(nargv, options, long_options, idx,
+                                       short_too, context);
+        if (optchar != -1) {
+            context->place = EMSG;
+            return optchar;
+        }
+    }
+
+    const char* oli;  // option letter list index
+    if ((optchar = (int)*(context->place)++) == (int)':' ||
+        (optchar == (int)'-' && *context->place != '\0') ||
+        !(oli = strchr(options, optchar))) {
+        // If the user specified "-" and  '-' isn't listed in
+        // options, return -1 (non-option) as per POSIX.
+        // Otherwise, it is an unknown option character (or ':').
+        if (optchar == (int)'-' && *context->place == '\0') return -1;
+        if (!*context->place) context->optind++;
+        if (PRINT_ERROR) {
+            fprintf(context->optstderr ?: stderr, "invalid option -- %c",
+                    optchar);
+        }
+        context->optopt = optchar;
+        return BADCH;
+    }
+
+    static const char recargchar[] = "option requires an argument -- %c";
+    if (long_options && optchar == 'W' && oli[1] == ';') {
+        // -W long-option
+        if (*context->place) {                      // no space
+            ;                                       // NOTHING
+        } else if (++(context->optind) >= nargc) {  // no arg
+            context->place = EMSG;
+            if (PRINT_ERROR) {
+                fprintf(context->optstderr ?: stderr, recargchar, optchar);
+            }
+            context->optopt = optchar;
+            return BADARG;
+        } else {  // white space
+            context->place = nargv[context->optind];
+        }
+        context->dash_prefix = W_PREFIX;
+        optchar = parse_long_options_r(nargv, options, long_options, idx, false,
+                                       context);
+        context->place = EMSG;
+        return optchar;
+    }
+    if (*++oli != ':') {  // doesn't take argument
+        if (!*context->place) context->optind++;
+    } else {  // takes (optional) argument
+        context->optarg = nullptr;
+        if (*context->place) {  // no white space
+            context->optarg = context->place;
+        } else if (oli[1] != ':') {              // arg not optional
+            if (++(context->optind) >= nargc) {  // no arg
+                context->place = EMSG;
+                if (PRINT_ERROR) {
+                    fprintf(context->optstderr ?: stderr, recargchar, optchar);
+                }
+                context->optopt = optchar;
+                return BADARG;
+            }
+            context->optarg = nargv[context->optind];
+        }
+        context->place = EMSG;
+        context->optind++;
+    }
+    // dump back option letter
+    return optchar;
+}
diff --git a/logcat/include/log/getopt.h b/logcat/include/log/getopt.h
new file mode 100644
index 0000000..0da2b10
--- /dev/null
+++ b/logcat/include/log/getopt.h
@@ -0,0 +1,67 @@
+/*
+ * 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 _LOG_GETOPT_H_
+#define _LOG_GETOPT_H_
+
+#ifndef __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE
+#ifndef __ANDROID_API__
+#define __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE 1
+#elif __ANDROID_API__ > 24 /* > Nougat */
+#define __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE 1
+#else
+#define __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE 0
+#endif
+#endif
+
+#if __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE
+
+#include <getopt.h>
+#include <sys/cdefs.h>
+
+struct getopt_context {
+    int opterr;
+    int optind;
+    int optopt;
+    int optreset;
+    const char* optarg;
+    FILE* optstderr; /* NULL defaults to stderr */
+    /* private */
+    const char* place;
+    int nonopt_start;
+    int nonopt_end;
+    int dash_prefix;
+    /* expansion space */
+    int __extra__;
+    void* __stuff__;
+};
+
+#define EMSG ""
+#define NO_PREFIX (-1)
+
+#define INIT_GETOPT_CONTEXT(context) \
+    context = { 1, 1, '?', 0, NULL, NULL, EMSG, -1, -1, NO_PREFIX, 0, NULL }
+
+__BEGIN_DECLS
+int getopt_long_r(int nargc, char* const* nargv, const char* options,
+                  const struct option* long_options, int* idx,
+                  struct getopt_context* context);
+
+__END_DECLS
+
+#endif /* __ANDROID_USE_LIBLOG_LOGCAT_INTERFACE */
+
+#endif /* !_LOG_GETOPT_H_ */
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 077332a..4da5030 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -20,7 +20,6 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <getopt.h>
 #include <math.h>
 #include <pthread.h>
 #include <sched.h>
@@ -47,6 +46,7 @@
 #include <cutils/sched_policy.h>
 #include <cutils/sockets.h>
 #include <log/event_tag_map.h>
+#include <log/getopt.h>
 #include <log/logcat.h>
 #include <log/logprint.h>
 #include <private/android_logger.h>
@@ -56,6 +56,25 @@
 
 #define DEFAULT_MAX_ROTATED_LOGS 4
 
+struct log_device_t {
+    const char* device;
+    bool binary;
+    struct logger* logger;
+    struct logger_list* logger_list;
+    bool printed;
+
+    log_device_t* next;
+
+    log_device_t(const char* d, bool b) {
+        device = d;
+        binary = b;
+        next = nullptr;
+        printed = false;
+        logger = nullptr;
+        logger_list = nullptr;
+    }
+};
+
 struct android_logcat_context_internal {
     // status
     volatile std::atomic_int retval;  // valid if thread_stopped set
@@ -91,15 +110,15 @@
     int printBinary;
     int devCount;  // >1 means multiple
     pcrecpp::RE* regex;
+    log_device_t* devices;
+    EventTagMap* eventTagMap;
     // 0 means "infinite"
     size_t maxCount;
     size_t printCount;
+
     bool printItAnyways;
     bool debug;
-
-    // static variables
     bool hasOpenedEventTagMap;
-    EventTagMap* eventTagMap;
 };
 
 // Creates a context associated with this logcat instance
@@ -127,25 +146,6 @@
 // logd prefixes records with a length field
 #define RECORD_LENGTH_FIELD_SIZE_BYTES sizeof(uint32_t)
 
-struct log_device_t {
-    const char* device;
-    bool binary;
-    struct logger* logger;
-    struct logger_list* logger_list;
-    bool printed;
-
-    log_device_t* next;
-
-    log_device_t(const char* d, bool b) {
-        device = d;
-        binary = b;
-        next = nullptr;
-        printed = false;
-        logger = nullptr;
-        logger_list = nullptr;
-    }
-};
-
 namespace android {
 
 enum helpType { HELP_FALSE, HELP_TRUE, HELP_FORMAT };
@@ -635,19 +635,17 @@
 }
 
 // Find last logged line in <outputFileName>, or <outputFileName>.1
-static log_time lastLogTime(char* outputFileName) {
+static log_time lastLogTime(const char* outputFileName) {
     log_time retval(log_time::EPOCH);
     if (!outputFileName) return retval;
 
     std::string directory;
-    char* file = strrchr(outputFileName, '/');
+    const char* file = strrchr(outputFileName, '/');
     if (!file) {
         directory = ".";
         file = outputFileName;
     } else {
-        *file = '\0';
-        directory = outputFileName;
-        *file = '/';
+        directory = std::string(outputFileName, file - outputFileName);
         ++file;
     }
 
@@ -736,11 +734,10 @@
     bool printStatistics = false;
     bool printDividers = false;
     unsigned long setLogSize = 0;
-    char* setPruneList = nullptr;
-    char* setId = nullptr;
+    const char* setPruneList = nullptr;
+    const char* setId = nullptr;
     int mode = ANDROID_LOG_RDONLY;
     std::string forceFilters;
-    log_device_t* devices = nullptr;
     log_device_t* dev;
     struct logger_list* logger_list;
     size_t tail_lines = 0;
@@ -855,8 +852,11 @@
     // net for stability dealing with possible mistaken inputs.
     static const char delimiters[] = ",:; \t\n\r\f";
 
-    // danger: getopt is _not_ reentrant
-    optind = 1;
+    struct getopt_context optctx;
+    INIT_GETOPT_CONTEXT(optctx);
+    optctx.opterr = !!context->error;
+    optctx.optstderr = context->error;
+
     for (;;) {
         int ret;
 
@@ -899,9 +899,9 @@
         };
         // clang-format on
 
-        ret = getopt_long(argc, argv,
-                          ":cdDLt:T:gG:sQf:r:n:v:b:BSpP:m:e:", long_options,
-                          &option_index);
+        ret = getopt_long_r(argc, argv,
+                            ":cdDLt:T:gG:sQf:r:n:v:b:BSpP:m:e:", long_options,
+                            &option_index, &optctx);
         if (ret < 0) break;
 
         switch (ret) {
@@ -909,9 +909,10 @@
                 // only long options
                 if (long_options[option_index].name == pid_str) {
                     // ToDo: determine runtime PID_MAX?
-                    if (!getSizeTArg(optarg, &pid, 1)) {
+                    if (!getSizeTArg(optctx.optarg, &pid, 1)) {
                         logcat_panic(context, HELP_TRUE, "%s %s out of range\n",
-                                     long_options[option_index].name, optarg);
+                                     long_options[option_index].name,
+                                     optctx.optarg);
                         goto exit;
                     }
                     break;
@@ -921,9 +922,11 @@
                             ANDROID_LOG_NONBLOCK;
                     // ToDo: implement API that supports setting a wrap timeout
                     size_t dummy = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT;
-                    if (optarg && !getSizeTArg(optarg, &dummy, 1)) {
+                    if (optctx.optarg &&
+                        !getSizeTArg(optctx.optarg, &dummy, 1)) {
                         logcat_panic(context, HELP_TRUE, "%s %s out of range\n",
-                                     long_options[option_index].name, optarg);
+                                     long_options[option_index].name,
+                                     optctx.optarg);
                         goto exit;
                     }
                     if ((dummy != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) &&
@@ -944,7 +947,8 @@
                     break;
                 }
                 if (long_options[option_index].name == id_str) {
-                    setId = (optarg && optarg[0]) ? optarg : nullptr;
+                    setId = (optctx.optarg && optctx.optarg[0]) ? optctx.optarg
+                                                                : nullptr;
                 }
                 break;
 
@@ -972,12 +976,13 @@
                 mode |= ANDROID_LOG_RDONLY | ANDROID_LOG_NONBLOCK;
             // FALLTHRU
             case 'T':
-                if (strspn(optarg, "0123456789") != strlen(optarg)) {
-                    char* cp = parseTime(tail_time, optarg);
+                if (strspn(optctx.optarg, "0123456789") !=
+                    strlen(optctx.optarg)) {
+                    char* cp = parseTime(tail_time, optctx.optarg);
                     if (!cp) {
                         logcat_panic(context, HELP_FALSE,
                                      "-%c \"%s\" not in time format\n", ret,
-                                     optarg);
+                                     optctx.optarg);
                         goto exit;
                     }
                     if (*cp) {
@@ -987,16 +992,16 @@
                             fprintf(
                                 context->error,
                                 "WARNING: -%c \"%s\"\"%c%s\" time truncated\n",
-                                ret, optarg, c, cp + 1);
+                                ret, optctx.optarg, c, cp + 1);
                         }
                         *cp = c;
                     }
                 } else {
-                    if (!getSizeTArg(optarg, &tail_lines, 1)) {
+                    if (!getSizeTArg(optctx.optarg, &tail_lines, 1)) {
                         if (context->error) {
                             fprintf(context->error,
                                     "WARNING: -%c %s invalid, setting to 1\n",
-                                    ret, optarg);
+                                    ret, optctx.optarg);
                         }
                         tail_lines = 1;
                     }
@@ -1008,22 +1013,22 @@
                 break;
 
             case 'e':
-                context->regex = new pcrecpp::RE(optarg);
+                context->regex = new pcrecpp::RE(optctx.optarg);
                 break;
 
             case 'm': {
                 char* end = nullptr;
-                if (!getSizeTArg(optarg, &context->maxCount)) {
+                if (!getSizeTArg(optctx.optarg, &context->maxCount)) {
                     logcat_panic(context, HELP_FALSE,
                                  "-%c \"%s\" isn't an "
                                  "integer greater than zero\n",
-                                 ret, optarg);
+                                 ret, optctx.optarg);
                     goto exit;
                 }
             } break;
 
             case 'g':
-                if (!optarg) {
+                if (!optctx.optarg) {
                     getLogSize = true;
                     break;
                 }
@@ -1031,8 +1036,8 @@
 
             case 'G': {
                 char* cp;
-                if (strtoll(optarg, &cp, 0) > 0) {
-                    setLogSize = strtoll(optarg, &cp, 0);
+                if (strtoll(optctx.optarg, &cp, 0) > 0) {
+                    setLogSize = strtoll(optctx.optarg, &cp, 0);
                 } else {
                     setLogSize = 0;
                 }
@@ -1065,42 +1070,42 @@
             } break;
 
             case 'p':
-                if (!optarg) {
+                if (!optctx.optarg) {
                     getPruneList = true;
                     break;
                 }
             // FALLTHRU
 
             case 'P':
-                setPruneList = optarg;
+                setPruneList = optctx.optarg;
                 break;
 
             case 'b': {
-                std::unique_ptr<char, void (*)(void*)> buffers(strdup(optarg),
-                                                               free);
-                optarg = buffers.get();
+                std::unique_ptr<char, void (*)(void*)> buffers(
+                    strdup(optctx.optarg), free);
+                char* arg = buffers.get();
                 unsigned idMask = 0;
                 char* sv = nullptr;  // protect against -ENOMEM above
-                while (!!(optarg = strtok_r(optarg, delimiters, &sv))) {
-                    if (!strcmp(optarg, "default")) {
+                while (!!(arg = strtok_r(arg, delimiters, &sv))) {
+                    if (!strcmp(arg, "default")) {
                         idMask |= (1 << LOG_ID_MAIN) | (1 << LOG_ID_SYSTEM) |
                                   (1 << LOG_ID_CRASH);
-                    } else if (!strcmp(optarg, "all")) {
+                    } else if (!strcmp(arg, "all")) {
                         allSelected = true;
                         idMask = (unsigned)-1;
                     } else {
-                        log_id_t log_id = android_name_to_log_id(optarg);
+                        log_id_t log_id = android_name_to_log_id(arg);
                         const char* name = android_log_id_to_name(log_id);
 
-                        if (!!strcmp(name, optarg)) {
+                        if (!!strcmp(name, arg)) {
                             logcat_panic(context, HELP_TRUE,
-                                         "unknown buffer %s\n", optarg);
+                                         "unknown buffer %s\n", arg);
                             goto exit;
                         }
                         if (log_id == LOG_ID_SECURITY) allSelected = false;
                         idMask |= (1 << log_id);
                     }
-                    optarg = nullptr;
+                    arg = nullptr;
                 }
 
                 for (int i = LOG_ID_MIN; i < LOG_ID_MAX; ++i) {
@@ -1111,7 +1116,7 @@
                     if (!(idMask & (1 << i))) continue;
 
                     bool found = false;
-                    for (dev = devices; dev; dev = dev->next) {
+                    for (dev = context->devices; dev; dev = dev->next) {
                         if (!strcmp(name, dev->device)) {
                             found = true;
                             break;
@@ -1128,7 +1133,7 @@
                         dev->next = d;
                         dev = d;
                     } else {
-                        devices = dev = d;
+                        context->devices = dev = d;
                     }
                     context->devCount++;
                 }
@@ -1140,47 +1145,51 @@
 
             case 'f':
                 if ((tail_time == log_time::EPOCH) && !tail_lines) {
-                    tail_time = lastLogTime(optarg);
+                    tail_time = lastLogTime(optctx.optarg);
                 }
                 // redirect output to a file
-                context->outputFileName = optarg;
+                context->outputFileName = optctx.optarg;
                 break;
 
             case 'r':
-                if (!getSizeTArg(optarg, &context->logRotateSizeKBytes, 1)) {
+                if (!getSizeTArg(optctx.optarg, &context->logRotateSizeKBytes,
+                                 1)) {
                     logcat_panic(context, HELP_TRUE,
-                                 "Invalid parameter \"%s\" to -r\n", optarg);
+                                 "Invalid parameter \"%s\" to -r\n",
+                                 optctx.optarg);
                     goto exit;
                 }
                 break;
 
             case 'n':
-                if (!getSizeTArg(optarg, &context->maxRotatedLogs, 1)) {
+                if (!getSizeTArg(optctx.optarg, &context->maxRotatedLogs, 1)) {
                     logcat_panic(context, HELP_TRUE,
-                                 "Invalid parameter \"%s\" to -n\n", optarg);
+                                 "Invalid parameter \"%s\" to -n\n",
+                                 optctx.optarg);
                     goto exit;
                 }
                 break;
 
             case 'v': {
-                if (!strcmp(optarg, "help") || !strcmp(optarg, "--help")) {
+                if (!strcmp(optctx.optarg, "help") ||
+                    !strcmp(optctx.optarg, "--help")) {
                     show_format_help(context);
                     context->retval = EXIT_SUCCESS;
                     goto exit;
                 }
-                std::unique_ptr<char, void (*)(void*)> formats(strdup(optarg),
-                                                               free);
-                optarg = formats.get();
+                std::unique_ptr<char, void (*)(void*)> formats(
+                    strdup(optctx.optarg), free);
+                char* arg = formats.get();
                 unsigned idMask = 0;
                 char* sv = nullptr;  // protect against -ENOMEM above
-                while (!!(optarg = strtok_r(optarg, delimiters, &sv))) {
-                    err = setLogFormat(context, optarg);
+                while (!!(arg = strtok_r(arg, delimiters, &sv))) {
+                    err = setLogFormat(context, arg);
                     if (err < 0) {
                         logcat_panic(context, HELP_FORMAT,
-                                     "Invalid parameter \"%s\" to -v\n", optarg);
+                                     "Invalid parameter \"%s\" to -v\n", arg);
                         goto exit;
                     }
-                    optarg = nullptr;
+                    arg = nullptr;
                     if (err) hasSetLogFormat = true;
                 }
             } break;
@@ -1249,12 +1258,12 @@
 
             case ':':
                 logcat_panic(context, HELP_TRUE,
-                             "Option -%c needs an argument\n", optopt);
+                             "Option -%c needs an argument\n", optctx.optopt);
                 goto exit;
 
             default:
                 logcat_panic(context, HELP_TRUE, "Unrecognized Option %c\n",
-                             optopt);
+                             optctx.optopt);
                 goto exit;
         }
     }
@@ -1277,8 +1286,8 @@
         context->printItAnyways = false;
     }
 
-    if (!devices) {
-        dev = devices = new log_device_t("main", false);
+    if (!context->devices) {
+        dev = context->devices = new log_device_t("main", false);
         context->devCount = 1;
         if (android_name_to_log_id("system") == LOG_ID_SYSTEM) {
             dev = dev->next = new log_device_t("system", false);
@@ -1343,7 +1352,7 @@
                          "Invalid filter expression in logcat args\n");
             goto exit;
         }
-    } else if (argc == optind) {
+    } else if (argc == optctx.optind) {
         // Add from environment variable
         const char* env_tags_orig = android::getenv(context, "ANDROID_LOG_TAGS");
 
@@ -1359,7 +1368,7 @@
         }
     } else {
         // Add from commandline
-        for (int i = optind ; i < argc ; i++) {
+        for (int i = optctx.optind ; i < argc ; i++) {
             // skip stderr redirections of _all_ kinds
             if ((argv[i][0] == '2') && (argv[i][1] == '>')) continue;
             // skip stdout redirections of _all_ kinds
@@ -1374,7 +1383,7 @@
         }
     }
 
-    dev = devices;
+    dev = context->devices;
     if (tail_time != log_time::EPOCH) {
         logger_list = android_logger_list_alloc_time(mode, tail_time, pid);
     } else {
@@ -1585,7 +1594,7 @@
         }
 
         log_device_t* d;
-        for (d = devices; d; d = d->next) {
+        for (d = context->devices; d; d = d->next) {
             if (android_name_to_log_id(d->device) == log_msg.id()) break;
         }
         if (!d) {
@@ -1607,6 +1616,11 @@
     }
 
 close:
+    // Short and sweet. Implemented generic version in android_logcat_destroy.
+    while (!!(dev = context->devices)) {
+        context->devices = dev->next;
+        delete dev;
+    }
     android_logger_list_free(logger_list);
 
 exit:
@@ -1780,6 +1794,20 @@
 
     android_closeEventTagMap(context->eventTagMap);
 
+    // generic cleanup of devices list to handle all possible dirty cases
+    log_device_t* dev;
+    while (!!(dev = context->devices)) {
+        struct logger_list* logger_list = dev->logger_list;
+        if (logger_list) {
+            for (log_device_t* d = dev; d; d = d->next) {
+                if (d->logger_list == logger_list) d->logger_list = nullptr;
+            }
+            android_logger_list_free(logger_list);
+        }
+        context->devices = dev->next;
+        delete dev;
+    }
+
     int retval = context->retval;
 
     free(context);
diff --git a/qemu_pipe/include/qemu_pipe.h b/qemu_pipe/include/qemu_pipe.h
index 16486c0..0987498 100644
--- a/qemu_pipe/include/qemu_pipe.h
+++ b/qemu_pipe/include/qemu_pipe.h
@@ -28,8 +28,10 @@
 // This file descriptor can be used as a standard pipe/socket descriptor.
 //
 // 'pipeName' is the name of the emulator service you want to connect to,
-// and must begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles').
-//
+// and should begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles').
+// For backward compatibility, the 'pipe:' prefix can be omitted, and in
+// that case, qemu_pipe_open will add it for you.
+
 // On success, return a valid file descriptor, or -1/errno on failure. E.g.:
 //
 // EINVAL  -> unknown/unsupported pipeName
diff --git a/qemu_pipe/qemu_pipe.cpp b/qemu_pipe/qemu_pipe.cpp
index a4529de..beeccb0 100644
--- a/qemu_pipe/qemu_pipe.cpp
+++ b/qemu_pipe/qemu_pipe.cpp
@@ -22,6 +22,10 @@
 #include <errno.h>
 #include <stdio.h>
 
+#include <android-base/file.h>
+
+using android::base::ReadFully;
+using android::base::WriteFully;
 
 // Define QEMU_PIPE_DEBUG if you want to print error messages when an error
 // occurs during pipe operations. The macro should simply take a printf-style
@@ -30,29 +34,9 @@
 #  define  QEMU_PIPE_DEBUG(...)   (void)0
 #endif
 
-// Try to open a new Qemu fast-pipe. This function returns a file descriptor
-// that can be used to communicate with a named service managed by the
-// emulator.
-//
-// This file descriptor can be used as a standard pipe/socket descriptor.
-//
-// 'pipeName' is the name of the emulator service you want to connect to,
-// and must begin with 'pipe:' (e.g. 'pipe:camera' or 'pipe:opengles').
-//
-// On success, return a valid file descriptor, or -1/errno on failure. E.g.:
-//
-// EINVAL  -> unknown/unsupported pipeName
-// ENOSYS  -> fast pipes not available in this system.
-//
-// ENOSYS should never happen, except if you're trying to run within a
-// misconfigured emulator.
-//
-// You should be able to open several pipes to the same pipe service,
-// except for a few special cases (e.g. GSM modem), where EBUSY will be
-// returned if more than one client tries to connect to it.
 int qemu_pipe_open(const char* pipeName) {
     // Sanity check.
-    if (!pipeName || memcmp(pipeName, "pipe:", 5) != 0) {
+    if (!pipeName) {
         errno = EINVAL;
         return -1;
     }
@@ -66,48 +50,41 @@
 
     // Write the pipe name, *including* the trailing zero which is necessary.
     size_t pipeNameLen = strlen(pipeName);
-    ssize_t ret = TEMP_FAILURE_RETRY(write(fd, pipeName, pipeNameLen + 1U));
-    if (ret != (ssize_t)pipeNameLen + 1) {
-        QEMU_PIPE_DEBUG("%s: Could not connect to %s pipe service: %s",
-                        __FUNCTION__, pipeName, strerror(errno));
-        if (ret == 0) {
-            errno = ECONNRESET;
-        } else if (ret > 0) {
-            errno = EINVAL;
-        }
-        return -1;
+    if (WriteFully(fd, pipeName, pipeNameLen + 1U)) {
+        return fd;
     }
-    return fd;
+
+    // now, add 'pipe:' prefix and try again
+    // Note: host side will wait for the trailing '\0' to start
+    // service lookup.
+    const char pipe_prefix[] = "pipe:";
+    if (WriteFully(fd, pipe_prefix, strlen(pipe_prefix)) &&
+            WriteFully(fd, pipeName, pipeNameLen + 1U)) {
+        return fd;
+    }
+    QEMU_PIPE_DEBUG("%s: Could not write to %s pipe service: %s",
+            __FUNCTION__, pipeName, strerror(errno));
+    close(fd);
+    return -1;
 }
 
-// Send a framed message |buff| of |len| bytes through the |fd| descriptor.
-// This really adds a 4-hexchar prefix describing the payload size.
-// Returns 0 on success, and -1 on error.
 int qemu_pipe_frame_send(int fd, const void* buff, size_t len) {
     char header[5];
     snprintf(header, sizeof(header), "%04zx", len);
-    ssize_t ret = TEMP_FAILURE_RETRY(write(fd, header, 4));
-    if (ret != 4) {
+    if (!WriteFully(fd, header, 4)) {
         QEMU_PIPE_DEBUG("Can't write qemud frame header: %s", strerror(errno));
         return -1;
     }
-    ret = TEMP_FAILURE_RETRY(write(fd, buff, len));
-    if (ret != (ssize_t)len) {
+    if (!WriteFully(fd, buff, len)) {
         QEMU_PIPE_DEBUG("Can't write qemud frame payload: %s", strerror(errno));
         return -1;
     }
     return 0;
 }
 
-// Read a frame message from |fd|, and store it into |buff| of |len| bytes.
-// If the framed message is larger than |len|, then this returns -1 and the
-// content is lost. Otherwise, this returns the size of the message. NOTE:
-// empty messages are possible in a framed wire protocol and do not mean
-// end-of-stream.
 int qemu_pipe_frame_recv(int fd, void* buff, size_t len) {
     char header[5];
-    ssize_t ret = TEMP_FAILURE_RETRY(read(fd, header, 4));
-    if (ret != 4) {
+    if (!ReadFully(fd, header, 4)) {
         QEMU_PIPE_DEBUG("Can't read qemud frame header: %s", strerror(errno));
         return -1;
     }
@@ -122,8 +99,7 @@
                         len);
         return -1;
     }
-    ret = TEMP_FAILURE_RETRY(read(fd, buff, size));
-    if (ret != (ssize_t)size) {
+    if (!ReadFully(fd, buff, size)) {
         QEMU_PIPE_DEBUG("Could not read qemud frame payload: %s",
                         strerror(errno));
         return -1;
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index 03f878a..86fec6a 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -53,7 +53,7 @@
 
 # Pretty comprehensive set of native services. This list is helpful if all that's to be checked is an
 # app.
-ifeq ($(SANITIZE_LITE),true)
+ifeq ($(SANITIZE_LITE_SERVICES),true)
 SANITIZE_ASAN_OPTIONS_FOR := \
   adbd \
   ATFWD-daemon \
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 757e1ff..25cea7f 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -244,6 +244,10 @@
     # set RLIMIT_NICE to allow priorities from 19 to -20
     setrlimit 13 40 40
 
+    # This allows the ledtrig-transient properties to be created here so
+    # that they can be chown'd to system:system later on boot
+    write /sys/class/leds/vibrator/trigger "transient"
+
 # Healthd can trigger a full boot from charger mode by signaling this
 # property when the power button is held.
 on property:sys.boot_from_charger_mode=1
@@ -290,6 +294,9 @@
     # /data, which in turn can only be loaded when system properties are present.
     trigger post-fs-data
 
+    # Now we can start zygote for devices with file based encryption
+    trigger zygote-start
+
     # Load persist properties and override properties (if enabled) from /data.
     trigger load_persist_props_action
 
@@ -490,6 +497,13 @@
     # Set indication (checked by vold) that we have finished this action
     #setprop vold.post_fs_data_done 1
 
+# This trigger will be triggered before 'zygote-start' since there is no zygote-start defined in
+# current init.rc. It is recommended to put unnecessary data/ initialization from post-fs-data
+# to start-zygote to unblock zygote start.
+on zygote-start && property:ro.crypto.state=encrypted && property:ro.crypto.type=file
+   start netd
+   start zygote
+
 on boot
     # basic network init
     ifup lo
@@ -553,6 +567,11 @@
     chown system system /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
     chmod 0660 /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
 
+    chown system system /sys/class/leds/vibrator/trigger
+    chown system system /sys/class/leds/vibrator/activate
+    chown system system /sys/class/leds/vibrator/brightness
+    chown system system /sys/class/leds/vibrator/duration
+    chown system system /sys/class/leds/vibrator/state
     chown system system /sys/class/timed_output/vibrator/enable
     chown system system /sys/class/leds/keyboard-backlight/brightness
     chown system system /sys/class/leds/lcd-backlight/brightness
@@ -564,7 +583,6 @@
     chown system system /sys/class/leds/red/device/grpfreq
     chown system system /sys/class/leds/red/device/grppwm
     chown system system /sys/class/leds/red/device/blink
-    chown system system /sys/class/timed_output/vibrator/enable
     chown system system /sys/module/sco/parameters/disable_esco
     chown system system /sys/kernel/ipv4/tcp_wmem_min
     chown system system /sys/kernel/ipv4/tcp_wmem_def
