cleaned up lots of not-so-niceties and a few bugs

I built everything with clang (hackishly in some areas) and it spit out a bunch
of warnings.
diff --git a/aos/common/die.h b/aos/common/die.h
index d973b42..3c5cca9 100644
--- a/aos/common/die.h
+++ b/aos/common/die.h
@@ -3,6 +3,8 @@
 
 #include <stdarg.h>
 
+#include "aos/common/macros.h"
+
 namespace aos {
 
 // Terminates the task/process and logs a message (without using the logging
@@ -10,10 +12,10 @@
 // (code that can should LOG(FATAL), which calls this).
 void Die(const char *format, ...)
     __attribute__((noreturn))
-    __attribute__((format(gnu_printf, 1, 2)));
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 1, 2)));
 void VDie(const char *format, va_list args)
     __attribute__((noreturn))
-    __attribute__((format(gnu_printf, 1, 0)));
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 1, 0)));
 
 // Turns on (or off) "test mode", where (V)Die doesn't write out files and
 // doesn't print to stdout.
diff --git a/aos/common/logging/logging.h b/aos/common/logging/logging.h
index 114007b..6487b64 100644
--- a/aos/common/logging/logging.h
+++ b/aos/common/logging/logging.h
@@ -33,27 +33,20 @@
 // Not static const size_t for C code.
 #define LOG_MESSAGE_LEN 400
 
-#ifdef __VXWORKS__
-// We're using ancient glibc, so sticking to just what the syscall can handle is
-// probably safer.
-#define LOG_PRINTF_FORMAT_TYPE printf
-#else
-#define LOG_PRINTF_FORMAT_TYPE gnu_printf
-#endif
 #ifdef __cplusplus
 extern "C" {
 #endif
 // Actually implements the basic logging call.
 // Does not check that level is valid.
 void log_do(log_level level, const char *format, ...)
-  __attribute__((format(LOG_PRINTF_FORMAT_TYPE, 2, 3)));
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 3)));
 
 void log_cork(int line, const char *function, const char *format, ...)
-  __attribute__((format(LOG_PRINTF_FORMAT_TYPE, 3, 4)));
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)));
 // Implements the uncork logging call.
 void log_uncork(int line, const char *function, log_level level,
                 const char *file, const char *format, ...)
-  __attribute__((format(LOG_PRINTF_FORMAT_TYPE, 5, 6)));
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 5, 6)));
 #ifdef __cplusplus
 }
 #endif
diff --git a/aos/common/logging/logging_impl.cc b/aos/common/logging/logging_impl.cc
index 5c5dfc4..714aaf1 100644
--- a/aos/common/logging/logging_impl.cc
+++ b/aos/common/logging/logging_impl.cc
@@ -25,6 +25,7 @@
     LOG(FATAL, "can't have a next logger from here\n");
   }
 
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap) {
     LogMessage message;
     internal::FillInMessage(level, format, ap, &message);
diff --git a/aos/common/logging/logging_impl.h b/aos/common/logging/logging_impl.h
index 440e3fe..57f09ec 100644
--- a/aos/common/logging/logging_impl.h
+++ b/aos/common/logging/logging_impl.h
@@ -15,10 +15,11 @@
 #include "aos/common/logging/logging.h"
 #include "aos/common/type_traits.h"
 #include "aos/common/mutex.h"
+#include "aos/common/macros.h"
 
 namespace aos {
 
-class MessageType;
+struct MessageType;
 
 }  // namespace aos
 
@@ -101,16 +102,19 @@
 
 // Takes a message and logs it. It will set everything up and then call DoLog
 // for the current LogImplementation.
-void VLog(log_level level, const char *format, va_list ap);
+void VLog(log_level level, const char *format, va_list ap)
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
 // Adds to the saved up message.
-void VCork(int line, const char *format, va_list ap);
+void VCork(int line, const char *function, const char *format, va_list ap)
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)));
 // Actually logs the saved up message.
-void VUnCork(int line, log_level level, const char *file,
-             const char *format, va_list ap);
+void VUnCork(int line, const char *function, log_level level, const char *file,
+             const char *format, va_list ap)
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 5, 0)));
 
 // Will call VLog with the given arguments for the next logger in the chain.
 void LogNext(log_level level, const char *format, ...)
-  __attribute__((format(LOG_PRINTF_FORMAT_TYPE, 2, 3)));
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 3)));
 
 // Takes a structure and log it.
 template <class T>
@@ -140,7 +144,9 @@
  private:
   // Actually logs the given message. Implementations should somehow create a
   // LogMessage and then call internal::FillInMessage.
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap) = 0;
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)))
   void DoLogVariadic(log_level level, const char *format, ...) {
     va_list ap;
     va_start(ap, format);
@@ -167,7 +173,8 @@
   // These functions call similar methods on the "current" LogImplementation or
   // Die if they can't find one.
   // levels is how many LogImplementations to not use off the stack.
-  static void DoVLog(log_level, const char *format, va_list ap, int levels);
+  static void DoVLog(log_level, const char *format, va_list ap, int levels)
+      __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
   // This one is implemented in queue_logging.cc.
   static void DoLogStruct(log_level level, const ::std::string &message,
                           size_t size, const MessageType *type,
@@ -195,6 +202,7 @@
   StreamLogImplementation(FILE *stream);
 
  private:
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap);
 
   FILE *const stream_;
@@ -297,8 +305,10 @@
 // Fills in *message according to the given inputs (with type kString).
 // Used for implementing LogImplementation::DoLog.
 void FillInMessage(log_level level, const char *format, va_list ap,
-                   LogMessage *message);
+                   LogMessage *message)
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
 
+__attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)))
 static inline void FillInMessageVarargs(log_level level, LogMessage *message,
                                         const char *format, ...) {
   va_list ap;
@@ -313,7 +323,8 @@
 // Prints format (with ap) into output and correctly deals with the result
 // being too long etc.
 size_t ExecuteFormat(char *output, size_t output_size, const char *format,
-                     va_list ap);
+                     va_list ap)
+    __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)));
 
 // Runs the given function with the current LogImplementation (handles switching
 // it out while running function etc).
diff --git a/aos/common/logging/logging_impl_test.cc b/aos/common/logging/logging_impl_test.cc
index dea1815..f472bef 100644
--- a/aos/common/logging/logging_impl_test.cc
+++ b/aos/common/logging/logging_impl_test.cc
@@ -16,6 +16,7 @@
 namespace testing {
 
 class TestLogImplementation : public LogImplementation {
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap) {
     internal::FillInMessage(level, format, ap, &message_);
 
diff --git a/aos/common/macros.h b/aos/common/macros.h
index ba23fe4..a2a7891 100644
--- a/aos/common/macros.h
+++ b/aos/common/macros.h
@@ -25,4 +25,12 @@
 #define STRINGIFY(x) TO_STRING(x)
 #define TO_STRING(x) #x
 
+#ifdef __VXWORKS__
+// We're using ancient glibc, so sticking to just what the syscall can handle is
+// probably safer.
+#define GOOD_PRINTF_FORMAT_TYPE printf
+#else
+#define GOOD_PRINTF_FORMAT_TYPE gnu_printf
+#endif
+
 #endif  // _AOS_COMMON_MACROS_H_
diff --git a/aos/common/queue.h b/aos/common/queue.h
index 927f11f..33dc377 100644
--- a/aos/common/queue.h
+++ b/aos/common/queue.h
@@ -18,7 +18,7 @@
 
 namespace aos {
 
-class MessageType;
+struct MessageType;
 
 // This class is a base class for all messages sent over queues.
 // All of the methods are overloaded in (generated) subclasses to do the same
diff --git a/aos/common/queue_testutils.cc b/aos/common/queue_testutils.cc
index 8d195c5..5455859 100644
--- a/aos/common/queue_testutils.cc
+++ b/aos/common/queue_testutils.cc
@@ -49,6 +49,7 @@
     return new TestLogImplementation();
   }
 
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap) {
     LogMessage message;
 
diff --git a/aos/common/time_test.cc b/aos/common/time_test.cc
index ebc8284..c073e9e 100644
--- a/aos/common/time_test.cc
+++ b/aos/common/time_test.cc
@@ -11,7 +11,7 @@
 TEST(TimeTest, timespecConversions) {
   timespec start{1234, 5678};  // NOLINT
   Time time(start);
-  EXPECT_EQ(start.tv_sec, static_cast<signed time_t>(time.sec()));
+  EXPECT_EQ(start.tv_sec, static_cast<time_t>(time.sec()));
   EXPECT_EQ(start.tv_nsec, time.nsec());
   timespec end = time.ToTimespec();
   EXPECT_EQ(start.tv_sec, end.tv_sec);
diff --git a/aos/common/util/trapezoid_profile.h b/aos/common/util/trapezoid_profile.h
index 92e3dbe..3f7caa1 100644
--- a/aos/common/util/trapezoid_profile.h
+++ b/aos/common/util/trapezoid_profile.h
@@ -55,7 +55,6 @@
   double constant_time_;
   double deceleration_time_;
   double deceleration_;
-  double current_velocity_;
 
   double maximum_acceleration_;
   double maximum_velocity_;
diff --git a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h
index c8a6117..6949582 100644
--- a/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h
+++ b/aos/externals/WPILib/WPILib/NetworkRobot/NetworkRobotValues.h
@@ -256,7 +256,7 @@
     }
 
     // So that it can access bits directly for Serialize/Deserialize.
-    friend class NetworkRobotJoysticks;
+    friend struct NetworkRobotJoysticks;
 
     uint8_t bits;
   } control;
diff --git a/aos/linux_code/ipc_lib/raw_queue_test.cc b/aos/linux_code/ipc_lib/raw_queue_test.cc
index c2506a4..fecf488 100644
--- a/aos/linux_code/ipc_lib/raw_queue_test.cc
+++ b/aos/linux_code/ipc_lib/raw_queue_test.cc
@@ -47,7 +47,8 @@
       case ResultType::NotCalled:
         return "NotCalled";
       default:
-        return std::string("unknown(" + static_cast<uint8_t>(result)) + ")";
+        return std::string("unknown(") +
+               ::std::to_string(static_cast<uint8_t>(result)) + ")";
     }
   }
   static_assert(aos::shm_ok<ResultType>::value,
diff --git a/aos/linux_code/logging/linux_logging.cc b/aos/linux_code/logging/linux_logging.cc
index 65e6ca2..cdb052a 100644
--- a/aos/linux_code/logging/linux_logging.cc
+++ b/aos/linux_code/logging/linux_logging.cc
@@ -37,6 +37,7 @@
 }
 
 class LinuxQueueLogImplementation : public LogImplementation {
+  __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
   virtual void DoLog(log_level level, const char *format, va_list ap) override {
     LogMessage *message = GetMessageOrDie();
     internal::FillInMessage(level, format, ap, message);
diff --git a/bbb_cape/src/bbb/packet_finder_test.cc b/bbb_cape/src/bbb/packet_finder_test.cc
index 3e6dc26..dddf0ec 100644
--- a/bbb_cape/src/bbb/packet_finder_test.cc
+++ b/bbb_cape/src/bbb/packet_finder_test.cc
@@ -43,10 +43,9 @@
     ::aos::common::testing::EnableTestLogging();
   }
 
-  template <typename Data, size_t N = 0>
+  template <typename Data, size_t N>
   void ReceivePackets(const Data &data, int packets,
-                      ::std::array<int, N> expected_failures =
-                          ::std::array<int, 0>()) {
+                      ::std::array<int, N> expected_failures) {
     TestByteReader reader(data);
     PacketFinder packet_finder(&reader, 144);
     auto failure = expected_failures.begin();
@@ -71,6 +70,10 @@
     }
     EXPECT_FALSE(packet_finder.ReadPacket(::aos::time::Time(0, 0)));
   }
+  template <typename Data>
+  void ReceivePackets(const Data &data, int packets) {
+    ReceivePackets(data, packets, ::std::array<int, 0>());
+  }
 };
 
 static constexpr ::std::array<uint8_t, 896> kTestData1{
diff --git a/frc971/autonomous/auto.cc b/frc971/autonomous/auto.cc
index aaf0d2b..5a4b4a1 100644
--- a/frc971/autonomous/auto.cc
+++ b/frc971/autonomous/auto.cc
@@ -344,7 +344,7 @@
       auto_version = AutoVersion::kDoubleHot;
     }
   }
-  LOG(INFO, "running auto %" PRIu8 "\n", auto_version);
+  LOG(INFO, "running auto %" PRIu8 "\n", static_cast<uint8_t>(auto_version));
 
   HotGoalDecoder hot_goal_decoder;
   // True for left, false for right.