update_engine: fixed warnings from cpplint

Fixed all the cpplint warnings in update engine.

BUG=None
TEST=Unit tests still pass.

Change-Id: I285ae858eec8abe0b26ff203b99a42a200ceb71c
Reviewed-on: https://chromium-review.googlesource.com/204027
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/utils.cc b/utils.cc
index 9e4a4d8..af536d0 100644
--- a/utils.cc
+++ b/utils.cc
@@ -19,6 +19,7 @@
 #include <unistd.h>
 
 #include <algorithm>
+#include <utility>
 #include <vector>
 
 #include <base/file_util.h>
@@ -174,7 +175,6 @@
   }
   *out_bytes_read = bytes_read;
   return true;
-
 }
 
 // Append |nbytes| of content from |buf| to the vector pointed to by either
@@ -327,7 +327,7 @@
  private:
   DIR** dir_;
 };
-}  // namespace {}
+}  // namespace
 
 bool RecursiveUnlinkDir(const std::string& path) {
   struct stat stbuf;
@@ -527,27 +527,6 @@
   return S_ISDIR(stbuf.st_mode);
 }
 
-std::string TempFilename(string path) {
-  static const string suffix("XXXXXX");
-  CHECK(StringHasSuffix(path, suffix));
-  do {
-    string new_suffix;
-    for (unsigned int i = 0; i < suffix.size(); i++) {
-      int r = rand() % (26 * 2 + 10);  // [a-zA-Z0-9]
-      if (r < 26)
-        new_suffix.append(1, 'a' + r);
-      else if (r < (26 * 2))
-        new_suffix.append(1, 'A' + r - 26);
-      else
-        new_suffix.append(1, '0' + r - (26 * 2));
-    }
-    CHECK_EQ(new_suffix.size(), suffix.size());
-    path.resize(path.size() - new_suffix.size());
-    path.append(new_suffix);
-  } while (FileExists(path.c_str()));
-  return path;
-}
-
 // If |path| is absolute, or explicit relative to the current working directory,
 // leaves it as is. Otherwise, if TMPDIR is defined in the environment and is
 // non-empty, prepends it to |path|. Otherwise, prepends /tmp.  Returns the
@@ -612,7 +591,7 @@
 
 bool MountFilesystem(const string& device,
                      const string& mountpoint,
-                     unsigned long mountflags) {
+                     unsigned long mountflags) {  // NOLINT(runtime/int)
   int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags, NULL);
   if (rc < 0) {
     string msg = ErrnoNumberAsString(errno);
@@ -802,7 +781,7 @@
 // consistent stack trace.
 gboolean TriggerCrashReporterUpload(void* unused) {
   pid_t pid = fork();
-  CHECK(pid >= 0) << "fork failed";  // fork() failed. Something is very wrong.
+  CHECK_GE(pid, 0) << "fork failed";  // fork() failed. Something is very wrong.
   if (pid == 0) {
     // We are the child. Crash.
     abort();  // never returns
@@ -812,7 +791,7 @@
   LOG_IF(ERROR, result < 0) << "waitpid() failed";
   return FALSE;  // Don't call this callback again
 }
-}  // namespace {}
+}  // namespace
 
 void ScheduleCrashReporterUpload() {
   g_idle_add(&TriggerCrashReporterUpload, NULL);
@@ -822,8 +801,8 @@
   string string_shares = base::IntToString(static_cast<int>(shares));
   string cpu_shares_file = string(utils::kCGroupDir) + "/cpu.shares";
   LOG(INFO) << "Setting cgroup cpu shares to  " << string_shares;
-  if(utils::WriteFile(cpu_shares_file.c_str(), string_shares.c_str(),
-                      string_shares.size())){
+  if (utils::WriteFile(cpu_shares_file.c_str(), string_shares.c_str(),
+                       string_shares.size())) {
     return true;
   } else {
     LOG(ERROR) << "Failed to change cgroup cpu shares to "<< string_shares
@@ -1184,7 +1163,7 @@
                     static_cast<uint32_t>(ErrorCode::kSpecialFlags));
   string flag_names;
   string separator = "";
-  for(size_t i = 0; i < sizeof(flags) * 8; i++) {
+  for (size_t i = 0; i < sizeof(flags) * 8; i++) {
     uint32_t flag = flags & (1 << i);
     if (flag) {
       flag_names += separator + CodeToString(static_cast<ErrorCode>(flag));