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/motors/usb/cdc.cc b/motors/usb/cdc.cc
index 575b4c1..e082156 100644
--- a/motors/usb/cdc.cc
+++ b/motors/usb/cdc.cc
@@ -1,7 +1,7 @@
 #include "motors/usb/cdc.h"
 
-#include <string.h>
 #include <stdint.h>
+#include <string.h>
 
 #include "motors/core/time.h"
 
@@ -129,8 +129,8 @@
   {
     const auto interface_descriptor = CreateDescriptor(
         interface_descriptor_length(), UsbDescriptorType::kInterface);
-    interface_descriptor->AddByte(status_interface_);  // bInterfaceNumber
-    interface_descriptor->AddByte(0);  // bAlternateSetting
+    interface_descriptor->AddByte(status_interface_);       // bInterfaceNumber
+    interface_descriptor->AddByte(0);                       // bAlternateSetting
     interface_descriptor->AddByte(1);                       // bNumEndpoints
     interface_descriptor->AddByte(communications_class());  // bInterfaceClass
     interface_descriptor->AddByte(
@@ -157,7 +157,7 @@
     call_management->AddByte(
         cdc_descriptor_subtype::call_management());  // bDescriptorSubtype
     // We don't do call management.
-    call_management->AddByte(0);  // bmCapabilities
+    call_management->AddByte(0);                // bmCapabilities
     call_management->AddByte(data_interface_);  // bDataInterface
   }
 
@@ -184,7 +184,7 @@
     cdc_union_descriptor->AddByte(
         cdc_descriptor_subtype::union_function());     // bDescriptorSubtype
     cdc_union_descriptor->AddByte(status_interface_);  // bMasterInterface
-    cdc_union_descriptor->AddByte(data_interface_);  // bSlaveInterface
+    cdc_union_descriptor->AddByte(data_interface_);    // bSlaveInterface
   }
 
   {
diff --git a/motors/usb/cdc.h b/motors/usb/cdc.h
index c02873d..f8f084b 100644
--- a/motors/usb/cdc.h
+++ b/motors/usb/cdc.h
@@ -3,8 +3,8 @@
 
 #include <array>
 
-#include "motors/usb/usb.h"
 #include "motors/usb/queue.h"
+#include "motors/usb/usb.h"
 #include "motors/util.h"
 
 // CDC (Communications Device Class) is a "class standard" which takes 30 pages
diff --git a/motors/usb/hid.cc b/motors/usb/hid.cc
index d885e75..f42842b 100644
--- a/motors/usb/hid.cc
+++ b/motors/usb/hid.cc
@@ -60,7 +60,7 @@
     endpoint_descriptor->AddByte(
         m_endpoint_attributes_interrupt());                  // bmAttributes
     endpoint_descriptor->AddUint16(in_endpoint_max_size());  // wMaxPacketSize
-    endpoint_descriptor->AddByte(0x8);                        // bInterval
+    endpoint_descriptor->AddByte(0x8);                       // bInterval
   }
 }
 
diff --git a/motors/usb/hid.h b/motors/usb/hid.h
index 019231c..924cf37 100644
--- a/motors/usb/hid.h
+++ b/motors/usb/hid.h
@@ -3,6 +3,7 @@
 
 #include <stdint.h>
 #include <string.h>
+
 #include <array>
 
 #include "motors/usb/usb.h"
diff --git a/motors/usb/interrupt_out.cc b/motors/usb/interrupt_out.cc
index 9af650a..568e5c5 100644
--- a/motors/usb/interrupt_out.cc
+++ b/motors/usb/interrupt_out.cc
@@ -35,13 +35,12 @@
     endpoint_descriptor->AddByte(
         m_endpoint_attributes_interrupt());  // bmAttributes
     endpoint_descriptor->AddUint16(kSize);   // wMaxPacketSize
-    endpoint_descriptor->AddByte(1);  // bInterval
+    endpoint_descriptor->AddByte(1);         // bInterval
   }
 }
 
 void InterruptOut::HandleOutFinished(int endpoint, BdtEntry *bdt_entry) {
   if (endpoint == endpoint_) {
-
     DisableInterrupts disable_interrupts;
     if (first_rx_held_ == nullptr) {
       first_rx_held_ = bdt_entry;
diff --git a/motors/usb/interrupt_out.h b/motors/usb/interrupt_out.h
index 9a7232c..31852f9 100644
--- a/motors/usb/interrupt_out.h
+++ b/motors/usb/interrupt_out.h
@@ -1,12 +1,12 @@
 #ifndef MOTORS_USB_INTERRUPT_OUT_H_
 #define MOTORS_USB_INTERRUPT_OUT_H_
 
-#include "motors/usb/usb.h"
-#include "motors/util.h"
-
 #include <array>
 #include <string>
 
+#include "motors/usb/usb.h"
+#include "motors/util.h"
+
 namespace frc971 {
 namespace teensy {
 
diff --git a/motors/usb/queue.h b/motors/usb/queue.h
index 669abe4..f7a7e77 100644
--- a/motors/usb/queue.h
+++ b/motors/usb/queue.h
@@ -1,8 +1,8 @@
 #ifndef MOTORS_USB_QUEUE_H_
 #define MOTORS_USB_QUEUE_H_
 
-#include <memory>
 #include <atomic>
+#include <memory>
 
 namespace frc971 {
 namespace teensy {
@@ -28,9 +28,7 @@
                       write_cursor_.load(::std::memory_order_relaxed));
   }
 
-  size_t space_available() const {
-    return size_ - data_queued() - 1;
-  }
+  size_t space_available() const { return size_ - data_queued() - 1; }
 
   bool empty() const {
     return read_cursor_.load(::std::memory_order_relaxed) ==
diff --git a/motors/usb/usb.cc b/motors/usb/usb.cc
index e4a2b26..2c64b61 100644
--- a/motors/usb/usb.cc
+++ b/motors/usb/usb.cc
@@ -76,9 +76,9 @@
 // The total number of endpoints supported by this hardware.
 constexpr int number_endpoints() { return 16; }
 
-__attribute__((aligned(512))) BdtEntry
-    usb0_buffer_descriptor_table[number_endpoints() * 2 /* rx/tx */ *
-                                 2 /* even/odd */];
+__attribute__((aligned(512)))
+BdtEntry usb0_buffer_descriptor_table[number_endpoints() * 2 /* rx/tx */ *
+                                      2 /* even/odd */];
 
 // Returns the specified BDT entry.
 BdtEntry *MutableBdtEntry(int endpoint, Direction direction, EvenOdd odd) {
@@ -121,13 +121,13 @@
 
   device_descriptor_ =
       device_descriptor_list_.CreateDescriptor(18, UsbDescriptorType::kDevice);
-  device_descriptor_->AddUint16(0x0200);  // bcdUSB
-  device_descriptor_->AddByte(iad_device_class());  // bDeviceClass
+  device_descriptor_->AddUint16(0x0200);               // bcdUSB
+  device_descriptor_->AddByte(iad_device_class());     // bDeviceClass
   device_descriptor_->AddByte(iad_device_subclass());  // bDeviceSubClass
   device_descriptor_->AddByte(iad_device_protocol());  // bDeviceProtocol
-  device_descriptor_->AddByte(kEndpoint0MaxSize);  // bMaxPacketSize0
-  device_descriptor_->AddUint16(vendor_id);  // idVendor
-  device_descriptor_->AddUint16(product_id);  // idProduct
+  device_descriptor_->AddByte(kEndpoint0MaxSize);      // bMaxPacketSize0
+  device_descriptor_->AddUint16(vendor_id);            // idVendor
+  device_descriptor_->AddUint16(product_id);           // idProduct
   // Increment this whenever you need Windows boxes to actually pay attention to
   // changes.
   device_descriptor_->AddUint16(25);  // bcdDevice
@@ -211,7 +211,7 @@
   config_descriptor_->AddByte(0);  // iConfiguration
   config_descriptor_->AddByte((1 << 7) /* Reserved */ |
                               (1 << 6) /* Self-powered */);  // bmAttribute
-  config_descriptor_->AddByte(2 /* 4mA */);  // bMaxPower
+  config_descriptor_->AddByte(2 /* 4mA */);                  // bMaxPower
 
   device_descriptor_.reset();
   config_descriptor_.reset();
@@ -440,9 +440,9 @@
       break;
 
     case UsbPid::kOut:
-     for (UsbFunction *function : functions_) {
-       switch (function->HandleEndpoint0OutPacket(
-           bdt_entry->address, G_USB_BD_BC(bdt_entry->buffer_descriptor))) {
+      for (UsbFunction *function : functions_) {
+        switch (function->HandleEndpoint0OutPacket(
+            bdt_entry->address, G_USB_BD_BC(bdt_entry->buffer_descriptor))) {
           case SetupResponse::kIgnored:
             break;
           case SetupResponse::kHandled:
@@ -473,7 +473,7 @@
         // TODO(Brian): Keep track of which direction it is and how much we've
         // finished so we actually know when to stall it, both here and for
         // kOut tokens.
-        //StallEndpoint0();
+        // StallEndpoint0();
       }
 
       // If we have a new address, there is nothing left in the setup request
@@ -755,19 +755,27 @@
               // Microsoft is going to set them to; not like they document it
               // anywhere obvious...
               if (descriptor_index == 0xEE && setup_packet.index == 0) {
-                static uint8_t
-                    kMicrosoftOsStringDescriptor
-                        [] = {
-                            0x12,  // bLength
-                            static_cast<uint8_t>(
-                                UsbDescriptorType::kString),  // bDescriptorType
-                            0x4D,
-                            0x00, 0x53, 0x00, 0x46, 0x00, 0x54, 0x00, 0x31,
-                            0x00, 0x30, 0x00, 0x30,
-                            0x00,                     // qwSignature
-                            microsoft_vendor_code(),  // bMS_VendorCode
-                            0x00                      // bPad
-                        };
+                static uint8_t kMicrosoftOsStringDescriptor[] = {
+                    0x12,  // bLength
+                    static_cast<uint8_t>(
+                        UsbDescriptorType::kString),  // bDescriptorType
+                    0x4D,
+                    0x00,
+                    0x53,
+                    0x00,
+                    0x46,
+                    0x00,
+                    0x54,
+                    0x00,
+                    0x31,
+                    0x00,
+                    0x30,
+                    0x00,
+                    0x30,
+                    0x00,                     // qwSignature
+                    microsoft_vendor_code(),  // bMS_VendorCode
+                    0x00                      // bPad
+                };
                 QueueEndpoint0Data(
                     reinterpret_cast<char *>(kMicrosoftOsStringDescriptor),
                     ::std::min<int>(setup_packet.length,
diff --git a/motors/usb/usb.h b/motors/usb/usb.h
index 1273efd..1117bc8 100644
--- a/motors/usb/usb.h
+++ b/motors/usb/usb.h
@@ -3,9 +3,10 @@
 
 #include <assert.h>
 #include <string.h>
+
+#include <memory>
 #include <string>
 #include <vector>
-#include <memory>
 
 #include "aos/macros.h"
 #include "motors/core/kinetis.h"
@@ -175,9 +176,7 @@
           end_index_(end_index),
           next_index_(start_index_) {}
 
-    char *data() const {
-      return &descriptor_list_->data_[0];
-    }
+    char *data() const { return &descriptor_list_->data_[0]; }
 
     UsbDescriptorList *const descriptor_list_;
     const int start_index_, end_index_;