crash-reporter: Replace NULL with nullptr.

BUG=None
TEST=`FEATURES=test emerge-$BOARD crash-reporter`

Change-Id: If0804613ee0385752d01f7bbe01902ffef53bd94
Reviewed-on: https://chromium-review.googlesource.com/218870
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/crash_reporter/chrome_collector.cc b/crash_reporter/chrome_collector.cc
index 438ecbc..b7fa7ca 100644
--- a/crash_reporter/chrome_collector.cc
+++ b/crash_reporter/chrome_collector.cc
@@ -45,7 +45,7 @@
 bool GetDriErrorState(const chromeos::dbus::Proxy &proxy,
                       const FilePath &error_state_path) {
   chromeos::glib::ScopedError error;
-  gchar *error_state = NULL;
+  gchar *error_state = nullptr;
   if (!dbus_g_proxy_call(proxy.gproxy(), debugd::kGetLog,
                          &chromeos::Resetter(&error).lvalue(),
                          G_TYPE_STRING, "i915_error_state", G_TYPE_INVALID,
@@ -150,12 +150,12 @@
   FilePath dir;
   uid_t uid = atoi(uid_string.c_str());
   pid_t pid = atoi(pid_string.c_str());
-  if (!GetCreatedCrashDirectoryByEuid(uid, &dir, NULL)) {
+  if (!GetCreatedCrashDirectoryByEuid(uid, &dir, nullptr)) {
     LOG(ERROR) << "Can't create crash directory for uid " << uid;
     return false;
   }
 
-  std::string dump_basename = FormatDumpBasename(exe_name, time(NULL), pid);
+  std::string dump_basename = FormatDumpBasename(exe_name, time(nullptr), pid);
   FilePath meta_path = GetCrashPath(dir, dump_basename, "meta");
   FilePath minidump_path = GetCrashPath(dir, dump_basename, "dmp");
   FilePath log_path = GetCrashPath(dir, dump_basename, "log.tar.xz");
diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc
index fcb0845..825ed08 100644
--- a/crash_reporter/crash_collector.cc
+++ b/crash_reporter/crash_collector.cc
@@ -88,8 +88,8 @@
 void CrashCollector::Initialize(
     CrashCollector::CountCrashFunction count_crash_function,
     CrashCollector::IsFeedbackAllowedFunction is_feedback_allowed_function) {
-  CHECK(count_crash_function != NULL);
-  CHECK(is_feedback_allowed_function != NULL);
+  CHECK(count_crash_function);
+  CHECK(is_feedback_allowed_function);
 
   count_crash_function_ = count_crash_function;
   is_feedback_allowed_function_ = is_feedback_allowed_function;
@@ -156,7 +156,7 @@
 }
 
 GHashTable *CrashCollector::GetActiveUserSessions() {
-  GHashTable *active_sessions = NULL;
+  GHashTable *active_sessions = nullptr;
 
   chromeos::dbus::BusConnection dbus = chromeos::dbus::GetSystemBusConnection();
   if (!dbus.HasConnection()) {
@@ -174,7 +174,7 @@
   }
 
   // Request all the active sessions.
-  GError *gerror = NULL;
+  GError *gerror = nullptr;
   if (!dbus_g_proxy_call(proxy.gproxy(),
                          login_manager::kSessionManagerRetrieveActiveSessions,
                          &gerror, G_TYPE_INVALID,
@@ -243,10 +243,10 @@
                                          gid_t *gid) {
   char storage[256];
   struct passwd passwd_storage;
-  struct passwd *passwd_result = NULL;
+  struct passwd *passwd_result = nullptr;
 
   if (getpwnam_r(name.c_str(), &passwd_storage, storage, sizeof(storage),
-                 &passwd_result) != 0 || passwd_result == NULL) {
+                 &passwd_result) != 0 || passwd_result == nullptr) {
     LOG(ERROR) << "Cannot find user named " << name;
     return false;
   }
@@ -262,7 +262,7 @@
   uid_t default_user_id;
   gid_t default_user_group;
 
-  if (out_of_capacity != NULL) *out_of_capacity = false;
+  if (out_of_capacity) *out_of_capacity = false;
 
   // For testing.
   if (!forced_crash_directory_.empty()) {
@@ -308,7 +308,7 @@
   }
 
   if (!CheckHasCapacity(*crash_directory)) {
-    if (out_of_capacity != NULL) *out_of_capacity = true;
+    if (out_of_capacity) *out_of_capacity = true;
     return false;
   }
 
@@ -386,7 +386,7 @@
   struct dirent* ent;
   bool full = false;
   std::set<std::string> basenames;
-  while (readdir_r(dir, &ent_buf, &ent) == 0 && ent != NULL) {
+  while (readdir_r(dir, &ent_buf, &ent) == 0 && ent) {
     if ((strcmp(ent->d_name, ".") == 0) ||
         (strcmp(ent->d_name, "..") == 0))
       continue;
diff --git a/crash_reporter/crash_collector.h b/crash_reporter/crash_collector.h
index c98d4a5..a1565e3 100644
--- a/crash_reporter/crash_collector.h
+++ b/crash_reporter/crash_collector.h
@@ -91,7 +91,7 @@
 
   // Determines the crash directory for given euid, and creates the
   // directory if necessary with appropriate permissions.  If
-  // |out_of_capacity| is not NULL, it is set to indicate if the call
+  // |out_of_capacity| is not nullptr, it is set to indicate if the call
   // failed due to not having capacity in the crash directory. Returns
   // true whether or not directory needed to be created, false on any
   // failure.  If the crash directory is at capacity, returns false.
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index a483c84..1da71d4 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -172,7 +172,7 @@
   // Accumulate logs to help in diagnosing failures during user collection.
   chromeos::LogToString(true);
   // Handle the crash, get the name of the process from procfs.
-  bool handled = user_collector->HandleCrash(FLAGS_user, NULL);
+  bool handled = user_collector->HandleCrash(FLAGS_user, nullptr);
   chromeos::LogToString(false);
   if (!handled)
     return 1;
diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc
index ab7e250..6ba529f 100644
--- a/crash_reporter/kernel_collector.cc
+++ b/crash_reporter/kernel_collector.cc
@@ -236,7 +236,8 @@
 }
 
 bool KernelCollector::Enable() {
-  if (arch_ == kArchUnknown || arch_ >= kArchCount || kPCRegex[arch_] == NULL) {
+  if (arch_ == kArchUnknown || arch_ >= kArchCount ||
+      kPCRegex[arch_] == nullptr) {
     LOG(WARNING) << "KernelCollector does not understand this architecture";
     return false;
   }
@@ -519,12 +520,12 @@
 
     if (!GetCreatedCrashDirectoryByEuid(kRootUid,
                                         &root_crash_directory,
-                                        NULL)) {
+                                        nullptr)) {
       return true;
     }
 
     std::string dump_basename =
-        FormatDumpBasename(kKernelExecName, time(NULL), kKernelPid);
+        FormatDumpBasename(kKernelExecName, time(nullptr), kKernelPid);
     FilePath kernel_crash_path = root_crash_directory.Append(
         StringPrintf("%s.kcrash", dump_basename.c_str()));
 
diff --git a/crash_reporter/kernel_warning_collector.cc b/crash_reporter/kernel_warning_collector.cc
index b4ff3ea..5dcd1f6 100644
--- a/crash_reporter/kernel_warning_collector.cc
+++ b/crash_reporter/kernel_warning_collector.cc
@@ -68,12 +68,13 @@
   }
 
   FilePath root_crash_directory;
-  if (!GetCreatedCrashDirectoryByEuid(kRootUid, &root_crash_directory, NULL)) {
+  if (!GetCreatedCrashDirectoryByEuid(kRootUid, &root_crash_directory,
+                                      nullptr)) {
     return true;
   }
 
   std::string dump_basename =
-      FormatDumpBasename(kExecName, time(NULL), kKernelPid);
+      FormatDumpBasename(kExecName, time(nullptr), kKernelPid);
   FilePath kernel_crash_path = root_crash_directory.Append(
       StringPrintf("%s.kcrash", dump_basename.c_str()));
 
diff --git a/crash_reporter/list_proxies.cc b/crash_reporter/list_proxies.cc
index 282c6ae..6cac8f8 100644
--- a/crash_reporter/list_proxies.cc
+++ b/crash_reporter/list_proxies.cc
@@ -109,9 +109,9 @@
 
   void OnSignal(DBusMessage *message) override {
     // Get args
-    char *source_url = NULL;
-    char *proxy_list = NULL;
-    char *error = NULL;
+    char *source_url = nullptr;
+    char *proxy_list = nullptr;
+    char *error = nullptr;
     DBusError arg_error;
     dbus_error_init(&arg_error);
     if (!dbus_message_get_args(message, &arg_error,
@@ -150,7 +150,7 @@
 }
 
 static bool ShowBrowserProxies(std::string url, unsigned timeout) {
-  GMainLoop *main_loop = g_main_loop_new(NULL, false);
+  GMainLoop *main_loop = g_main_loop_new(nullptr, false);
 
   chromeos::dbus::BusConnection dbus = chromeos::dbus::GetSystemBusConnection();
   if (!dbus.HasConnection()) {
@@ -175,7 +175,7 @@
 
   // Request the proxies for our URL.  The answer is sent to us via a
   // proxy-resolved signal.
-  GError *gerror = NULL;
+  GError *gerror = nullptr;
   if (!dbus_g_proxy_call(browser_proxy.gproxy(),
                          kLibCrosServiceResolveNetworkProxyMethodName,
                          &gerror,
diff --git a/crash_reporter/udev_collector.cc b/crash_reporter/udev_collector.cc
index 6847d2a..e202fed 100644
--- a/crash_reporter/udev_collector.cc
+++ b/crash_reporter/udev_collector.cc
@@ -57,13 +57,13 @@
 
   // Make sure the crash directory exists, or create it if it doesn't.
   FilePath crash_directory;
-  if (!GetCreatedCrashDirectoryByEuid(0, &crash_directory, NULL)) {
+  if (!GetCreatedCrashDirectoryByEuid(0, &crash_directory, nullptr)) {
     LOG(ERROR) << "Could not get crash directory.";
     return false;
   }
   // Create the destination path.
   std::string log_file_name =
-      FormatDumpBasename(basename, time(NULL), 0);
+      FormatDumpBasename(basename, time(nullptr), 0);
   FilePath crash_path = GetCrashPath(crash_directory, log_file_name, "log");
 
   // Handle the crash.
diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc
index a3c6f9c..9056a5c 100644
--- a/crash_reporter/user_collector.cc
+++ b/crash_reporter/user_collector.cc
@@ -164,7 +164,7 @@
     return false;
   }
   const char *number = ids[kind].c_str();
-  char *end_number = NULL;
+  char *end_number = nullptr;
   *id = strtol(number, &end_number, 10);
   if (*end_number != '\0') {
     return false;
@@ -187,13 +187,13 @@
                                               const std::string &exec) {
   FilePath crash_path;
   LOG(INFO) << "Writing conversion problems as separate crash report.";
-  if (!GetCreatedCrashDirectoryByEuid(0, &crash_path, NULL)) {
+  if (!GetCreatedCrashDirectoryByEuid(0, &crash_path, nullptr)) {
     LOG(ERROR) << "Could not even get log directory; out of space?";
     return;
   }
   AddCrashMetaData("sig", kCollectionErrorSignature);
   AddCrashMetaData("error_type", GetErrorTypeSignature(error_type));
-  std::string dump_basename = FormatDumpBasename(exec, time(NULL), pid);
+  std::string dump_basename = FormatDumpBasename(exec, time(nullptr), pid);
   std::string error_log = chromeos::GetLog();
   FilePath diag_log_path = GetCrashPath(crash_path, dump_basename, "diaglog");
   if (GetLogContents(FilePath(log_config_path_), kCollectionErrorSignature,
@@ -447,7 +447,7 @@
   // been left around for diagnostics from a failed conversion attempt.
   // If we don't, existing files can cause forking to fail.
   base::DeleteFile(container_dir, true);
-  std::string dump_basename = FormatDumpBasename(exec, time(NULL), pid);
+  std::string dump_basename = FormatDumpBasename(exec, time(nullptr), pid);
   FilePath core_path = GetCrashPath(crash_path, dump_basename, "core");
   FilePath meta_path = GetCrashPath(crash_path, dump_basename, "meta");
   FilePath minidump_path = GetCrashPath(crash_path, dump_basename, "dmp");
diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc
index 5250c71..778c061 100644
--- a/crash_reporter/user_collector_test.cc
+++ b/crash_reporter/user_collector_test.cc
@@ -254,7 +254,7 @@
 
 TEST_F(UserCollectorTest, HandleSuppliedChromeCrashWithConsent) {
   s_metrics = true;
-  collector_.HandleCrash("0:2:chrome", NULL);
+  collector_.HandleCrash("0:2:chrome", nullptr);
   EXPECT_TRUE(FindLog(
       "Received crash notification for supplied_chrome[0] sig 2"));
   EXPECT_TRUE(FindLog(kChromeIgnoreMsg));
@@ -479,7 +479,7 @@
 
   // maps file is empty
   FilePath maps_file = container_dir.Append("maps");
-  ASSERT_EQ(0, base::WriteFile(maps_file, NULL, 0));
+  ASSERT_EQ(0, base::WriteFile(maps_file, nullptr, 0));
   ASSERT_TRUE(base::PathExists(maps_file));
   EXPECT_FALSE(collector_.ValidateProcFiles(container_dir));