update_engine: Replace NULL with nullptr

Replaced the usage of NULL with nullptr. This also makes it possible to
use standard gtest macros to compare pointers in Update Manager's unit tests.
So, there is no need in custom UMTEST_... macros which are replaced with the
gtest macros (see change in update_engine/update_manager/umtest_utils.h):

UMTEST_ASSERT_NULL(p)      => ASSERT_EQ(nullptr, p)
UMTEST_ASSERT_NOT_NULL(p)  => ASSERT_NE(nullptr, p)
UMTEST_EXPECT_NULL(p)      => EXPECT_EQ(nullptr, p)
UMTEST_EXPECT_NOT_NULL(p)  => EXPECT_NE(nullptr, p)

BUG=None
TEST=FEATURES=test emerge-link update_engine
     USE="clang asan" FEATURES=test emerge-link update_engine

Change-Id: I77a42a1e9ce992bb2f9f263db5cf75fe6110a4ec
Reviewed-on: https://chromium-review.googlesource.com/215136
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/utils.cc b/utils.cc
index ed57c14..6c527b3 100644
--- a/utils.cc
+++ b/utils.cc
@@ -323,8 +323,8 @@
     if (dir_ && *dir_) {
       int r = closedir(*dir_);
       TEST_AND_RETURN_ERRNO(r == 0);
-      *dir_ = NULL;
-      dir_ = NULL;
+      *dir_ = nullptr;
+      dir_ = nullptr;
     }
   }
  private:
@@ -354,7 +354,7 @@
     struct dirent *dir_entry_p;
     int err = 0;
     while ((err = readdir_r(dir, &dir_entry, &dir_entry_p)) == 0) {
-      if (dir_entry_p == NULL) {
+      if (dir_entry_p == nullptr) {
         // end of stream reached
         break;
       }
@@ -575,7 +575,7 @@
   buf[dirname_template.size()] = '\0';
 
   char* return_code = mkdtemp(&buf[0]);
-  TEST_AND_RETURN_FALSE_ERRNO(return_code != NULL);
+  TEST_AND_RETURN_FALSE_ERRNO(return_code != nullptr);
   *dirname = &buf[0];
   return true;
 }
@@ -595,7 +595,8 @@
 bool MountFilesystem(const string& device,
                      const string& mountpoint,
                      unsigned long mountflags) {  // NOLINT(runtime/int)
-  int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags, NULL);
+  int rc = mount(device.c_str(), mountpoint.c_str(), "ext3", mountflags,
+                 nullptr);
   if (rc < 0) {
     string msg = ErrnoNumberAsString(errno);
     LOG(ERROR) << "Unable to mount destination device: " << msg << ". "
@@ -792,14 +793,14 @@
     abort();  // never returns
   }
   // We are the parent. Wait for child to terminate.
-  pid_t result = waitpid(pid, NULL, 0);
+  pid_t result = waitpid(pid, nullptr, 0);
   LOG_IF(ERROR, result < 0) << "waitpid() failed";
   return FALSE;  // Don't call this callback again
 }
 }  // namespace
 
 void ScheduleCrashReporterUpload() {
-  g_idle_add(&TriggerCrashReporterUpload, NULL);
+  g_idle_add(&TriggerCrashReporterUpload, nullptr);
 }
 
 bool SetCpuShares(CpuShares shares) {
@@ -1401,7 +1402,7 @@
        i != vector.end(); ++i) {
     g_ptr_array_add(p, g_strdup(i->c_str()));
   }
-  g_ptr_array_add(p, NULL);
+  g_ptr_array_add(p, nullptr);
   return reinterpret_cast<gchar**>(g_ptr_array_free(p, FALSE));
 }
 
@@ -1477,7 +1478,7 @@
   }
 
   FILE *file = base::CreateAndOpenTemporaryFile(out_path);
-  if (file == NULL) {
+  if (file == nullptr) {
     LOG(ERROR) << "Error creating temporary file.";
     return false;
   }