Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14595032 authored by Alex Vakulenko's avatar Alex Vakulenko Committed by chrome-internal-fetch
Browse files

platform2: Replace NULL with nullptr in minor components

Replace NULL with nullptr in C++11-enabled components of platform2
that don't have too many occurrences of NULL. Other major
"offenders" will be handled separately.

BUG=None
TEST=FEATURES=test emerge-link app-shell-launcher buffet easy-unlock platform2 metrics wimax_manager

Change-Id: I61b25a057e3d6865908bc74f9f3d4cb55e08af26
Reviewed-on: https://chromium-review.googlesource.com/214837


Tested-by: default avatarAlex Vakulenko <avakulenko@chromium.org>
Reviewed-by: default avatarBen Chan <benchan@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
parent b1640eee
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ void MetricsDaemon::Init(bool testing,
                         const string& scaling_max_freq_path,
                         const string& cpuinfo_max_freq_path) {
  testing_ = testing;
  DCHECK(metrics_lib != NULL);
  DCHECK(metrics_lib != nullptr);
  metrics_lib_ = metrics_lib;

  // Get ticks per second (HZ) on this system.
@@ -284,7 +284,7 @@ void MetricsDaemon::Init(bool testing,
  LOG_IF(FATAL, dbus_error_is_set(&error)) <<
      "No D-Bus connection: " << SAFE_MESSAGE(error);

  dbus_connection_setup_with_g_main(connection, NULL);
  dbus_connection_setup_with_g_main(connection, nullptr);

  vector<string> matches;
  matches.push_back(
@@ -305,7 +305,7 @@ void MetricsDaemon::Init(bool testing,
  // Adds the D-Bus filter routine to be called back whenever one of
  // the registered D-Bus matches is successful. The daemon is not
  // activated for D-Bus messages that don't match.
  CHECK(dbus_connection_add_filter(connection, MessageFilter, this, NULL));
  CHECK(dbus_connection_add_filter(connection, MessageFilter, this, nullptr));

  update_stats_timeout_id_ =
      g_timeout_add(kUpdateStatsIntervalMs, &HandleUpdateStatsTimeout, this);
@@ -317,7 +317,7 @@ void MetricsDaemon::Init(bool testing,
}

void MetricsDaemon::Loop() {
  GMainLoop* loop = g_main_loop_new(NULL, false);
  GMainLoop* loop = g_main_loop_new(nullptr, false);
  g_main_loop_run(loop);
}

+3 −3
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ TEST_F(MetricsDaemonTest, MessageFilter) {

  DBusMessage* msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
  DBusHandlerResult res =
      MetricsDaemon::MessageFilter(/* connection */ NULL, msg, &daemon_);
      MetricsDaemon::MessageFilter(/* connection */ nullptr, msg, &daemon_);
  EXPECT_EQ(DBUS_HANDLER_RESULT_NOT_YET_HANDLED, res);
  DeleteDBusMessage(msg);

@@ -235,7 +235,7 @@ TEST_F(MetricsDaemonTest, MessageFilter) {
                            "org.chromium.CrashReporter",
                            "UserCrash",
                            signal_args);
  res = MetricsDaemon::MessageFilter(/* connection */ NULL, msg, &daemon_);
  res = MetricsDaemon::MessageFilter(/* connection */ nullptr, msg, &daemon_);
  EXPECT_EQ(DBUS_HANDLER_RESULT_HANDLED, res);
  DeleteDBusMessage(msg);

@@ -246,7 +246,7 @@ TEST_F(MetricsDaemonTest, MessageFilter) {
                            "org.chromium.UnknownService.Manager",
                            "StateChanged",
                            signal_args);
  res = MetricsDaemon::MessageFilter(/* connection */ NULL, msg, &daemon_);
  res = MetricsDaemon::MessageFilter(/* connection */ nullptr, msg, &daemon_);
  EXPECT_EQ(DBUS_HANDLER_RESULT_NOT_YET_HANDLED, res);
  DeleteDBusMessage(msg);
}
+3 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ bool MetricsLibrary::IsDeviceMounted(const char* device_name,
                                     char* buffer,
                                     int buffer_size,
                                     bool* result) {
  if (buffer == NULL || buffer_size < 1)
  if (buffer == nullptr || buffer_size < 1)
    return false;
  int mounts_fd = open(mounts_file, O_RDONLY);
  if (mounts_fd < 0)
@@ -121,7 +121,7 @@ bool MetricsLibrary::IsGuestMode() {

bool MetricsLibrary::AreMetricsEnabled() {
  static struct stat stat_buffer;
  time_t this_check_time = time(NULL);
  time_t this_check_time = time(nullptr);
  if (this_check_time != cached_enabled_time_) {
    cached_enabled_time_ = this_check_time;

@@ -157,7 +157,7 @@ void MetricsLibrary::Init() {

bool MetricsLibrary::SendToAutotest(const std::string& name, int value) {
  FILE* autotest_file = fopen(kAutotestPath, "a+");
  if (autotest_file == NULL) {
  if (autotest_file == nullptr) {
    PLOG(ERROR) << kAutotestPath << ": fopen";
    return false;
  }
+2 −1
Original line number Diff line number Diff line
@@ -152,7 +152,8 @@ void MetricsLibraryTest::VerifyEnabledCacheEviction(bool to_value) {
  ASSERT_EQ(!to_value, lib_.AreMetricsEnabled());
  EXPECT_CALL(*device_policy_, GetMetricsEnabled(_))
      .WillOnce(SetMetricsPolicy(to_value));
  ASSERT_LT(abs(static_cast<int>(time(NULL) - lib_.cached_enabled_time_)), 5);
  ASSERT_LT(abs(static_cast<int>(time(nullptr) - lib_.cached_enabled_time_)),
            5);
  // Sleep one second (or cheat to be faster).
  --lib_.cached_enabled_time_;
  ASSERT_EQ(to_value, lib_.AreMetricsEnabled());
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ bool Timer::GetElapsedTime(base::TimeDelta* elapsed_time) const {
}

// static
MetricsLibraryInterface* TimerReporter::metrics_lib_ = NULL;
MetricsLibraryInterface* TimerReporter::metrics_lib_ = nullptr;

TimerReporter::TimerReporter(const std::string& histogram_name, int min,
                             int max, int num_buckets)
Loading