From 0ce627332c4b8ce2f312cc0bd7ec36e0e637d794 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 2 Oct 2020 22:04:16 +0200 Subject: [PATCH 1/1] Use empty() to check whether the container is empty or not. --- include/xbt/Extendable.hpp | 2 +- src/mc/checker/CommunicationDeterminismChecker.cpp | 2 +- src/simix/smx_global.cpp | 2 +- src/smpi/internals/smpi_global.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/xbt/Extendable.hpp b/include/xbt/Extendable.hpp index d47298dc81..75eeeed6bc 100644 --- a/include/xbt/Extendable.hpp +++ b/include/xbt/Extendable.hpp @@ -48,7 +48,7 @@ template class Extendable { private: static std::vector deleters_; - std::vector extensions_{(deleters_.size() > 0 ? deleters_.size() : 1), nullptr}; + std::vector extensions_{std::max(1, deleters_.size()), nullptr}; public: static size_t extension_create(void (*deleter)(void*)) diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 89f2249a8d..47eb9a20b8 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -106,7 +106,7 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern, comm_pattern->dst_proc = dst_proc->get_pid(); comm_pattern->src_host = MC_smx_actor_get_host_name(src_proc); comm_pattern->dst_host = MC_smx_actor_get_host_name(dst_proc); - if (comm_pattern->data.size() == 0 && comm->src_buff_ != nullptr) { + if (comm_pattern->data.empty() && comm->src_buff_ != nullptr) { size_t buff_size; mc_model_checker->get_remote_simulation().read(&buff_size, remote(comm->dst_buff_size_)); comm_pattern->data.resize(buff_size); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 8ae0f08757..4e90c3d7ac 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -330,7 +330,7 @@ void SIMIX_clean() } #if HAVE_SMPI - if (simix_global->process_list.size() > 0) { + if (not simix_global->process_list.empty()) { if(smpi_process()->initialized()){ xbt_die("Process exited without calling MPI_Finalize - Killing simulation"); }else{ diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index c2ff4c60a6..16826b500f 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -164,7 +164,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v XBT_DEBUG("Copy the data over"); if(smpi_is_shared(buff, src_private_blocks, &src_offset)) { src_private_blocks = shift_and_frame_private_blocks(src_private_blocks, src_offset, buff_size); - if (src_private_blocks.size()==0){//simple shared malloc ... return. + if (src_private_blocks.empty()) { // simple shared malloc ... return. XBT_VERB("Sender is shared. Let's ignore it."); smpi_cleanup_comm_after_copy(comm, buff); return; @@ -176,7 +176,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v } if (smpi_is_shared((char*)comm->dst_buff_, dst_private_blocks, &dst_offset)) { dst_private_blocks = shift_and_frame_private_blocks(dst_private_blocks, dst_offset, buff_size); - if (dst_private_blocks.size()==0){//simple shared malloc ... return. + if (dst_private_blocks.empty()) { // simple shared malloc ... return. XBT_VERB("Receiver is shared. Let's ignore it."); smpi_cleanup_comm_after_copy(comm, buff); return; -- 2.30.2