Run clang-format on the entire repo

This patch clang-formats the entire repo. Third-party code is
excluded.

I needed to fix up the .clang-format file so that all the header
includes are ordered properly. I could have sworn that it used to work
without the extra modification, but I guess not.

Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
Change-Id: I64bb9f2c795401393f9dfe2fefc4f04cb36b52f6
diff --git a/aos/network/log_web_proxy_main.cc b/aos/network/log_web_proxy_main.cc
index 34e40a2..7833808 100644
--- a/aos/network/log_web_proxy_main.cc
+++ b/aos/network/log_web_proxy_main.cc
@@ -4,13 +4,14 @@
 // /path/to/logfile And then opening the plotting webpage at
 // http://localhost:8080/graph.html
 
+#include "gflags/gflags.h"
+
 #include "aos/configuration.h"
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/flatbuffer_merge.h"
 #include "aos/init.h"
 #include "aos/network/web_proxy.h"
-#include "gflags/gflags.h"
 
 DEFINE_string(data_dir, "www", "Directory to serve data files from");
 DEFINE_string(node, "", "Directory to serve data files from");
@@ -64,8 +65,7 @@
   }
 
   aos::web_proxy::WebProxy web_proxy(
-      event_loop.get(),
-      reader.event_loop_factory()->scheduler_epoll(),
+      event_loop.get(), reader.event_loop_factory()->scheduler_epoll(),
       aos::web_proxy::StoreHistory::kYes, FLAGS_buffer_size);
 
   web_proxy.SetDataPath(FLAGS_data_dir.c_str());
diff --git a/aos/network/message_bridge_client_lib.cc b/aos/network/message_bridge_client_lib.cc
index 0aefb5c..38512c4 100644
--- a/aos/network/message_bridge_client_lib.cc
+++ b/aos/network/message_bridge_client_lib.cc
@@ -3,6 +3,9 @@
 #include <chrono>
 #include <string_view>
 
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/shm_event_loop.h"
 #include "aos/network/connect_generated.h"
@@ -13,8 +16,6 @@
 #include "aos/network/timestamp_generated.h"
 #include "aos/unique_malloc_ptr.h"
 #include "aos/util/file.h"
-#include "gflags/gflags.h"
-#include "glog/logging.h"
 
 // This application receives messages from another node and re-publishes them on
 // this node.
diff --git a/aos/network/message_bridge_protocol.cc b/aos/network/message_bridge_protocol.cc
index 38e16b2..c661c4c 100644
--- a/aos/network/message_bridge_protocol.cc
+++ b/aos/network/message_bridge_protocol.cc
@@ -2,11 +2,12 @@
 
 #include <string_view>
 
+#include "flatbuffers/flatbuffers.h"
+
 #include "aos/configuration.h"
 #include "aos/flatbuffer_merge.h"
 #include "aos/flatbuffers.h"
 #include "aos/network/connect_generated.h"
-#include "flatbuffers/flatbuffers.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/message_bridge_server.cc b/aos/network/message_bridge_server.cc
index ec3cdc4..04b07c3 100644
--- a/aos/network/message_bridge_server.cc
+++ b/aos/network/message_bridge_server.cc
@@ -1,10 +1,11 @@
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+
 #include "aos/events/shm_event_loop.h"
 #include "aos/init.h"
 #include "aos/logging/dynamic_logging.h"
 #include "aos/network/message_bridge_server_lib.h"
 #include "aos/sha256.h"
-#include "gflags/gflags.h"
-#include "glog/logging.h"
 
 DEFINE_string(config, "aos_config.json", "Path to the config.");
 DEFINE_int32(rt_priority, -1, "If > 0, run as this RT priority");
diff --git a/aos/network/message_bridge_server_lib.cc b/aos/network/message_bridge_server_lib.cc
index df6d4b1..a474e88 100644
--- a/aos/network/message_bridge_server_lib.cc
+++ b/aos/network/message_bridge_server_lib.cc
@@ -2,6 +2,9 @@
 
 #include "absl/strings/str_cat.h"
 #include "absl/types/span.h"
+#include "glog/logging.h"
+#include "glog/raw_logging.h"
+
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/logging/logger_generated.h"
 #include "aos/events/shm_event_loop.h"
@@ -12,8 +15,6 @@
 #include "aos/network/remote_message_generated.h"
 #include "aos/network/sctp_server.h"
 #include "aos/network/timestamp_channel.h"
-#include "glog/logging.h"
-#include "glog/raw_logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/message_bridge_server_lib.h b/aos/network/message_bridge_server_lib.h
index 98e1dd0..d74a847 100644
--- a/aos/network/message_bridge_server_lib.h
+++ b/aos/network/message_bridge_server_lib.h
@@ -4,6 +4,8 @@
 #include <deque>
 
 #include "absl/types/span.h"
+#include "glog/logging.h"
+
 #include "aos/events/logging/log_reader.h"
 #include "aos/events/logging/logger_generated.h"
 #include "aos/events/shm_event_loop.h"
@@ -16,7 +18,6 @@
 #include "aos/network/sctp_server.h"
 #include "aos/network/timestamp_channel.h"
 #include "aos/network/timestamp_generated.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
@@ -65,7 +66,8 @@
   // Needs to be called when a node (might have) disconnected.
   // Returns the node index which [dis]connected, or -1 if it didn't match.
   // reconnected is a vector of associations which have already connected.
-  // This will potentially grow to the number of associations as we find reconnects.
+  // This will potentially grow to the number of associations as we find
+  // reconnects.
   int NodeDisconnected(sctp_assoc_t assoc_id);
   int NodeConnected(const Node *node, sctp_assoc_t assoc_id, int stream,
                     SctpServer *server, FixedAllocator *allocator,
diff --git a/aos/network/message_bridge_test.cc b/aos/network/message_bridge_test.cc
index 681001e..153f1e5 100644
--- a/aos/network/message_bridge_test.cc
+++ b/aos/network/message_bridge_test.cc
@@ -2,6 +2,8 @@
 #include <thread>
 
 #include "absl/strings/str_cat.h"
+#include "gtest/gtest.h"
+
 #include "aos/events/ping_generated.h"
 #include "aos/events/pong_generated.h"
 #include "aos/ipc_lib/event.h"
@@ -11,7 +13,6 @@
 #include "aos/sha256.h"
 #include "aos/testing/path.h"
 #include "aos/util/file.h"
-#include "gtest/gtest.h"
 
 DECLARE_string(boot_uuid);
 
@@ -423,54 +424,54 @@
   // Wait until we are connected, then send.
   int ping_count = 0;
   int pi1_server_statistics_count = 0;
-  ping_event_loop.MakeWatcher("/pi1/aos", [this, &ping_count, &ping_sender,
-                                           &pi1_server_statistics_count,
-                                           &long_data](
-                                              const ServerStatistics &stats) {
-    VLOG(1) << "/pi1/aos ServerStatistics " << FlatbufferToJson(&stats);
+  ping_event_loop.MakeWatcher(
+      "/pi1/aos",
+      [this, &ping_count, &ping_sender, &pi1_server_statistics_count,
+       &long_data](const ServerStatistics &stats) {
+        VLOG(1) << "/pi1/aos ServerStatistics " << FlatbufferToJson(&stats);
 
-    ASSERT_TRUE(stats.has_connections());
-    EXPECT_EQ(stats.connections()->size(), 1);
+        ASSERT_TRUE(stats.has_connections());
+        EXPECT_EQ(stats.connections()->size(), 1);
 
-    bool connected = false;
-    for (const ServerConnection *connection : *stats.connections()) {
-      // Confirm that we are estimating the server time offset correctly. It
-      // should be about 0 since we are on the same machine here.
-      if (connection->has_monotonic_offset()) {
-        EXPECT_LT(chrono::nanoseconds(connection->monotonic_offset()),
-                  chrono::milliseconds(1));
-        EXPECT_GT(chrono::nanoseconds(connection->monotonic_offset()),
-                  chrono::milliseconds(-1));
-        ++pi1_server_statistics_count;
-      }
+        bool connected = false;
+        for (const ServerConnection *connection : *stats.connections()) {
+          // Confirm that we are estimating the server time offset correctly. It
+          // should be about 0 since we are on the same machine here.
+          if (connection->has_monotonic_offset()) {
+            EXPECT_LT(chrono::nanoseconds(connection->monotonic_offset()),
+                      chrono::milliseconds(1));
+            EXPECT_GT(chrono::nanoseconds(connection->monotonic_offset()),
+                      chrono::milliseconds(-1));
+            ++pi1_server_statistics_count;
+          }
 
-      if (connection->node()->name()->string_view() ==
-          pi2_client_event_loop->node()->name()->string_view()) {
-        if (connection->state() == State::CONNECTED) {
-          EXPECT_TRUE(connection->has_boot_uuid());
-          EXPECT_EQ(connection->connection_count(), 1u);
-          EXPECT_LT(monotonic_clock::time_point(chrono::nanoseconds(
-                        connection->connected_since_time())),
-                    monotonic_clock::now());
-          connected = true;
-        } else {
-          EXPECT_FALSE(connection->has_connection_count());
-          EXPECT_FALSE(connection->has_connected_since_time());
+          if (connection->node()->name()->string_view() ==
+              pi2_client_event_loop->node()->name()->string_view()) {
+            if (connection->state() == State::CONNECTED) {
+              EXPECT_TRUE(connection->has_boot_uuid());
+              EXPECT_EQ(connection->connection_count(), 1u);
+              EXPECT_LT(monotonic_clock::time_point(chrono::nanoseconds(
+                            connection->connected_since_time())),
+                        monotonic_clock::now());
+              connected = true;
+            } else {
+              EXPECT_FALSE(connection->has_connection_count());
+              EXPECT_FALSE(connection->has_connected_since_time());
+            }
+          }
         }
-      }
-    }
 
-    if (connected) {
-      VLOG(1) << "Connected!  Sent ping.";
-      auto builder = ping_sender.MakeBuilder();
-      builder.fbb()->CreateString(long_data);
-      examples::Ping::Builder ping_builder =
-          builder.MakeBuilder<examples::Ping>();
-      ping_builder.add_value(ping_count + 971);
-      EXPECT_EQ(builder.Send(ping_builder.Finish()), RawSender::Error::kOk);
-      ++ping_count;
-    }
-  });
+        if (connected) {
+          VLOG(1) << "Connected!  Sent ping.";
+          auto builder = ping_sender.MakeBuilder();
+          builder.fbb()->CreateString(long_data);
+          examples::Ping::Builder ping_builder =
+              builder.MakeBuilder<examples::Ping>();
+          ping_builder.add_value(ping_count + 971);
+          EXPECT_EQ(builder.Send(ping_builder.Finish()), RawSender::Error::kOk);
+          ++ping_count;
+        }
+      });
 
   // Confirm both client and server statistics messages have decent offsets in
   // them.
diff --git a/aos/network/multinode_timestamp_filter.cc b/aos/network/multinode_timestamp_filter.cc
index 32d345a..417845b 100644
--- a/aos/network/multinode_timestamp_filter.cc
+++ b/aos/network/multinode_timestamp_filter.cc
@@ -5,12 +5,13 @@
 #include <map>
 
 #include "absl/strings/str_join.h"
+#include "glog/logging.h"
+
 #include "aos/configuration.h"
 #include "aos/events/logging/boot_timestamp.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/network/timestamp_filter.h"
 #include "aos/time/time.h"
-#include "glog/logging.h"
 
 DEFINE_bool(timestamps_to_csv, false,
             "If true, write all the time synchronization information to a set "
@@ -278,8 +279,7 @@
   result.hessian = Eigen::MatrixXd::Zero(states(), states());
 
   // Constrain the average of the times.
-  result.A =
-      Eigen::MatrixXd::Ones(1, states()) / static_cast<double>(states());
+  result.A = Eigen::MatrixXd::Ones(1, states()) / static_cast<double>(states());
   result.Axmb = Eigen::VectorXd::Zero(1);
 
   if (active_constraints.size() > 0 || all) {
diff --git a/aos/network/multinode_timestamp_filter.h b/aos/network/multinode_timestamp_filter.h
index 5864334..e3bfde2 100644
--- a/aos/network/multinode_timestamp_filter.h
+++ b/aos/network/multinode_timestamp_filter.h
@@ -7,13 +7,14 @@
 
 #include "Eigen/Dense"
 #include "absl/container/btree_set.h"
+#include "glog/logging.h"
+
 #include "aos/configuration.h"
 #include "aos/events/logging/boot_timestamp.h"
 #include "aos/events/logging/logfile_utils.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/network/timestamp_filter.h"
 #include "aos/time/time.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
@@ -317,7 +318,6 @@
 
   // Points to solve equality constraints to.
   absl::Span<const logger::BootTimestamp> points_;
-
 };
 
 // Helpers to convert times between the monotonic and distributed clocks for
@@ -552,8 +552,7 @@
   void FlushAllSamples(bool finish);
 
   // Adds the solution to last_distributed_.
-  void UpdateSolution(
-      std::vector<logger::BootTimestamp> result_times);
+  void UpdateSolution(std::vector<logger::BootTimestamp> result_times);
 
   void WriteFilter(
       NoncausalTimestampFilter *next_filter,
diff --git a/aos/network/multinode_timestamp_filter_test.cc b/aos/network/multinode_timestamp_filter_test.cc
index 209de06..1446e77 100644
--- a/aos/network/multinode_timestamp_filter_test.cc
+++ b/aos/network/multinode_timestamp_filter_test.cc
@@ -2,12 +2,13 @@
 
 #include <chrono>
 
+#include "gtest/gtest.h"
+
 #include "aos/configuration.h"
 #include "aos/json_to_flatbuffer.h"
 #include "aos/macros.h"
 #include "aos/network/testing_time_converter.h"
 #include "aos/network/timestamp_filter.h"
-#include "gtest/gtest.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/sctp_client.cc b/aos/network/sctp_client.cc
index ab70c20..b7b7a93 100644
--- a/aos/network/sctp_client.cc
+++ b/aos/network/sctp_client.cc
@@ -9,9 +9,10 @@
 #include <cstring>
 #include <string_view>
 
+#include "glog/logging.h"
+
 #include "aos/network/sctp_lib.h"
 #include "aos/unique_malloc_ptr.h"
-#include "glog/logging.h"
 
 DEFINE_int32(sinit_max_init_timeout, 0,
              "Timeout in milliseconds for retrying the INIT packet when "
diff --git a/aos/network/sctp_client.h b/aos/network/sctp_client.h
index d7a2b43..5affecc 100644
--- a/aos/network/sctp_client.h
+++ b/aos/network/sctp_client.h
@@ -5,9 +5,10 @@
 #include <cstdlib>
 #include <string_view>
 
+#include "glog/logging.h"
+
 #include "aos/network/sctp_lib.h"
 #include "aos/unique_malloc_ptr.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/sctp_lib.h b/aos/network/sctp_lib.h
index a852365..42cecea 100644
--- a/aos/network/sctp_lib.h
+++ b/aos/network/sctp_lib.h
@@ -10,10 +10,11 @@
 #include <string_view>
 #include <vector>
 
-#include "aos/unique_malloc_ptr.h"
 #include "gflags/gflags.h"
 #include "glog/logging.h"
 
+#include "aos/unique_malloc_ptr.h"
+
 namespace aos {
 namespace message_bridge {
 
diff --git a/aos/network/sctp_lib_test.cc b/aos/network/sctp_lib_test.cc
index 53b285f..f297a82 100644
--- a/aos/network/sctp_lib_test.cc
+++ b/aos/network/sctp_lib_test.cc
@@ -1,8 +1,9 @@
 #include "aos/network/sctp_lib.h"
 
-#include "aos/init.h"
 #include "gflags/gflags.h"
 
+#include "aos/init.h"
+
 DEFINE_string(host, "", "host to resolve");
 DEFINE_int32(port, 2977, "port to use");
 
diff --git a/aos/network/sctp_server.cc b/aos/network/sctp_server.cc
index a78aa34..cfc8512 100644
--- a/aos/network/sctp_server.cc
+++ b/aos/network/sctp_server.cc
@@ -13,9 +13,10 @@
 #include <memory>
 #include <thread>
 
+#include "glog/logging.h"
+
 #include "aos/network/sctp_lib.h"
 #include "aos/unique_malloc_ptr.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/sctp_server.h b/aos/network/sctp_server.h
index 800c2c1..6d0b44e 100644
--- a/aos/network/sctp_server.h
+++ b/aos/network/sctp_server.h
@@ -13,9 +13,10 @@
 #include <cstring>
 #include <memory>
 
+#include "glog/logging.h"
+
 #include "aos/network/sctp_lib.h"
 #include "aos/unique_malloc_ptr.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/timestamp_channel.h b/aos/network/timestamp_channel.h
index d95edda..c8e88d9 100644
--- a/aos/network/timestamp_channel.h
+++ b/aos/network/timestamp_channel.h
@@ -5,10 +5,11 @@
 #include <vector>
 
 #include "absl/container/btree_map.h"
+#include "glog/logging.h"
+
 #include "aos/configuration.h"
 #include "aos/events/event_loop.h"
 #include "aos/network/remote_message_generated.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/timestamp_channel_test.cc b/aos/network/timestamp_channel_test.cc
index e3850ca..a217a74 100644
--- a/aos/network/timestamp_channel_test.cc
+++ b/aos/network/timestamp_channel_test.cc
@@ -1,12 +1,13 @@
 #include "aos/network/timestamp_channel.h"
 
+#include "gtest/gtest.h"
+
 #include "aos/configuration.h"
 #include "aos/events/ping_generated.h"
 #include "aos/events/shm_event_loop.h"
 #include "aos/events/simulated_event_loop.h"
 #include "aos/testing/path.h"
 #include "aos/testing/tmpdir.h"
-#include "gtest/gtest.h"
 
 DECLARE_string(override_hostname);
 
diff --git a/aos/network/timestamp_filter.cc b/aos/network/timestamp_filter.cc
index 4664f6f..77d3726 100644
--- a/aos/network/timestamp_filter.cc
+++ b/aos/network/timestamp_filter.cc
@@ -7,6 +7,7 @@
 #include "absl/numeric/int128.h"
 #include "absl/strings/str_cat.h"
 #include "absl/strings/str_format.h"
+
 #include "aos/configuration.h"
 #include "aos/time/time.h"
 
diff --git a/aos/network/timestamp_filter.h b/aos/network/timestamp_filter.h
index 3e2db01..8b597bd 100644
--- a/aos/network/timestamp_filter.h
+++ b/aos/network/timestamp_filter.h
@@ -8,10 +8,11 @@
 #include <deque>
 
 #include "absl/numeric/int128.h"
+#include "glog/logging.h"
+
 #include "aos/configuration.h"
 #include "aos/events/logging/boot_timestamp.h"
 #include "aos/time/time.h"
-#include "glog/logging.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/timestamp_filter_test.cc b/aos/network/timestamp_filter_test.cc
index e33fdd1..07f7d6d 100644
--- a/aos/network/timestamp_filter_test.cc
+++ b/aos/network/timestamp_filter_test.cc
@@ -2,11 +2,12 @@
 
 #include <chrono>
 
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
 #include "aos/configuration.h"
 #include "aos/json_to_flatbuffer.h"
 #include "aos/macros.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
 
 namespace aos {
 namespace message_bridge {
diff --git a/aos/network/web_proxy.cc b/aos/network/web_proxy.cc
index d384f72..d7ab418 100644
--- a/aos/network/web_proxy.cc
+++ b/aos/network/web_proxy.cc
@@ -1,11 +1,12 @@
 #include "aos/network/web_proxy.h"
 
+#include "glog/logging.h"
+
 #include "aos/flatbuffer_merge.h"
 #include "aos/network/connect_generated.h"
 #include "aos/network/web_proxy_generated.h"
 #include "aos/network/web_proxy_utils.h"
 #include "aos/seasocks/seasocks_logger.h"
-#include "glog/logging.h"
 #include "internal/Embedded.h"
 
 extern "C" {
diff --git a/aos/network/web_proxy.h b/aos/network/web_proxy.h
index e38dcea..5526d07 100644
--- a/aos/network/web_proxy.h
+++ b/aos/network/web_proxy.h
@@ -5,6 +5,8 @@
 #include <map>
 #include <set>
 
+#include "flatbuffers/flatbuffers.h"
+
 #include "aos/events/event_loop.h"
 #include "aos/events/shm_event_loop.h"
 #include "aos/mutex/mutex.h"
@@ -12,7 +14,6 @@
 #include "aos/network/rawrtc.h"
 #include "aos/network/web_proxy_generated.h"
 #include "aos/seasocks/seasocks_logger.h"
-#include "flatbuffers/flatbuffers.h"
 #include "seasocks/Server.h"
 #include "seasocks/StringUtil.h"
 #include "seasocks/WebSocket.h"
diff --git a/aos/network/web_proxy_main.cc b/aos/network/web_proxy_main.cc
index 2a92a88..7684b06 100644
--- a/aos/network/web_proxy_main.cc
+++ b/aos/network/web_proxy_main.cc
@@ -1,8 +1,9 @@
+#include "gflags/gflags.h"
+
 #include "aos/events/shm_event_loop.h"
 #include "aos/flatbuffer_merge.h"
 #include "aos/init.h"
 #include "aos/network/web_proxy.h"
-#include "gflags/gflags.h"
 
 DEFINE_string(config, "aos_config.json", "File path of aos configuration");
 DEFINE_string(data_dir, "www", "Directory to serve data files from");
diff --git a/aos/network/web_proxy_utils.h b/aos/network/web_proxy_utils.h
index de64329..c5e2716 100644
--- a/aos/network/web_proxy_utils.h
+++ b/aos/network/web_proxy_utils.h
@@ -1,4 +1,5 @@
 #include "absl/types/span.h"
+
 #include "aos/events/event_loop.h"
 #include "aos/flatbuffers.h"
 #include "aos/network/web_proxy_generated.h"