From 4d5ec9803b74d0f3e9c002a92a748bd08b6640ac Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 22 Jan 2019 15:01:31 +0100 Subject: [PATCH] Replace NULL with nullptr. --- communicator.cpp | 18 +++++++++--------- deployment.cpp | 2 +- main.cpp | 4 ++-- msg_thread.cpp | 6 +++--- named_object_list.h | 4 ++-- options.cpp | 2 +- process.cpp | 2 +- sync_queue.h | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/communicator.cpp b/communicator.cpp index 2df6d76..bb48bd7 100644 --- a/communicator.cpp +++ b/communicator.cpp @@ -31,11 +31,11 @@ communicator::~communicator() msg_task_t task; XBT_DEBUG("send finalize to receiver/ctrl"); - task = MSG_task_create("finalize", 0.0, 0, NULL); + task = MSG_task_create("finalize", 0.0, 0, nullptr); MSG_task_send(task, host->get_ctrl_mbox()); XBT_DEBUG("send finalize to receiver/data"); - task = MSG_task_create("finalize", 0.0, 0, NULL); + task = MSG_task_create("finalize", 0.0, 0, nullptr); MSG_task_send(task, host->get_data_mbox()); receiver_thread->wait(); @@ -76,15 +76,15 @@ void communicator::real_flush(sent_comm_type& sent_comm, bool wait) void communicator::receiver() { - xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL); + xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), nullptr); struct channel { msg_comm_t comm; msg_task_t task; const char* mbox; message_queue& received; }; - channel chan[] = { { NULL, NULL, host->get_ctrl_mbox(), ctrl_received }, - { NULL, NULL, host->get_data_mbox(), data_received } }; + channel chan[] = { { nullptr, nullptr, host->get_ctrl_mbox(), ctrl_received }, + { nullptr, nullptr, host->get_data_mbox(), data_received } }; const int chan_size = (sizeof chan) / (sizeof chan[0]); for (int i = 0 ; i < chan_size ; ++i) { @@ -105,15 +105,15 @@ void communicator::receiver() if (strcmp(MSG_task_get_name(ch->task), "finalize")) { XBT_DEBUG("received message on %s", ch->mbox); ch->received.push(ch->task); - ch->task = NULL; + ch->task = nullptr; ch->comm = MSG_task_irecv(&ch->task, ch->mbox); xbt_dynar_set_as(comms, index, msg_comm_t, ch->comm); } else { XBT_DEBUG("received finalize on %s", ch->mbox); MSG_task_destroy(ch->task); - ch->task = NULL; - ch->comm = NULL; - xbt_dynar_remove_at(comms, index, NULL); + ch->task = nullptr; + ch->comm = nullptr; + xbt_dynar_remove_at(comms, index, nullptr); } } diff --git a/deployment.cpp b/deployment.cpp index 287ca4f..0af3e3b 100644 --- a/deployment.cpp +++ b/deployment.cpp @@ -93,7 +93,7 @@ void deployment_generator::distribute_load() void deployment_generator::deploy() { - xbt_dynar_t args = xbt_dynar_new(sizeof(const char*), NULL); + xbt_dynar_t args = xbt_dynar_new(sizeof(const char*), nullptr); for (unsigned i = 0 ; i < hosts.size() ; ++i) { const char* hostname = hostdata::at(i).get_name(); std::ostringstream oss; diff --git a/main.cpp b/main.cpp index 64fa49f..efeac38 100644 --- a/main.cpp +++ b/main.cpp @@ -181,7 +181,7 @@ static void install_signal_handler() action.sa_handler = signal_handler; sigemptyset(&action.sa_mask); action.sa_flags = SA_RESTART; - if (sigaction(SIGINT, &action, NULL) == -1) { + if (sigaction(SIGINT, &action, nullptr) == -1) { std::cerr << "ERROR: sigaction: " << strerror(errno) << "\n"; exit(EXIT_FAILURE_OTHER); } @@ -294,7 +294,7 @@ int main(int argc, char* argv[]) simulated_time = MSG_get_clock(); XBT_INFO("Simulation ended at %f.", simulated_time); - process::set_proc_mutex(NULL); + process::set_proc_mutex(nullptr); delete proc_cond; delete proc_mutex; diff --git a/msg_thread.cpp b/msg_thread.cpp index 35ee01a..309d573 100644 --- a/msg_thread.cpp +++ b/msg_thread.cpp @@ -8,14 +8,14 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(thrd); msg_thread::msg_thread() : started(false) - , thread(NULL) + , thread(nullptr) , thread_name("msg_thread") { } msg_thread::msg_thread(const char* name) : started(false) - , thread(NULL) + , thread(nullptr) , thread_name(name) { } @@ -61,7 +61,7 @@ int msg_thread::start_wrapper(int, char* []) XBT_DEBUG("terminate \"%s\"", self->thread_name.c_str()); self->mutex.acquire(); - self->thread = NULL; + self->thread = nullptr; self->cond.signal(); self->mutex.release(); return 0; diff --git a/named_object_list.h b/named_object_list.h index 2c691fa..7731a89 100644 --- a/named_object_list.h +++ b/named_object_list.h @@ -65,7 +65,7 @@ public: if (it != assoc.end()) return (*it->second)(); else - return NULL; + return nullptr; } const std::string& get_name(iterator& it) const { return it->first; } @@ -130,7 +130,7 @@ public: if (it != assoc.end()) return (*it->second)(arg1, arg2); else - return NULL; + return nullptr; } const std::string& get_name(iterator& it) const { return it->first; } diff --git a/options.cpp b/options.cpp index 76de43b..006c83a 100644 --- a/options.cpp +++ b/options.cpp @@ -395,7 +395,7 @@ bool opt::parse_args(int* argc, char* argv[]) } if (!opt::auto_depl::random_seed) - opt::auto_depl::random_seed = time(NULL); + opt::auto_depl::random_seed = time(nullptr); return result; } diff --git a/process.cpp b/process.cpp index 76082c5..38cec99 100644 --- a/process.cpp +++ b/process.cpp @@ -249,7 +249,7 @@ void process::compute_loop() idle_duration += MSG_get_clock() - idle_since_date; ++comp_iter; double flops = opt::comp_cost(real_load); - msg_task_t task = MSG_task_create("computation", flops, 0.0, NULL); + msg_task_t task = MSG_task_create("computation", flops, 0.0, nullptr); // MSG_task_set_category(task, TRACE_CAT_COMP); XBT_DEBUG("compute %g flop%s", flops, ESSE(flops)); MSG_task_execute(task); diff --git a/sync_queue.h b/sync_queue.h index d400578..55d2e79 100644 --- a/sync_queue.h +++ b/sync_queue.h @@ -18,7 +18,7 @@ public: ~sync_queue() { node* n = head_node; - while (n != NULL) { + while (n != nullptr) { node* prev = n; n = n->next; delete prev; @@ -84,7 +84,7 @@ public: private: struct node { - node(): next(NULL) { } + node(): next(nullptr) { } T values[SYNC_QUEUE_BUFSIZE]; node* next; }; -- 2.39.5