From 8cd1ef6275c48c8985e297ba1e484cbb85ba6126 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 3 Jul 2020 11:50:55 +0200 Subject: [PATCH] [sonar] Declare functions "const" (round #2). --- include/simgrid/plugins/file_system.h | 2 +- include/simgrid/s4u/Actor.hpp | 4 ++-- include/simgrid/s4u/Engine.hpp | 2 +- src/kernel/actor/ActorImpl.cpp | 2 +- src/kernel/actor/ActorImpl.hpp | 2 +- src/mc/remote/AppSide.cpp | 4 ++-- src/mc/remote/AppSide.hpp | 4 ++-- src/plugins/file_system/s4u_FileSystem.cpp | 2 +- src/s4u/s4u_Actor.cpp | 4 ++-- src/s4u/s4u_Engine.cpp | 2 +- src/smpi/include/smpi_comm.hpp | 2 +- src/smpi/include/smpi_win.hpp | 2 +- src/smpi/mpi/smpi_comm.cpp | 3 ++- src/smpi/mpi/smpi_win.cpp | 2 +- 14 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/simgrid/plugins/file_system.h b/include/simgrid/plugins/file_system.h index fcc4f99408..7b9c7a55cd 100644 --- a/include/simgrid/plugins/file_system.h +++ b/include/simgrid/plugins/file_system.h @@ -146,7 +146,7 @@ public: int remote_move(sg_host_t host, const char* fullpath); int unlink() const; /** Remove a file from the contents of a disk */ - void dump(); + void dump() const; }; class XBT_PUBLIC FileSystemDiskExt { diff --git a/include/simgrid/s4u/Actor.hpp b/include/simgrid/s4u/Actor.hpp index 235476048b..c664c030a0 100644 --- a/include/simgrid/s4u/Actor.hpp +++ b/include/simgrid/s4u/Actor.hpp @@ -63,7 +63,7 @@ public: friend XBT_PUBLIC void intrusive_ptr_release(const Actor* actor); #endif /** Retrieve the amount of references on that object. Useful to debug the automatic refcounting */ - int get_refcount(); + int get_refcount() const; // ***** Actor creation ***** /** Retrieve a reference to myself */ @@ -157,7 +157,7 @@ public: void resume(); /** Returns true if the actor is suspended. */ - bool is_suspended(); + bool is_suspended() const; /** If set to true, the actor will automatically restart when its host reboots */ void set_auto_restart(bool autorestart); diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 8903b10b20..249000775f 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -80,7 +80,7 @@ public: register_function(name, std::move(code_factory)); } - void load_deployment(const std::string& deploy); + void load_deployment(const std::string& deploy) const; protected: #ifndef DOXYGEN diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 1c9d773b31..6e0b52a988 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -270,7 +270,7 @@ void ActorImpl::set_kill_time(double kill_time) }); } -double ActorImpl::get_kill_time() +double ActorImpl::get_kill_time() const { return kill_timer_ ? kill_timer_->get_date() : 0; } diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index 17b8042634..181e0195e6 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -37,7 +37,7 @@ public: ~ActorImpl(); static ActorImpl* self(); - double get_kill_time(); + double get_kill_time() const; void set_kill_time(double kill_time); boost::intrusive::list_member_hook<> host_actor_list_hook; /* simgrid::simix::Host::process_list */ boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->actors_to_destroy */ diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index 486a9c79fd..907f73c0a6 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -106,7 +106,7 @@ void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) cons xbt_assert(received_size == sizeof(_type_), "Unexpected size for " _name_ " (%zd != %zu)", received_size, \ sizeof(_type_)) -void AppSide::handle_messages() +void AppSide::handle_messages() const { while (true) { XBT_DEBUG("Waiting messages from model-checker"); @@ -154,7 +154,7 @@ void AppSide::main_loop() } } -void AppSide::report_assertion_failure() +void AppSide::report_assertion_failure() const { if (channel_.send(MC_MESSAGE_ASSERTION_FAILED)) xbt_die("Could not send assertion to model-checker"); diff --git a/src/mc/remote/AppSide.hpp b/src/mc/remote/AppSide.hpp index 0c96f35db6..ccb19fad0e 100644 --- a/src/mc/remote/AppSide.hpp +++ b/src/mc/remote/AppSide.hpp @@ -27,7 +27,7 @@ private: public: AppSide(); explicit AppSide(int fd) : channel_(fd) {} - void handle_messages(); + void handle_messages() const; private: void handle_deadlock_check(const s_mc_message_t* msg) const; @@ -39,7 +39,7 @@ public: Channel const& get_channel() const { return channel_; } Channel& get_channel() { return channel_; } XBT_ATTRIB_NORETURN void main_loop(); - void report_assertion_failure(); + void report_assertion_failure() const; void ignore_memory(void* addr, std::size_t size) const; void ignore_heap(void* addr, std::size_t size) const; void unignore_heap(void* addr, std::size_t size) const; diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 43854f9caa..1b40450457 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -143,7 +143,7 @@ File::~File() kernel::actor::simcall([this, desc_table] { desc_table->push_back(this->desc_id); }); } -void File::dump() +void File::dump() const { if (local_storage_) XBT_INFO("File Descriptor information:\n" diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index e6737e9342..f3a612b417 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -96,7 +96,7 @@ void intrusive_ptr_release(const Actor* actor) { intrusive_ptr_release(actor->pimpl_); } -int Actor::get_refcount() +int Actor::get_refcount() const { return pimpl_->get_refcount(); } @@ -234,7 +234,7 @@ void Actor::resume() s4u::Actor::on_resume(*this); } -bool Actor::is_suspended() +bool Actor::is_suspended() const { return pimpl_->is_suspended(); } diff --git a/src/s4u/s4u_Engine.cpp b/src/s4u/s4u_Engine.cpp index c072730782..89b3cedb5a 100644 --- a/src/s4u/s4u_Engine.cpp +++ b/src/s4u/s4u_Engine.cpp @@ -145,7 +145,7 @@ void Engine::register_function(const std::string& name, const kernel::actor::Act * See also: :ref:`deploy`. * \endrst */ -void Engine::load_deployment(const std::string& deploy) +void Engine::load_deployment(const std::string& deploy) const { pimpl->load_deployment(deploy); } diff --git a/src/smpi/include/smpi_comm.hpp b/src/smpi/include/smpi_comm.hpp index 70fa4ec3be..6ff921e335 100644 --- a/src/smpi/include/smpi_comm.hpp +++ b/src/smpi/include/smpi_comm.hpp @@ -85,7 +85,7 @@ public: void add_rma_win(MPI_Win win); void remove_rma_win(MPI_Win win); - void finish_rma_calls(); + void finish_rma_calls() const; MPI_Comm split_type(int type, int key, const Info* info); }; diff --git a/src/smpi/include/smpi_win.hpp b/src/smpi/include/smpi_win.hpp index 595bfe8394..b50573c837 100644 --- a/src/smpi/include/smpi_win.hpp +++ b/src/smpi/include/smpi_win.hpp @@ -91,7 +91,7 @@ public: int flush_local_all(); int finish_comms(); int finish_comms(int rank); - int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr); + int shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr) const; MPI_Errhandler errhandler(); void set_errhandler( MPI_Errhandler errhandler); }; diff --git a/src/smpi/mpi/smpi_comm.cpp b/src/smpi/mpi/smpi_comm.cpp index b72ab97504..d3e4978d1e 100644 --- a/src/smpi/mpi/smpi_comm.cpp +++ b/src/smpi/mpi/smpi_comm.cpp @@ -532,7 +532,8 @@ void Comm::remove_rma_win(MPI_Win win){ rma_wins_.remove(win); } -void Comm::finish_rma_calls(){ +void Comm::finish_rma_calls() const +{ for (auto const& it : rma_wins_) { if(it->rank()==this->rank()){//is it ours (for MPI_COMM_WORLD)? int finished = it->finish_comms(); diff --git a/src/smpi/mpi/smpi_win.cpp b/src/smpi/mpi/smpi_win.cpp index 38ac9553a6..f62ab4e2ef 100644 --- a/src/smpi/mpi/smpi_win.cpp +++ b/src/smpi/mpi/smpi_win.cpp @@ -736,7 +736,7 @@ int Win::finish_comms(int rank){ return size; } -int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr) +int Win::shared_query(int rank, MPI_Aint* size, int* disp_unit, void* baseptr) const { const Win* target_win = rank != MPI_PROC_NULL ? connected_wins_[rank] : nullptr; for (int i = 0; not target_win && i < comm_->size(); i++) { -- 2.20.1