From d62ee315557076a63312c335a533cd46a27bc8b9 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Wed, 8 Jun 2016 23:20:59 +0200 Subject: [PATCH] [S4U] NULL -> nullptr substitution I used the following command: (the '**' means recursion in ZSH) sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp We check for the underscore to avoid replacing MPI_*_NULL --- src/s4u/s4u_actor.cpp | 8 ++++---- src/s4u/s4u_as.cpp | 6 +++--- src/s4u/s4u_comm.cpp | 16 ++++++++-------- src/s4u/s4u_engine.cpp | 4 ++-- src/s4u/s4u_host.cpp | 8 ++++---- src/s4u/s4u_storage.cpp | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 37302a75d8..2170f7447e 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -24,7 +24,7 @@ s4u::Actor::Actor(const char* name, s4u::Host *host, double killTime, std::funct // instance will get a fresh (reinitialized) state. Is this what we want? this->pimpl_ = simcall_process_create( name, std::move(code), nullptr, host->name().c_str(), - killTime, NULL, 0); + killTime, nullptr, 0); } s4u::Actor::~Actor() {} @@ -59,7 +59,7 @@ double s4u::Actor::getKillTime() { void s4u::Actor::kill(int pid) { msg_process_t process = SIMIX_process_from_PID(pid); - if(process != NULL) { + if(process != nullptr) { simcall_process_kill(process); } else { std::ostringstream oss; @@ -88,12 +88,12 @@ void sleep(double duration) { } e_smx_state_t execute(double flops) { - smx_synchro_t s = simcall_execution_start(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/); + smx_synchro_t s = simcall_execution_start(nullptr,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/); return simcall_execution_wait(s); } void* recv(Mailbox &chan) { - void *res = NULL; + void *res = nullptr; Comm c = Comm::recv_init(chan); c.setDstData(&res,sizeof(res)); c.wait(); diff --git a/src/s4u/s4u_as.cpp b/src/s4u/s4u_as.cpp index b0f760f50e..70338f6dee 100644 --- a/src/s4u/s4u_as.cpp +++ b/src/s4u/s4u_as.cpp @@ -25,7 +25,7 @@ namespace simgrid { } As::~As() { - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; char *key; AS_t elem; xbt_dict_foreach(children_, cursor, key, elem) { @@ -54,12 +54,12 @@ namespace simgrid { xbt_dynar_t As::hosts() { - xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), NULL); + xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr); for (unsigned int index = 0; index < xbt_dynar_length(vertices_); index++) { simgrid::surf::NetCard *card = xbt_dynar_get_as(vertices_, index, simgrid::surf::NetCard*); simgrid::s4u::Host *host = simgrid::s4u::Host::by_name_or_null(card->name()); - if (host!=NULL) + if (host!=nullptr) xbt_dynar_push(res, &host); } return res; diff --git a/src/s4u/s4u_comm.cpp b/src/s4u/s4u_comm.cpp index 93e1c506dc..d27cfb0968 100644 --- a/src/s4u/s4u_comm.cpp +++ b/src/s4u/s4u_comm.cpp @@ -37,7 +37,7 @@ void s4u::Comm::setRate(double rate) { void s4u::Comm::setSrcData(void * buff) { xbt_assert(state_==inited); - xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time"); + xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time"); srcBuff_ = buff; } void s4u::Comm::setSrcDataSize(size_t size){ @@ -47,13 +47,13 @@ void s4u::Comm::setSrcDataSize(size_t size){ void s4u::Comm::setSrcData(void * buff, size_t size) { xbt_assert(state_==inited); - xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time"); + xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time"); srcBuff_ = buff; srcBuffSize_ = size; } void s4u::Comm::setDstData(void ** buff) { xbt_assert(state_==inited); - xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time"); + xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time"); dstBuff_ = buff; } size_t s4u::Comm::getDstDataSize(){ @@ -63,7 +63,7 @@ size_t s4u::Comm::getDstDataSize(){ void s4u::Comm::setDstData(void ** buff, size_t size) { xbt_assert(state_==inited); - xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time"); + xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time"); dstBuff_ = buff; dstBuffSize_ = size; } @@ -71,12 +71,12 @@ void s4u::Comm::setDstData(void ** buff, size_t size) { void s4u::Comm::start() { xbt_assert(state_ == inited); - if (srcBuff_ != NULL) { // Sender side + if (srcBuff_ != nullptr) { // Sender side pimpl_ = simcall_comm_isend(sender_, mailbox_->getInferior(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_, cleanFunction_, copyDataFunction_, userData_, detached_); - } else if (dstBuff_ != NULL) { // Receiver side + } else if (dstBuff_ != nullptr) { // Receiver side pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getInferior(), dstBuff_, &dstBuffSize_, matchFunction_, copyDataFunction_, userData_, rate_); @@ -92,7 +92,7 @@ void s4u::Comm::wait() { if (state_ == started) simcall_comm_wait(pimpl_, -1/*timeout*/); else {// p_state == inited. Save a simcall and do directly a blocking send/recv - if (srcBuff_ != NULL) { + if (srcBuff_ != nullptr) { simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_, copyDataFunction_, @@ -115,7 +115,7 @@ void s4u::Comm::wait(double timeout) { } // It's not started yet. Do it in one simcall - if (srcBuff_ != NULL) { + if (srcBuff_ != nullptr) { simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_, srcBuff_, srcBuffSize_, matchFunction_, copyDataFunction_, diff --git a/src/s4u/s4u_engine.cpp b/src/s4u/s4u_engine.cpp index 1f6a490321..73b3b7c380 100644 --- a/src/s4u/s4u_engine.cpp +++ b/src/s4u/s4u_engine.cpp @@ -82,12 +82,12 @@ static s4u::As *asByNameRecursive(s4u::As *current, const char *name) if(!strcmp(current->name(), name)) return current; - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; char *key; AS_t elem; xbt_dict_foreach(current->children(), cursor, key, elem) { simgrid::s4u::As *tmp = asByNameRecursive(elem, name); - if (tmp != NULL ) + if (tmp != nullptr ) return tmp; } return nullptr; diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 8c70f80b5f..7b9c90bfee 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -63,14 +63,14 @@ Host* Host::by_name_or_create(const char* name) Host* host = by_name_or_null(name); if (host == nullptr) { host = new Host(name); - xbt_dict_set(host_list, name, host, NULL); + xbt_dict_set(host_list, name, host, nullptr); } return host; } Host *Host::current(){ smx_process_t smx_proc = SIMIX_process_self(); - if (smx_proc == NULL) + if (smx_proc == nullptr) xbt_die("Cannot call Host::current() from the maestro context"); return SIMIX_process_get_host(smx_proc); } @@ -92,7 +92,7 @@ int Host::pstatesCount() const { } boost::unordered_map const& Host::mountedStorages() { - if (mounts == NULL) { + if (mounts == nullptr) { mounts = new boost::unordered_map (); xbt_dict_t dict = this->mountedStoragesAsDict(); @@ -117,7 +117,7 @@ xbt_dict_t Host::properties() { }); } -/** Retrieve the property value (or NULL if not set) */ +/** Retrieve the property value (or nullptr if not set) */ const char*Host::property(const char*key) { simgrid::surf::HostImpl* surf_host = this->extension(); return surf_host->getProperty(key); diff --git a/src/s4u/s4u_storage.cpp b/src/s4u/s4u_storage.cpp index afc3401bcc..04c1ee4fbd 100644 --- a/src/s4u/s4u_storage.cpp +++ b/src/s4u/s4u_storage.cpp @@ -28,12 +28,12 @@ smx_storage_t Storage::inferior() { return pimpl_; } Storage &Storage::byName(const char*name) { - s4u::Storage *res = NULL; + s4u::Storage *res = nullptr; try { res = storages_->at(name); } catch (std::out_of_range& e) { smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name); - if (inferior == NULL) + if (inferior == nullptr) xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name); res = new Storage(name,inferior); -- 2.20.1