Buffet: utility function tweaks

Various tweakes to helper functions and classes, split off from
a larger CL that required them.

1. Added Error::AddToPrintf to help add formatted error messages.
2. Added Error::GetFirstError to get the innermost error occurred.
3. Added string_utils::ToString and swept code using std::to_string
   in order to ensure we format doubles correctly (using %g instead
   of %f format specifier) and bool values (using "true"/"false"
   instead of 1/0).
4. Fixed C-style cast in http_utils.h and using static_cast now.
5. Fixed a few linter warnings. Also since the linter was updated
   there is no reason to have some NOLINT since many C++11 features
   are now recognized properly by cpplint.

BUG=None
TEST=All unit tests pass.

Change-Id: I208ffaa3f0ec0a5ff78bf9e8151e784ec8cd77e2
Reviewed-on: https://chromium-review.googlesource.com/202962
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/device_registration_info.cc b/buffet/device_registration_info.cc
index 4aab715..5447726 100644
--- a/buffet/device_registration_info.cc
+++ b/buffet/device_registration_info.cc
@@ -66,9 +66,7 @@
     const std::string& access_token) {
   std::string authorization =
       buffet::string_utils::Join(' ', access_token_type, access_token);
-  // Linter doesn't like the ; after } on the following line...
-  return {buffet::http::request_header::kAuthorization,
-          authorization};  // NOLINT
+  return {buffet::http::request_header::kAuthorization, authorization};
 }
 
 std::unique_ptr<base::DictionaryValue> ParseOAuthResponse(
@@ -320,8 +318,8 @@
   if (!param_value.empty())
     return true;
 
-  Error::AddTo(error, kErrorDomainBuffet, "missing_parameter",
-               "Parameter " + param_name + " not specified");
+  Error::AddToPrintf(error, kErrorDomainBuffet, "missing_parameter",
+                     "Parameter %s not specified", param_name.c_str());
   return false;
 }
 
@@ -364,9 +362,9 @@
   set_device_configuration_params->Append(param1);
 
   base::ListValue* vendor_commands = new base::ListValue;
-  for (auto&& pair : commands) {
+  for (const auto& pair : commands) {
     base::ListValue* params = new base::ListValue;
-    for (auto&& param_name : pair.second) {
+    for (const auto& param_name : pair.second) {
       base::DictionaryValue* param = new base::DictionaryValue;
       param->SetString("name", param_name);
       params->Append(param);