From a4a0b7a61683f71695edc5b66c554d209311699f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 24 May 2017 00:11:19 +0200 Subject: [PATCH] hunt down some more short negation forms --- examples/s4u/dht-chord/s4u_dht-chord.hpp | 4 +- include/simgrid/kernel/future.hpp | 11 ++---- include/simgrid/s4u/ConditionVariable.hpp | 4 +- include/simgrid/s4u/Host.hpp | 2 +- include/simgrid/simix/blocking_simcall.hpp | 4 +- include/xbt/config.hpp | 4 +- include/xbt/exception.hpp | 4 +- include/xbt/functional.hpp | 4 +- src/instr/instr_interface.cpp | 2 +- src/mc/Process.cpp | 2 +- src/mc/Process.hpp | 6 +-- src/mc/mc_config.cpp | 2 +- src/mc/mc_snapshot.cpp | 2 +- src/mc/remote/RemotePtr.hpp | 2 +- .../allgather-ompi-neighborexchange.cpp | 2 +- src/smpi/colls/coll_tuned_topo.cpp | 2 +- src/smpi/colls/scatter/scatter-ompi.cpp | 4 +- src/smpi/colls/smpi_mvapich2_selector.cpp | 10 ++--- src/smpi/smpi_datatype.cpp | 16 +++----- src/smpi/smpi_datatype_derived.cpp | 38 +++++++++---------- src/smpi/smpi_keyvals.hpp | 2 +- src/smpi/smpi_op.cpp | 2 +- src/smpi/smpi_request.cpp | 21 +++++----- src/smpi/smpi_win.cpp | 6 +-- src/surf/fair_bottleneck.cpp | 2 +- src/surf/lagrange.cpp | 2 +- src/surf/maxmin.cpp | 14 +++---- src/surf/network_cm02.cpp | 2 +- src/surf/trace_mgr.hpp | 2 +- src/xbt/dict.cpp | 8 ++-- src/xbt/ex.cpp | 2 +- 31 files changed, 84 insertions(+), 104 deletions(-) diff --git a/examples/s4u/dht-chord/s4u_dht-chord.hpp b/examples/s4u/dht-chord/s4u_dht-chord.hpp index 7b64d2c801..c3a3a53f31 100644 --- a/examples/s4u/dht-chord/s4u_dht-chord.hpp +++ b/examples/s4u/dht-chord/s4u_dht-chord.hpp @@ -118,7 +118,7 @@ public: join(known_id_); } - if (!joined) + if (not joined) return; ChordMessage* message = nullptr; void* data = nullptr; @@ -131,7 +131,7 @@ public: while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME) { data = nullptr; simgrid::s4u::Comm& comm_receive = simgrid::s4u::this_actor::irecv(mailbox_, &data); - while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME && !comm_receive.test()) { + while ((now < (start_time_ + deadline_)) && now < MAX_SIMULATION_TIME && not comm_receive.test()) { // no task was received: make some periodic calls if (now >= next_stabilize_date) { stabilize(); diff --git a/include/simgrid/kernel/future.hpp b/include/simgrid/kernel/future.hpp index da5bd080f5..8f0c25d488 100644 --- a/include/simgrid/kernel/future.hpp +++ b/include/simgrid/kernel/future.hpp @@ -61,7 +61,7 @@ public: void set_continuation(simgrid::xbt::Task&& continuation) { - xbt_assert(!continuation_); + xbt_assert(not continuation_); switch (status_) { case FutureStatus::done: // This is not supposed to happen if continuation is set @@ -369,12 +369,9 @@ public: * the future is ready * @exception std::future_error no state is associated with the future */ - template - auto then(F continuation) - -> typename std::enable_if< - !is_future::value, - Future - >::type + template + auto then(F continuation) -> typename std::enable_if::value, + Future>::type { return this->thenNoUnwrap(std::move(continuation)); } diff --git a/include/simgrid/s4u/ConditionVariable.hpp b/include/simgrid/s4u/ConditionVariable.hpp index c087a0e5ef..b1e2be3e85 100644 --- a/include/simgrid/s4u/ConditionVariable.hpp +++ b/include/simgrid/s4u/ConditionVariable.hpp @@ -52,7 +52,7 @@ public: void wait(std::unique_lock & lock); template void wait(std::unique_lock & lock, P pred) { - while (!pred()) + while (not pred()) wait(lock); } @@ -62,7 +62,7 @@ public: std::cv_status wait_for(std::unique_lock & lock, double duration); template bool wait_until(std::unique_lock & lock, double timeout_time, P pred) { - while (!pred()) + while (not pred()) if (this->wait_until(lock, timeout_time) == std::cv_status::timeout) return pred(); return true; diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 999098f3eb..665f2c85fe 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -83,7 +83,7 @@ public: /** Returns if that host is currently up and running */ bool isOn(); /** Returns if that host is currently down and offline */ - bool isOff() { return !isOn(); } + bool isOff() { return not isOn(); } double speed(); int coreCount(); diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index 6341521a42..88e522c69c 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -87,7 +87,7 @@ public: bool valid() const { return future_.valid(); } T get() { - if (!valid()) + if (not valid()) throw std::future_error(std::future_errc::no_state); smx_actor_t self = SIMIX_process_self(); simgrid::xbt::Result result; @@ -109,7 +109,7 @@ public: } bool is_ready() const { - if (!valid()) + if (not valid()) throw std::future_error(std::future_errc::no_state); return future_.is_ready(); } diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 4e0e22221f..f5b3c95222 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -168,8 +168,8 @@ typename std::enable_if class WithContext : public E, public WithContextException { public: - - static_assert(!std::is_base_of::value, - "Trying to appli WithContext twice"); + static_assert(not std::is_base_of::value, "Trying to appli WithContext twice"); WithContext(E exception) : E(std::move(exception)) {} diff --git a/include/xbt/functional.hpp b/include/xbt/functional.hpp index 10c16bf98a..b93f958fd2 100644 --- a/include/xbt/functional.hpp +++ b/include/xbt/functional.hpp @@ -232,9 +232,7 @@ private: vtable_ = &vtable; } - template - typename std::enable_if()>::type - init(F code) + template typename std::enable_if()>::type init(F code) { const static TaskVtable vtable { // Call: diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index dbefe457ee..79dc5d33dc 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -84,7 +84,7 @@ void TRACE_category_with_color (const char *category, const char *color) if (not TRACE_is_enabled() || not TRACE_needs_platform()) return; - if (!(TRACE_categorized() && category != nullptr)) + if (not(TRACE_categorized() && category != nullptr)) return; //check if category is already created diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index 4e5090a916..26447a3dc2 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -335,7 +335,7 @@ void Process::init_memory_map_info() continue; current_name = pathname; - if (!(reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)) + if (not(reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)) continue; const bool is_executable = not i; diff --git a/src/mc/Process.hpp b/src/mc/Process.hpp index 16e481f104..68ebb05f0f 100644 --- a/src/mc/Process.hpp +++ b/src/mc/Process.hpp @@ -143,13 +143,13 @@ public: // Heap access: xbt_mheap_t get_heap() { - if (!(this->cache_flags_ & Process::cache_heap)) + if (not(this->cache_flags_ & Process::cache_heap)) this->refresh_heap(); return this->heap.get(); } const malloc_info* get_malloc_info() { - if (!(this->cache_flags_ & Process::cache_malloc)) + if (not(this->cache_flags_ & Process::cache_malloc)) this->refresh_malloc_info(); return this->heap_info.data(); } @@ -226,7 +226,7 @@ public: simgrid::mc::ActorInformation* resolveActorInfo(simgrid::mc::RemotePtr actor) { xbt_assert(mc_model_checker != nullptr); - if (!actor) + if (not actor) return nullptr; this->refresh_simix(); for (auto& actor_info : this->smx_actors_infos) diff --git a/src/mc/mc_config.cpp b/src/mc/mc_config.cpp index a288a173d0..5f7ed7b996 100644 --- a/src/mc/mc_config.cpp +++ b/src/mc/mc_config.cpp @@ -40,7 +40,7 @@ int _sg_mc_timeout = 0; void _mc_cfg_cb_timeout(const char *name) { - if (_sg_cfg_init_status && !(_sg_do_model_check || MC_record_path)) + if (_sg_cfg_init_status && not(_sg_do_model_check || MC_record_path)) xbt_die("You are specifying a value to enable/disable timeout for wait requests after the initialization (through MSG_config?), but model-checking was not activated at config time (through bu the program was not runned under the model-checker (with simgrid-mc)). This won't work, sorry."); _sg_mc_timeout = xbt_cfg_get_boolean(name); diff --git a/src/mc/mc_snapshot.cpp b/src/mc/mc_snapshot.cpp index 784f672265..32f035bf9c 100644 --- a/src/mc/mc_snapshot.cpp +++ b/src/mc/mc_snapshot.cpp @@ -35,7 +35,7 @@ mc_mem_region_t mc_get_snapshot_region( size_t n = snapshot->snapshot_regions.size(); for (size_t i = 0; i != n; ++i) { mc_mem_region_t region = snapshot->snapshot_regions[i].get(); - if (!(region && region->contain(simgrid::mc::remote(addr)))) + if (not(region && region->contain(simgrid::mc::remote(addr)))) continue; if (region->storage_type() == simgrid::mc::StorageType::Privatized) { diff --git a/src/mc/remote/RemotePtr.hpp b/src/mc/remote/RemotePtr.hpp index 88effca9f9..951b60c7c1 100644 --- a/src/mc/remote/RemotePtr.hpp +++ b/src/mc/remote/RemotePtr.hpp @@ -89,7 +89,7 @@ public: T* local() const { return (T*)address_; } operator bool() const { return address_; } - bool operator!() const { return !address_; } + bool operator!() const { return not address_; } operator RemotePtr() const { return RemotePtr(address_); } RemotePtr operator+(std::uint64_t n) const { return RemotePtr(address_ + n * sizeof(T)); } RemotePtr operator-(std::uint64_t n) const { return RemotePtr(address_ - n * sizeof(T)); } diff --git a/src/smpi/colls/allgather/allgather-ompi-neighborexchange.cpp b/src/smpi/colls/allgather/allgather-ompi-neighborexchange.cpp index 8f4d2a9473..cb350c6df9 100644 --- a/src/smpi/colls/allgather/allgather-ompi-neighborexchange.cpp +++ b/src/smpi/colls/allgather/allgather-ompi-neighborexchange.cpp @@ -115,7 +115,7 @@ Coll_allgather_ompi_neighborexchange::allgather(void *sbuf, int scount, } /* Determine neighbors, order in which blocks will arrive, etc. */ - even_rank = !(rank % 2); + even_rank = not(rank % 2); if (even_rank) { neighbor[0] = (rank + 1) % size; neighbor[1] = (rank - 1 + size) % size; diff --git a/src/smpi/colls/coll_tuned_topo.cpp b/src/smpi/colls/coll_tuned_topo.cpp index 4f128a57eb..f90e726f07 100644 --- a/src/smpi/colls/coll_tuned_topo.cpp +++ b/src/smpi/colls/coll_tuned_topo.cpp @@ -295,7 +295,7 @@ int ompi_coll_tuned_topo_destroy_tree( ompi_coll_tree_t** tree ) { ompi_coll_tree_t *ptr; - if ((not tree) || (!*tree)) { + if ((tree == nullptr) || (*tree == nullptr)) { return MPI_SUCCESS; } diff --git a/src/smpi/colls/scatter/scatter-ompi.cpp b/src/smpi/colls/scatter/scatter-ompi.cpp index 6a622b38e6..9d14907810 100644 --- a/src/smpi/colls/scatter/scatter-ompi.cpp +++ b/src/smpi/colls/scatter/scatter-ompi.cpp @@ -109,7 +109,7 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt } } total_send = scount; - } else if (!(vrank % 2)) { + } else if (not(vrank % 2)) { /* non-root, non-leaf nodes, allocate temp buffer for recv * the most we need is rcount*size/2 */ tempbuf = (char*)smpi_get_tmp_recvbuffer(rtrue_extent + (rcount * size - 1) * rextent); @@ -130,7 +130,7 @@ int Coll_scatter_ompi_binomial::scatter(void* sbuf, int scount, MPI_Datatype sdt ptmp = (char*)rbuf; } - if (!(vrank % 2)) { + if (not(vrank % 2)) { if (rank != root) { /* recv from parent on non-root */ Request::recv(ptmp, rcount * size, rdtype, bmtree->tree_prev, COLL_TAG_SCATTER, comm, &status); diff --git a/src/smpi/colls/smpi_mvapich2_selector.cpp b/src/smpi/colls/smpi_mvapich2_selector.cpp index 8be7648592..99290fb14a 100644 --- a/src/smpi/colls/smpi_mvapich2_selector.cpp +++ b/src/smpi/colls/smpi_mvapich2_selector.cpp @@ -304,13 +304,9 @@ int Coll_allgatherv_mvapich2::allgatherv(void *sendbuf, int sendcount, MPI_Datat if (MV2_Allgatherv_function == &MPIR_Allgatherv_Rec_Doubling_MV2) { - if(!(comm_size & (comm_size - 1))) - { - mpi_errno = - MPIR_Allgatherv_Rec_Doubling_MV2(sendbuf, sendcount, - sendtype, recvbuf, - recvcounts, displs, - recvtype, comm); + if (not(comm_size & (comm_size - 1))) { + mpi_errno = + MPIR_Allgatherv_Rec_Doubling_MV2(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm); } else { mpi_errno = MPIR_Allgatherv_Bruck_MV2(sendbuf, sendcount, diff --git a/src/smpi/smpi_datatype.cpp b/src/smpi/smpi_datatype.cpp index 00eb0433cb..b5ea2341c3 100644 --- a/src/smpi/smpi_datatype.cpp +++ b/src/smpi/smpi_datatype.cpp @@ -121,8 +121,8 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype- *ret = MPI_SUCCESS; if(datatype->name_) name_ = xbt_strdup(datatype->name_); - - if(!(datatype->attributes()->empty())){ + + if (not datatype->attributes()->empty()) { int flag; void* value_out; for(auto it = datatype->attributes()->begin(); it != datatype->attributes()->end(); it++){ @@ -175,7 +175,7 @@ void Datatype::unref(MPI_Datatype datatype) if (datatype->refcount_ > 0) datatype->refcount_--; - if (datatype->refcount_ == 0 && !(datatype->flags_ & DT_FLAG_PREDEFINED)) + if (datatype->refcount_ == 0 && not(datatype->flags_ & DT_FLAG_PREDEFINED)) delete datatype; #if SIMGRID_HAVE_MC @@ -276,16 +276,12 @@ int Datatype::copy(void *sendbuf, int sendcount, MPI_Datatype sendtype, recvcount *= recvtype->size(); count = sendcount < recvcount ? sendcount : recvcount; - if(!(sendtype->flags() & DT_FLAG_DERIVED) && !(recvtype->flags() & DT_FLAG_DERIVED)) { + if (not(sendtype->flags() & DT_FLAG_DERIVED) && not(recvtype->flags() & DT_FLAG_DERIVED)) { if (not smpi_process()->replaying()) memcpy(recvbuf, sendbuf, count); - } - else if (!(sendtype->flags() & DT_FLAG_DERIVED)) - { + } else if (not(sendtype->flags() & DT_FLAG_DERIVED)) { recvtype->unserialize( sendbuf, recvbuf, recvcount/recvtype->size(), MPI_REPLACE); - } - else if (!(recvtype->flags() & DT_FLAG_DERIVED)) - { + } else if (not(recvtype->flags() & DT_FLAG_DERIVED)) { sendtype->serialize(sendbuf, recvbuf, sendcount/sendtype->size()); }else{ diff --git a/src/smpi/smpi_datatype_derived.cpp b/src/smpi/smpi_datatype_derived.cpp index cc008857ef..afc16cae5f 100644 --- a/src/smpi/smpi_datatype_derived.cpp +++ b/src/smpi/smpi_datatype_derived.cpp @@ -49,15 +49,14 @@ Type_Vector::~Type_Vector(){ void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf, int count){ - int i; char* contiguous_buf_char = static_cast(contiguous_buf); char* noncontiguous_buf_char = static_cast(noncontiguous_buf); - for (i = 0; i < block_count_ * count; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)) - memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size()); - else - old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char, block_length_); + for (int i = 0; i < block_count_ * count; i++) { + if (not(old_type_->flags() & DT_FLAG_DERIVED)) + memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size()); + else + old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char, block_length_); contiguous_buf_char += block_length_*old_type_->size(); if((i+1)%block_count_ ==0) @@ -69,12 +68,11 @@ void Type_Vector::serialize( void* noncontiguous_buf, void *contiguous_buf, void Type_Vector::unserialize( void* contiguous_buf, void *noncontiguous_buf, int count, MPI_Op op){ - int i; char* contiguous_buf_char = static_cast(contiguous_buf); char* noncontiguous_buf_char = static_cast(noncontiguous_buf); - for (i = 0; i < block_count_ * count; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)){ + for (int i = 0; i < block_count_ * count; i++) { + if (not(old_type_->flags() & DT_FLAG_DERIVED)) { if(op != MPI_OP_NULL) op->apply(contiguous_buf_char, noncontiguous_buf_char, &block_length_, old_type_); @@ -98,12 +96,11 @@ Type_Hvector::~Type_Hvector(){ void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf, int count){ - int i; char* contiguous_buf_char = static_cast(contiguous_buf); char* noncontiguous_buf_char = static_cast(noncontiguous_buf); - for (i = 0; i < block_count_ * count; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)) + for (int i = 0; i < block_count_ * count; i++) { + if (not(old_type_->flags() & DT_FLAG_DERIVED)) memcpy(contiguous_buf_char, noncontiguous_buf_char, block_length_ * old_type_->size()); else old_type_->serialize( noncontiguous_buf_char, contiguous_buf_char, block_length_); @@ -119,12 +116,11 @@ void Type_Hvector::serialize( void* noncontiguous_buf, void *contiguous_buf, void Type_Hvector::unserialize( void* contiguous_buf, void *noncontiguous_buf, int count, MPI_Op op){ - int i; char* contiguous_buf_char = static_cast(contiguous_buf); char* noncontiguous_buf_char = static_cast(noncontiguous_buf); - for (i = 0; i < block_count_ * count; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)){ + for (int i = 0; i < block_count_ * count; i++) { + if (not(old_type_->flags() & DT_FLAG_DERIVED)) { if(op!=MPI_OP_NULL) op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_length_, old_type_); }else @@ -162,7 +158,7 @@ void Type_Indexed::serialize( void* noncontiguous_buf, void *contiguous_buf, char* noncontiguous_buf_char = static_cast(noncontiguous_buf)+block_indices_[0] * old_type_->size(); for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)) + if (not(old_type_->flags() & DT_FLAG_DERIVED)) memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_type_->size()); else old_type_->serialize( noncontiguous_buf_char, contiguous_buf_char, block_lengths_[i]); @@ -186,7 +182,7 @@ void Type_Indexed::unserialize( void* contiguous_buf, void *noncontiguous_buf, static_cast(noncontiguous_buf)+block_indices_[0]*old_type_->get_extent(); for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)){ + if (not(old_type_->flags() & DT_FLAG_DERIVED)) { if(op!=MPI_OP_NULL) op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i], old_type_); @@ -230,7 +226,7 @@ void Type_Hindexed::serialize( void* noncontiguous_buf, void *contiguous_buf, char* noncontiguous_buf_char = static_cast(noncontiguous_buf)+ block_indices_[0]; for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)) + if (not(old_type_->flags() & DT_FLAG_DERIVED)) memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_type_->size()); else old_type_->serialize(noncontiguous_buf_char, contiguous_buf_char,block_lengths_[i]); @@ -251,7 +247,7 @@ void Type_Hindexed::unserialize( void* contiguous_buf, void *noncontiguous_buf, char* noncontiguous_buf_char = static_cast(noncontiguous_buf)+ block_indices_[0]; for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_type_->flags() & DT_FLAG_DERIVED)){ + if (not(old_type_->flags() & DT_FLAG_DERIVED)) { if(op!=MPI_OP_NULL) op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i], old_type_); @@ -298,7 +294,7 @@ void Type_Struct::serialize( void* noncontiguous_buf, void *contiguous_buf, char* noncontiguous_buf_char = static_cast(noncontiguous_buf)+ block_indices_[0]; for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_types_[i]->flags() & DT_FLAG_DERIVED)) + if (not(old_types_[i]->flags() & DT_FLAG_DERIVED)) memcpy(contiguous_buf_char, noncontiguous_buf_char, block_lengths_[i] * old_types_[i]->size()); else old_types_[i]->serialize( noncontiguous_buf_char,contiguous_buf_char,block_lengths_[i]); @@ -320,7 +316,7 @@ void Type_Struct::unserialize( void* contiguous_buf, void *noncontiguous_buf, char* noncontiguous_buf_char = static_cast(noncontiguous_buf)+ block_indices_[0]; for (int j = 0; j < count; j++) { for (int i = 0; i < block_count_; i++) { - if (!(old_types_[i]->flags() & DT_FLAG_DERIVED)){ + if (not(old_types_[i]->flags() & DT_FLAG_DERIVED)) { if(op!=MPI_OP_NULL) op->apply( contiguous_buf_char, noncontiguous_buf_char, &block_lengths_[i], old_types_[i]); }else diff --git a/src/smpi/smpi_keyvals.hpp b/src/smpi/smpi_keyvals.hpp index 92f3384df0..52ad77ee45 100644 --- a/src/smpi/smpi_keyvals.hpp +++ b/src/smpi/smpi_keyvals.hpp @@ -137,7 +137,7 @@ template int Keyval::attr_put(int keyval, void* attr_value){ } template void Keyval::cleanup_attr(){ - if(!attributes()->empty()){ + if (not attributes()->empty()) { int flag=0; for(auto it : attributes_){ try{ diff --git a/src/smpi/smpi_op.cpp b/src/smpi/smpi_op.cpp index 5023a2e991..35b0a73744 100644 --- a/src/smpi/smpi_op.cpp +++ b/src/smpi/smpi_op.cpp @@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_op, smpi, "Logging specific to SMPI (op)"); #define PROD_OP(a, b) (b) *= (a) #define LAND_OP(a, b) (b) = (a) && (b) #define LOR_OP(a, b) (b) = (a) || (b) -#define LXOR_OP(a, b) (b) = (!(a) && (b)) || ((a) && !(b)) +#define LXOR_OP(a, b) (b) = (not(a) && (b)) || ((a) && not(b)) #define BAND_OP(a, b) (b) &= (a) #define BOR_OP(a, b) (b) |= (a) #define BXOR_OP(a, b) (b) ^= (a) diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index 0126847da4..ac052b4f99 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -395,7 +395,7 @@ void Request::start() detached_ = 1; XBT_DEBUG("Send request %p is detached", this); refcount_++; - if(!(old_type_->flags() & DT_FLAG_DERIVED)){ + if (not(old_type_->flags() & DT_FLAG_DERIVED)) { oldbuf = buf_; if (not process->replaying() && oldbuf != nullptr && size_ != 0) { if((smpi_privatize_global_variables != 0) @@ -432,7 +432,7 @@ void Request::start() if (async_small_thresh != 0 || (flags_ & RMA) != 0) xbt_mutex_acquire(mut); - if (!(async_small_thresh != 0 || (flags_ & RMA) !=0)) { + if (not(async_small_thresh != 0 || (flags_ & RMA) != 0)) { mailbox = process->mailbox(); } else if (((flags_ & RMA) != 0) || static_cast(size_) < async_small_thresh) { // eager mode mailbox = process->mailbox(); @@ -553,9 +553,9 @@ int Request::testany(int count, MPI_Request requests[], int *index, MPI_Status * std::vector map; /** Maps all matching comms back to their location in requests **/ for(i = 0; i < count; i++) { - if ((requests[i] != MPI_REQUEST_NULL) && requests[i]->action_ && !(requests[i]->flags_ & PREPARED)) { - comms.push_back(requests[i]->action_); - map.push_back(i); + if ((requests[i] != MPI_REQUEST_NULL) && requests[i]->action_ && not(requests[i]->flags_ & PREPARED)) { + comms.push_back(requests[i]->action_); + map.push_back(i); } } if (not map.empty()) { @@ -591,7 +591,7 @@ int Request::testall(int count, MPI_Request requests[], MPI_Status status[]) MPI_Status *pstat = status == MPI_STATUSES_IGNORE ? MPI_STATUS_IGNORE : &stat; int flag=1; for(int i=0; iflags_ & PREPARED)) { + if (requests[i] != MPI_REQUEST_NULL && not(requests[i]->flags_ & PREPARED)) { if (test(&requests[i], pstat)!=1){ flag=0; }else{ @@ -675,7 +675,7 @@ void Request::finish_wait(MPI_Request* request, MPI_Status * status) MPI_Request req = *request; Status::empty(status); - if(!((req->detached_ != 0) && ((req->flags_ & SEND) != 0)) && ((req->flags_ & PREPARED) == 0)){ + if (not((req->detached_ != 0) && ((req->flags_ & SEND) != 0)) && ((req->flags_ & PREPARED) == 0)) { if(status != MPI_STATUS_IGNORE) { int src = req->src_ == MPI_ANY_SOURCE ? req->real_src_ : req->src_; status->MPI_SOURCE = req->comm_->group()->rank(src); @@ -766,7 +766,8 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status) map = xbt_new(int, count); XBT_DEBUG("Wait for one of %d", count); for(i = 0; i < count; i++) { - if (requests[i] != MPI_REQUEST_NULL && !(requests[i]->flags_ & PREPARED) && !(requests[i]->flags_ & FINISHED)) { + if (requests[i] != MPI_REQUEST_NULL && not(requests[i]->flags_ & PREPARED) && + not(requests[i]->flags_ & FINISHED)) { if (requests[i]->action_ != nullptr) { XBT_DEBUG("Waiting any %p ", requests[i]); xbt_dynar_push(&comms, &requests[i]->action_); @@ -790,8 +791,8 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status) if (i != -1) { index = map[i]; //in case of an accumulate, we have to wait the end of all requests to apply the operation, ordered correctly. - if ((requests[index] == MPI_REQUEST_NULL) - || (!((requests[index]->flags_ & ACCUMULATE) && (requests[index]->flags_ & RECV)))){ + if ((requests[index] == MPI_REQUEST_NULL) || + (not((requests[index]->flags_ & ACCUMULATE) && (requests[index]->flags_ & RECV)))) { finish_wait(&requests[index],status); if (requests[i] != MPI_REQUEST_NULL && (requests[i]->flags_ & NON_PERSISTENT)) requests[index] = MPI_REQUEST_NULL; diff --git a/src/smpi/smpi_win.cpp b/src/smpi/smpi_win.cpp index 0240e939d7..6ac1654daa 100644 --- a/src/smpi/smpi_win.cpp +++ b/src/smpi/smpi_win.cpp @@ -84,7 +84,7 @@ Win::~Win(){ } int Win::attach (void *base, MPI_Aint size){ - if (!(base_ == MPI_BOTTOM || base_ == 0)) + if (not(base_ == MPI_BOTTOM || base_ == 0)) return MPI_ERR_ARG; base_=0;//actually the address will be given in the RMA calls, as being the disp. size_+=size; @@ -573,8 +573,8 @@ int Win::lock(int lock_type, int rank, int assert){ if(lock_type == MPI_LOCK_SHARED){//the window used to be exclusive, it's now shared. xbt_mutex_release(target_win->lock_mut_); } - } else if(!(target_win->mode_==MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE)) - target_win->mode_+= lock_type; // don't set to exclusive if it's already shared + } else if (not(target_win->mode_ == MPI_LOCK_SHARED && lock_type == MPI_LOCK_EXCLUSIVE)) + target_win->mode_ += lock_type; // don't set to exclusive if it's already shared target_win->lockers_.push_back(comm_->rank()); diff --git a/src/surf/fair_bottleneck.cpp b/src/surf/fair_bottleneck.cpp index 3555498619..1b2582bdcc 100644 --- a/src/surf/fair_bottleneck.cpp +++ b/src/surf/fair_bottleneck.cpp @@ -33,7 +33,7 @@ void bottleneck_solve(lmm_system_t sys) static s_xbt_swag_t cnst_to_update; - if (!(sys->modified)) + if (not sys->modified) return; /* Init */ diff --git a/src/surf/lagrange.cpp b/src/surf/lagrange.cpp index edc5cd4aa9..e82b60f5d7 100644 --- a/src/surf/lagrange.cpp +++ b/src/surf/lagrange.cpp @@ -182,7 +182,7 @@ void lagrange_solve(lmm_system_t sys) lmm_print(sys); } - if (!(sys->modified)) + if (not sys->modified) return; /* Initialize lambda. */ diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index f92f6e85d6..610e64aa8e 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -514,18 +514,18 @@ int lmm_get_number_of_cnst_from_var(lmm_system_t /*sys*/, lmm_variable_t var) lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem) { - if (!(*elem)) { + if (*elem == nullptr) { // That is the first call, pick the first element among enabled_element_set (or disabled_element_set if // enabled_element_set is empty) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set)); - if (!(*elem)) + if (*elem == nullptr) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); } else { //elem is not null, so we carry on if(xbt_swag_belongs(*elem,&(cnst->enabled_element_set))){ //Look at enabled_element_set, and jump to disabled_element_set when finished *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset); - if (!(*elem)) + if (*elem == nullptr) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); } else { *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset); @@ -542,10 +542,10 @@ lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, lmm_constraint_t cnst lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem, lmm_element_t * nextelem, int * numelem) { - if (!(*elem)){ + if (*elem == nullptr) { *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set)); *numelem = xbt_swag_size(&(cnst->enabled_element_set))+xbt_swag_size(&(cnst->disabled_element_set))-1; - if (!(*elem)) + if (*elem == nullptr) *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); }else{ *elem = *nextelem; @@ -559,7 +559,7 @@ lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, lmm_constraint_t if(xbt_swag_belongs(*elem,&(cnst->enabled_element_set))){ //Look at enabled_element_set, and jump to disabled_element_set when finished *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset); - if (!(*nextelem)) + if (*nextelem == nullptr) *nextelem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set)); } else { *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset); @@ -716,7 +716,7 @@ void lmm_solve(lmm_system_t sys) double min_usage = -1; double min_bound = -1; - if (!(sys->modified)) + if (not sys->modified) return; XBT_IN("(sys=%p)", sys); diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 7d3aa5ad87..1f204a778d 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -234,7 +234,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) double_update(&(deltap), action->latency_, sg_surf_precision); action->latency_ = 0.0; } - if (action->latency_ <= 0.0 && !(action->isSuspended())) + if (action->latency_ <= 0.0 && not action->isSuspended()) lmm_update_variable_weight(maxminSystem_, action->getVariable(), action->weight_); } if (TRACE_is_enabled()) { diff --git a/src/surf/trace_mgr.hpp b/src/surf/trace_mgr.hpp index de50cacd6f..d78d4de20d 100644 --- a/src/surf/trace_mgr.hpp +++ b/src/surf/trace_mgr.hpp @@ -59,7 +59,7 @@ public: explicit DatedValue() = default; explicit DatedValue(double d, double v) : date_(d), value_(v) {} bool operator==(DatedValue e2); - bool operator!=(DatedValue e2) { return !(*this == e2); } + bool operator!=(DatedValue e2) { return not(*this == e2); } }; std::ostream& operator<<(std::ostream& out, const DatedValue& e); diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 8dadf6bba8..f5759cf390 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -119,7 +119,7 @@ static void xbt_dict_rehash(xbt_dict_t dict) XBT_DEBUG("REHASH (%d->%d)", oldsize, newsize); for (unsigned i = 0; i < oldsize; i++, currcell++) { - if (!*currcell) /* empty cell */ + if (*currcell == nullptr) /* empty cell */ continue; xbt_dictelm_t *twincell = currcell + oldsize; @@ -132,7 +132,7 @@ static void xbt_dict_rehash(xbt_dict_t dict) if ((bucklet->hash_code & newsize) != i) { /* Move to b */ *pprev = bucklet->next; bucklet->next = *twincell; - if (!*twincell) + if (*twincell == nullptr) dict->fill++; *twincell = bucklet; } else { @@ -140,7 +140,7 @@ static void xbt_dict_rehash(xbt_dict_t dict) } } - if (!*currcell) /* everything moved */ + if (*currcell == nullptr) /* everything moved */ dict->fill--; } } @@ -938,7 +938,6 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test") xbt_dict_t head = xbt_dict_new_homogeneous(&free); xbt_test_add("Fill %d elements, with keys being the number of element", NB_ELM); for (int j = 0; j < NB_ELM; j++) { - /* if (!(j%1000)) { printf("."); fflush(stdout); } */ char* key = (char*)xbt_malloc(10); snprintf(key,10, "%d", j); @@ -966,7 +965,6 @@ XBT_TEST_UNIT("crash", test_dict_crash, "Crash test") xbt_test_add("Remove my %d elements", NB_ELM); key = (char*) xbt_malloc(10); for (int j = 0; j < NB_ELM; j++) { - /* if (!(j%10000)) printf("."); fflush(stdout); */ snprintf(key,10, "%d", j); xbt_dict_remove(head, key); } diff --git a/src/xbt/ex.cpp b/src/xbt/ex.cpp index 37f1c257f4..9115b407e0 100644 --- a/src/xbt/ex.cpp +++ b/src/xbt/ex.cpp @@ -227,7 +227,7 @@ XBT_TEST_UNIT("cleanup", test_cleanup, "cleanup handling") c = 1; if (v1 != 5678) xbt_test_fail("v1 = %d (!= 5678)", v1); - if (!(ex.category == 1 && ex.value == 2 && not strcmp(ex.what(), "blah"))) + if (not(ex.category == 1 && ex.value == 2 && not strcmp(ex.what(), "blah"))) xbt_test_fail("unexpected exception contents"); } if (not c) -- 2.20.1