Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Const for pointer and reference parameters (slight return).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 Jul 2020 12:10:27 +0000 (14:10 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 Jul 2020 12:45:27 +0000 (14:45 +0200)
16 files changed:
examples/s4u/engine-filtering/s4u-engine-filtering.cpp
include/simgrid/plugins/file_system.h
src/instr/instr_config.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/actor/ActorImpl.hpp
src/plugins/file_system/s4u_FileSystem.cpp
src/smpi/include/smpi_file.hpp
src/smpi/include/smpi_group.hpp
src/smpi/include/smpi_status.hpp
src/smpi/internals/smpi_replay.cpp
src/smpi/mpi/smpi_file.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/mpi/smpi_status.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp

index b240d22..d34e21f 100644 (file)
@@ -39,7 +39,7 @@ class FrequencyChanged {
   std::map<simgrid::s4u::Host*, int> host_list;
 
 public:
-  explicit FrequencyChanged(simgrid::s4u::Engine& e)
+  explicit FrequencyChanged(const simgrid::s4u::Engine& e)
   {
     std::vector<simgrid::s4u::Host*> list = e.get_all_hosts();
     for (auto& host : list) {
index 7b9c7a5..bc36088 100644 (file)
@@ -29,14 +29,14 @@ XBT_PUBLIC sg_size_t sg_file_read(sg_file_t fd, sg_size_t size);
 XBT_PUBLIC sg_size_t sg_file_write(sg_file_t fd, sg_size_t size);
 XBT_PUBLIC void sg_file_close(const_sg_file_t fd);
 
-XBT_PUBLIC const char* sg_file_get_name(sg_file_t fd);
-XBT_PUBLIC sg_size_t sg_file_get_size(sg_file_t fd);
+XBT_PUBLIC const char* sg_file_get_name(const_sg_file_t fd);
+XBT_PUBLIC sg_size_t sg_file_get_size(const_sg_file_t fd);
 XBT_PUBLIC void sg_file_dump(sg_file_t fd);
 XBT_PUBLIC void* sg_file_get_data(const_sg_file_t fd);
 XBT_PUBLIC void sg_file_set_data(sg_file_t fd, void* data);
 XBT_PUBLIC void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin);
-XBT_PUBLIC sg_size_t sg_file_tell(sg_file_t fd);
-XBT_PUBLIC void sg_file_move(sg_file_t fd, const char* fullpath);
+XBT_PUBLIC sg_size_t sg_file_tell(const_sg_file_t fd);
+XBT_PUBLIC void sg_file_move(const_sg_file_t fd, const char* fullpath);
 XBT_PUBLIC void sg_file_unlink(sg_file_t fd);
 XBT_PUBLIC int sg_file_rcopy(sg_file_t file, sg_host_t host, const char* fullpath);
 XBT_PUBLIC int sg_file_rmove(sg_file_t file, sg_host_t host, const char* fullpath);
index 881499f..a0f9afb 100644 (file)
@@ -225,7 +225,7 @@ xbt::signal<void(PajeEvent&)> PajeEvent::on_destruction;
 xbt::signal<void(StateEvent&)> StateEvent::on_destruction;
 xbt::signal<void(EntityValue&)> EntityValue::on_creation;
 
-static void on_container_creation_paje(Container& c)
+static void on_container_creation_paje(const Container& c)
 {
   double timestamp = SIMIX_get_clock();
   std::stringstream stream;
@@ -244,7 +244,7 @@ static void on_container_creation_paje(Container& c)
   tracing_file << stream.str() << std::endl;
 }
 
-static void on_container_destruction_paje(Container& c)
+static void on_container_destruction_paje(const Container& c)
 {
   // trace my destruction, but not if user requests so or if the container is root
   if (not trace_disable_destroy && &c != Container::get_root()) {
@@ -323,13 +323,13 @@ static void on_event_destruction(const PajeEvent& event)
   tracing_file << event.stream_.str() << std::endl;
 }
 
-static void on_state_event_destruction(StateEvent& event)
+static void on_state_event_destruction(const StateEvent& event)
 {
   if (event.has_extra())
     *tracing_files.at(event.get_container()) << event.stream_.str() << std::endl;
 }
 
-static void on_type_creation(Type& type, e_event_type event_type)
+static void on_type_creation(const Type& type, e_event_type event_type)
 {
   if (event_type == PAJE_DefineLinkType)
     return; // this kind of type has to be handled differently
@@ -344,7 +344,7 @@ static void on_type_creation(Type& type, e_event_type event_type)
   tracing_file << stream.str() << std::endl;
 }
 
-static void on_link_type_creation(Type& type, Type& source, Type& dest)
+static void on_link_type_creation(const Type& type, const Type& source, const Type& dest)
 {
   std::stringstream stream;
   XBT_DEBUG("%s: event_type=%u, timestamp=%.*f", __func__, PAJE_DefineLinkType, trace_precision, 0.);
index 6e0b52a..0c9d9a5 100644 (file)
@@ -494,7 +494,8 @@ ActorImpl* ActorImpl::start(const ActorCode& code)
 }
 
 ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
-                               const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor)
+                               const std::unordered_map<std::string, std::string>* properties,
+                               const ActorImpl* parent_actor)
 {
   XBT_DEBUG("Start actor %s@'%s'", name.c_str(), host->get_cname());
 
index 181e019..6e9691f 100644 (file)
@@ -121,7 +121,8 @@ public:
   ActorImpl* start(const ActorCode& code);
 
   static ActorImplPtr create(const std::string& name, const ActorCode& code, void* data, s4u::Host* host,
-                             const std::unordered_map<std::string, std::string>* properties, ActorImpl* parent_actor);
+                             const std::unordered_map<std::string, std::string>* properties,
+                             const ActorImpl* parent_actor);
   static ActorImplPtr attach(const std::string& name, void* data, s4u::Host* host,
                              const std::unordered_map<std::string, std::string>* properties);
   static void detach();
index 1b40450..6c37927 100644 (file)
@@ -702,7 +702,7 @@ void sg_file_close(const_sg_file_t fd)
 /** Retrieves the path to the file
  * @ingroup plugin_filesystem
  */
-const char* sg_file_get_name(sg_file_t fd)
+const char* sg_file_get_name(const_sg_file_t fd)
 {
   xbt_assert((fd != nullptr), "Invalid file descriptor");
   return fd->get_path();
@@ -711,7 +711,7 @@ const char* sg_file_get_name(sg_file_t fd)
 /** Retrieves the size of the file
  * @ingroup plugin_filesystem
  */
-sg_size_t sg_file_get_size(sg_file_t fd)
+sg_size_t sg_file_get_size(const_sg_file_t fd)
 {
   return fd->size();
 }
@@ -752,12 +752,12 @@ void sg_file_seek(sg_file_t fd, sg_offset_t offset, int origin)
   fd->seek(offset, origin);
 }
 
-sg_size_t sg_file_tell(sg_file_t fd)
+sg_size_t sg_file_tell(const_sg_file_t fd)
 {
   return fd->tell();
 }
 
-void sg_file_move(sg_file_t fd, const char* fullpath)
+void sg_file_move(const_sg_file_t fd, const char* fullpath)
 {
   fd->move(fullpath);
 }
index ad1a720..e03b30f 100644 (file)
@@ -49,13 +49,14 @@ class File : public F2C{
   int get_view(MPI_Offset* disp, MPI_Datatype* etype, MPI_Datatype* filetype, char* datarep) const;
   MPI_Info info();
   void set_info( MPI_Info info);
-  static int read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  static int read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  static int read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  static int write(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  static int write_shared(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  static int write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
-  template <int (*T)(MPI_File, void *, int, MPI_Datatype, MPI_Status *)> int op_all(void *buf, int count,MPI_Datatype datatype, MPI_Status *status);
+  static int read(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  static int read_shared(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  static int read_ordered(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  static int write(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  static int write_shared(MPI_File fh, const void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  static int write_ordered(MPI_File fh, const void* buf, int count, const Datatype* datatype, MPI_Status* status);
+  template <int (*T)(MPI_File, void*, int, const Datatype*, MPI_Status*)>
+  int op_all(void* buf, int count, const Datatype* datatype, MPI_Status* status);
   static int close(MPI_File *fh);
   static int del(const char* filename, const Info* info);
   MPI_Errhandler errhandler();
@@ -71,8 +72,9 @@ class File : public F2C{
   /* issue_date = {Winter 1996},*/
   /* pages = {301--317},*/
   /* }*/ 
-  template <int (*T)(MPI_File, void *, int, MPI_Datatype, MPI_Status *)>
-  int File::op_all(void *buf, int count, MPI_Datatype datatype, MPI_Status *status){
+  template <int (*T)(MPI_File, void*, int, const Datatype*, MPI_Status*)>
+  int File::op_all(void* buf, int count, const Datatype* datatype, MPI_Status* status)
+  {
     //get min and max offsets from everyone.
     int size =  comm_->size();
     int rank = comm_-> rank();
index 82c51c4..67e1291 100644 (file)
@@ -29,7 +29,7 @@ class Group : public F2C{
 public:
   Group() = default;
   explicit Group(int size) : size_(size), rank_to_actor_map_(size, nullptr), index_to_rank_map_(size, MPI_UNDEFINED) {}
-  explicit Group(Group* origin);
+  explicit Group(const Group* origin);
 
   void set_mapping(s4u::Actor* actor, int rank);
   int rank(int index);
index 31a7a1d..c906afd 100644 (file)
@@ -20,7 +20,7 @@ static void empty(MPI_Status * status);
 static int cancelled (const MPI_Status * status);
 static void set_cancelled (MPI_Status * status, int flag);
 static void set_elements(MPI_Status* status, const Datatype*, int count);
-static int get_count(const MPI_Status * status, MPI_Datatype datatype);
+static int get_count(const MPI_Status* status, const Datatype* datatype);
 };
 
 
index 6e01ff4..d05763b 100644 (file)
@@ -115,7 +115,7 @@ public:
       return (it == store.end()) ? MPI_REQUEST_NULL : it->second;
     }
 
-    void remove(MPI_Request req)
+    void remove(const Request* req)
     {
       if (req == MPI_REQUEST_NULL) return;
 
index 5e480d6..872d9a7 100644 (file)
@@ -145,7 +145,7 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::read(MPI_File fh, void* /*buf*/, int count, MPI_Datatype datatype, MPI_Status* status)
+  int File::read(MPI_File fh, void* /*buf*/, int count, const Datatype* datatype, MPI_Status* status)
   {
     //get position first as we may be doing non contiguous reads and it will probably be updated badly
     MPI_Offset position = fh->file_->tell();
@@ -173,7 +173,8 @@ namespace smpi{
   /* address="Berlin, Heidelberg",*/
   /* pages="84--93"*/
   /* }*/
-  int File::read_shared(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){
+  int File::read_shared(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status)
+  {
     fh->shared_mutex_->lock();
     fh->seek(*(fh->shared_file_pointer_),MPI_SEEK_SET);
     read(fh, buf, count, datatype, status);
@@ -182,7 +183,8 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::read_ordered(MPI_File fh, void *buf, int count, MPI_Datatype datatype, MPI_Status *status){
+  int File::read_ordered(MPI_File fh, void* buf, int count, const Datatype* datatype, MPI_Status* status)
+  {
     //0 needs to get the shared pointer value
     MPI_Offset val;
     if(fh->comm_->rank()==0){
@@ -205,7 +207,7 @@ namespace smpi{
     return ret;
   }
 
-  int File::write(MPI_File fh, void* /*buf*/, int count, MPI_Datatype datatype, MPI_Status* status)
+  int File::write(MPI_File fh, void* /*buf*/, int count, const Datatype* datatype, MPI_Status* status)
   {
     //get position first as we may be doing non contiguous reads and it will probably be updated badly
     MPI_Offset position = fh->file_->tell();
@@ -223,7 +225,8 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::write_shared(MPI_File fh, const void *buf, int count, MPI_Datatype datatype, MPI_Status *status){
+  int File::write_shared(MPI_File fh, const void* buf, int count, const Datatype* datatype, MPI_Status* status)
+  {
     fh->shared_mutex_->lock();
     XBT_DEBUG("Write shared on %s - Shared ptr before : %lld",fh->file_->get_path(), *(fh->shared_file_pointer_));
     fh->seek(*(fh->shared_file_pointer_),MPI_SEEK_SET);
@@ -234,7 +237,8 @@ namespace smpi{
     return MPI_SUCCESS;
   }
 
-  int File::write_ordered(MPI_File fh, const void *buf, int count, MPI_Datatype datatype, MPI_Status *status){
+  int File::write_ordered(MPI_File fh, const void* buf, int count, const Datatype* datatype, MPI_Status* status)
+  {
     //0 needs to get the shared pointer value
     MPI_Offset val;
     if(fh->comm_->rank()==0){
index 92cee30..37b2a22 100644 (file)
@@ -14,7 +14,7 @@ MPI_Group MPI_GROUP_EMPTY=&mpi_MPI_GROUP_EMPTY;
 namespace simgrid{
 namespace smpi{
 
-Group::Group(Group* origin)
+Group::Group(const Group* origin)
 {
   if (origin != MPI_GROUP_NULL && origin != MPI_GROUP_EMPTY) {
     size_              = origin->size();
index f1060f1..2bc696f 100644 (file)
@@ -1026,7 +1026,7 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status)
   return index;
 }
 
-static int sort_accumulates(MPI_Request a, MPI_Request b)
+static int sort_accumulates(const Request* a, const Request* b)
 {
   return (a->tag() > b->tag());
 }
index b048fe7..c11c097 100644 (file)
@@ -37,7 +37,7 @@ void Status::set_elements(MPI_Status* status, const Datatype*, int count)
   status->count=count;
 }
 
-int Status::get_count(const MPI_Status * status, MPI_Datatype datatype)
+int Status::get_count(const MPI_Status* status, const Datatype* datatype)
 {
   return status->count / datatype->size();
 }
index 0d3bfc9..ff17a48 100644 (file)
@@ -73,7 +73,7 @@ void HostImpl::turn_on() const
 }
 
 /** Kill all actors hosted here */
-void HostImpl::turn_off(kernel::actor::ActorImpl* issuer)
+void HostImpl::turn_off(const kernel::actor::ActorImpl* issuer)
 {
   for (auto& actor : actor_list_) {
     XBT_DEBUG("Killing Actor %s@%s on behalf of %s which turned off that host.", actor.get_cname(),
index 7ce2468..6e3404f 100644 (file)
@@ -66,7 +66,7 @@ public:
   s4u::Host* get_iface() { return piface_; }
 
   void turn_on() const;
-  void turn_off(kernel::actor::ActorImpl* issuer);
+  void turn_off(const kernel::actor::ActorImpl* issuer);
   std::vector<s4u::ActorPtr> get_all_actors();
   size_t get_actor_count() const;
   void add_actor(kernel::actor::ActorImpl* actor) { actor_list_.push_back(*actor); }