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/util.h b/motors/util.h
index 3ac6213..8e7ce1c 100644
--- a/motors/util.h
+++ b/motors/util.h
@@ -1,14 +1,13 @@
 #ifndef MOTORS_UTIL_H_
 #define MOTORS_UTIL_H_
 
-#include <stdint.h>
 #include <stddef.h>
+#include <stdint.h>
 
 #include "motors/core/kinetis.h"
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
 // This bitband register for a specific bit of a given peripheral register.
@@ -61,12 +60,12 @@
 #define CAN_MCR_IRMQ ((uint32_t)(1 << 16))
 #define CAN_MCR_LPRIOEN ((uint32_t)(1 << 13))
 #define CAN_MCR_AEN ((uint32_t)(1 << 12))
-#define CAN_MCR_IDAM(n) ((uint32_t)(((n) & 3) << 8))
-#define CAN_MCR_MAXMB(n) ((uint32_t)((n) & 0x7F))
-#define CAN_CTRL1_PRESDIV(n) ((uint32_t)(((n) & 0xFF) << 24))
-#define CAN_CTRL1_RJW(n) ((uint32_t)(((n) & 3) << 22))
-#define CAN_CTRL1_PSEG1(n) ((uint32_t)(((n) & 7) << 19))
-#define CAN_CTRL1_PSEG2(n) ((uint32_t)(((n) & 7) << 16))
+#define CAN_MCR_IDAM(n) ((uint32_t)(((n)&3) << 8))
+#define CAN_MCR_MAXMB(n) ((uint32_t)((n)&0x7F))
+#define CAN_CTRL1_PRESDIV(n) ((uint32_t)(((n)&0xFF) << 24))
+#define CAN_CTRL1_RJW(n) ((uint32_t)(((n)&3) << 22))
+#define CAN_CTRL1_PSEG1(n) ((uint32_t)(((n)&7) << 19))
+#define CAN_CTRL1_PSEG2(n) ((uint32_t)(((n)&7) << 16))
 #define CAN_CTRL1_BOFFMSK ((uint32_t)(1 << 15))
 #define CAN_CTRL1_ERRMSK ((uint32_t)(1 << 14))
 #define CAN_CTRL1_CLKSRC ((uint32_t)(1 << 13))
@@ -78,7 +77,7 @@
 #define CAN_CTRL1_TSYN ((uint32_t)(1 << 5))
 #define CAN_CTRL1_LBUF ((uint32_t)(1 << 4))
 #define CAN_CTRL1_LOM ((uint32_t)(1 << 3))
-#define CAN_CTRL1_PROPSEG(n) ((uint32_t)((n) & 7))
+#define CAN_CTRL1_PROPSEG(n) ((uint32_t)((n)&7))
 #define CAN_ESR1_SYNCH ((uint32_t)(1 << 18))
 #define CAN_ESR1_TWRNINT ((uint32_t)(1 << 17))
 #define CAN_ESR1_RWRNINT ((uint32_t)(1 << 16))
@@ -97,8 +96,8 @@
 #define CAN_ESR1_ERRINT ((uint32_t)(1 << 1))
 #define CAN_ESR1_WAKINT ((uint32_t)1)
 #define CAN_CTRL2_WRMFRZ ((uint32_t)(1 << 28))
-#define CAN_CTRL2_RFFN(n) ((uint32_t)(((n) & 0xF) << 24))
-#define CAN_CTRL2_TASD(n) ((uint32_t)(((n) & 0x1F) << 19))
+#define CAN_CTRL2_RFFN(n) ((uint32_t)(((n)&0xF) << 24))
+#define CAN_CTRL2_TASD(n) ((uint32_t)(((n)&0x1F) << 19))
 #define CAN_CTRL2_MRP ((uint32_t)(1 << 18))
 #define CAN_CTRL2_RRS ((uint32_t)(1 << 17))
 #define CAN_CTRL2_EACEN ((uint32_t)(1 << 16))
@@ -115,13 +114,13 @@
 #define CAN0_RXIMRS ((volatile uint32_t *)0x40024880)
 #define CAN1_MESSAGES ((volatile CanMessageBuffer *)0x400A4080)
 #define CAN1_RXIMRS ((volatile uint32_t *)0x400A4880)
-#define CAN_MB_CONTROL_INSERT_DLC(dlc) ((uint32_t)(((dlc) & 0xF) << 16))
+#define CAN_MB_CONTROL_INSERT_DLC(dlc) ((uint32_t)(((dlc)&0xF) << 16))
 #define CAN_MB_CONTROL_EXTRACT_DLC(control_timestamp) \
   ((control_timestamp >> 16) & 0xF)
 #define CAN_MB_CONTROL_RTR ((uint32_t)(1 << 20))
 #define CAN_MB_CONTROL_IDE ((uint32_t)(1 << 21))
 #define CAN_MB_CONTROL_SRR ((uint32_t)(1 << 22))
-#define CAN_MB_CONTROL_INSERT_CODE(n) ((uint32_t)(((n) & 0xF) << 24))
+#define CAN_MB_CONTROL_INSERT_CODE(n) ((uint32_t)(((n)&0xF) << 24))
 #define CAN_MB_CONTROL_EXTRACT_CODE(n) ((uint32_t)(((n) >> 24) & 0xF))
 #define CAN_MB_CONTROL_CODE_BUSY_MASK CAN_MB_CONTROL_INSERT_CODE(1)
 #define CAN_MB_PRIO_ID_PRIORITY_MASK ((uint32_t)((1 << 29) - 1))
@@ -135,11 +134,11 @@
 #define CAN_MB_CODE_TX_DATA 0xC
 #define CAN_MB_CODE_TX_REMOTE 0xC
 #define CAN_MB_CODE_TX_TANSWER 0xE
-#define CAN_MB_CODE_IS_BUSY(code) ((code) & 1)
+#define CAN_MB_CODE_IS_BUSY(code) ((code)&1)
 
 // We have to define these, and leave them defined, because the C preprocessor
 // is annoying...
-#define REALLY_DO_CONCATENATE(x, y, z) x ## y ## z
+#define REALLY_DO_CONCATENATE(x, y, z) x##y##z
 #define DO_CONCATENATE(x, y, z) REALLY_DO_CONCATENATE(x, y, z)
 
 // Index-parameterized access to various registers from various peripherals.
@@ -204,7 +203,7 @@
 typedef struct {
 #define FOR_BIG_FTM_REGISTER(name) const uint32_t _reserved_##name;
 #define FOR_LITTLE_FTM_REGISTER(name) volatile uint32_t name;
-        ALL_FTM_REGISTERS
+  ALL_FTM_REGISTERS
 #undef FOR_BIG_FTM_REGISTER
 #undef FOR_LITTLE_FTM_REGISTER
 #undef FOR_BOTH_FTM_REGISTER
@@ -248,7 +247,7 @@
 
 // constexpr log base 2, which fails to compile for non-power-of-2 inputs.
 // This is a silly implementation to use at runtime.
-template<typename T>
+template <typename T>
 constexpr T ConstexprLog2(T i) {
   if (i == 0) {
     __builtin_abort();