Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] initialization lists and co.
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 23 Dec 2019 13:08:29 +0000 (14:08 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 23 Dec 2019 13:08:29 +0000 (14:08 +0100)
14 files changed:
examples/s4u/dht-kademlia/node.hpp
include/simgrid/jedule/jedule_platform.hpp
include/simgrid/kernel/routing/FloydZone.hpp
include/simgrid/smpi/replay.hpp
include/xbt/Extendable.hpp
src/kernel/routing/FloydZone.cpp
src/mc/inspect/Frame.hpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_load.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/plugins/vm/VirtualMachineImpl.hpp
src/smpi/include/smpi_comm.hpp
src/smpi/mpi/smpi_comm.cpp
src/surf/network_ib.hpp

index 0aa8d80..4004615 100644 (file)
@@ -17,11 +17,11 @@ class Node {
   unsigned int id_;              // node id - 160 bits
   RoutingTable table;            // node routing table
 public:
-  simgrid::s4u::CommPtr receive_comm;
+  simgrid::s4u::CommPtr receive_comm = nullptr;
   void* received_msg             = nullptr;
   unsigned int find_node_success = 0; // Number of find_node which have succeeded.
   unsigned int find_node_failed  = 0; // Number of find_node which have failed.
-  explicit Node(unsigned int node_id) : id_(node_id), table(node_id), receive_comm(nullptr) {}
+  explicit Node(unsigned int node_id) : id_(node_id), table(node_id) {}
   Node(const Node&) = delete;
   Node& operator=(const Node&) = delete;
   unsigned int getId() { return id_; }
index ed27a85..faa128b 100644 (file)
@@ -22,7 +22,7 @@ public:
   Container& operator=(const Container&) = delete;
 
 private:
-  int last_id_;
+  int last_id_   = 0;
   int is_lowest_ = 0;
 
 public:
index b16ea00..f768867 100644 (file)
@@ -35,9 +35,9 @@ public:
 
 private:
   /* vars to compute the Floyd algorithm. */
-  int* predecessor_table_;
-  double* cost_table_;
-  RouteCreationArgs** link_table_;
+  int* predecessor_table_         = nullptr;
+  double* cost_table_             = nullptr;
+  RouteCreationArgs** link_table_ = nullptr;
 };
 } // namespace routing
 } // namespace kernel
index d295586..715f52e 100644 (file)
@@ -183,11 +183,11 @@ public:
 template <class T> class ReplayAction {
 protected:
   const std::string name;
-  const aid_t my_proc_id;
+  const aid_t my_proc_id = s4u::this_actor::get_pid();
   T args;
 
 public:
-  explicit ReplayAction(const std::string& name) : name(name), my_proc_id(s4u::this_actor::get_pid()) {}
+  explicit ReplayAction(const std::string& name) : name(name) {}
   virtual ~ReplayAction() = default;
 
   void execute(xbt::ReplayAction& action)
index c85201f..66c2aba 100644 (file)
@@ -20,11 +20,11 @@ template<class T>          class Extendable;
 template<class T, class U>
 class Extension {
   static const std::size_t INVALID_ID = std::numeric_limits<std::size_t>::max();
-  std::size_t id_;
+  std::size_t id_                     = INVALID_ID;
   friend class Extendable<T>;
   explicit constexpr Extension(std::size_t id) : id_(id) {}
 public:
-  explicit constexpr Extension() : id_(INVALID_ID) {}
+  explicit constexpr Extension() {}
   std::size_t id() const { return id_; }
   bool valid() const { return id_ != INVALID_ID; }
 };
index c7bb065..d9b7ab8 100644 (file)
@@ -26,9 +26,6 @@ namespace routing {
 FloydZone::FloydZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel)
     : RoutedZone(father, name, netmodel)
 {
-  predecessor_table_ = nullptr;
-  cost_table_        = nullptr;
-  link_table_        = nullptr;
 }
 
 FloydZone::~FloydZone()
index 0d653ed..51ca562 100644 (file)
@@ -23,7 +23,7 @@ namespace mc {
 /** Debug information about a given function or scope within a function */
 class Frame {
 public:
-  Frame();
+  Frame() = default;
 
   /** Kind of scope (DW_TAG_subprogram, DW_TAG_inlined_subroutine, etc.) */
   int tag = DW_TAG_invalid;
@@ -32,7 +32,7 @@ public:
   std::string name;
 
   /** Range of instruction addresses for which this scope is valid */
-  simgrid::xbt::Range<std::uint64_t> range;
+  simgrid::xbt::Range<std::uint64_t> range = {0, 0};
 
   simgrid::dwarf::LocationList frame_base_location;
 
@@ -58,16 +58,6 @@ public:
   void* frame_base(unw_cursor_t& unw_cursor) const;
   void remove_variable(char* name);
 };
-
-inline Frame::Frame()
-{
-  this->tag                = 0;
-  this->range              = {0, 0};
-  this->id                 = 0;
-  this->abstract_origin_id = 0;
-  this->object_info        = nullptr;
-}
-
 } // namespace mc
 } // namespace simgrid
 
index 88ec37b..fce578d 100644 (file)
@@ -479,10 +479,9 @@ FileSystemDiskExt::FileSystemDiskExt(simgrid::s4u::Disk* ptr)
     content_.reset(parse_content(content_str));
 }
 
-FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr)
+FileSystemStorageExt::FileSystemStorageExt(simgrid::s4u::Storage* ptr) : size_(ptr->get_impl()->size_)
 {
   content_.reset(parse_content(ptr->get_impl()->content_name_));
-  size_    = ptr->get_impl()->size_;
 }
 
 std::map<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::string& filename)
index f84ffc0..cf0141a 100644 (file)
@@ -63,7 +63,6 @@ public:
       , last_reset_(surf_get_clock())
       , current_speed_(host_->get_speed())
       , current_flops_(host_->get_load())
-      , theor_max_flops_(0)
   {
   }
   ~HostLoad() = default;
index b7ccd74..ee173f3 100644 (file)
@@ -158,7 +158,7 @@ double VMModel::next_occurring_event(double now)
 
 VirtualMachineImpl::VirtualMachineImpl(simgrid::s4u::VirtualMachine* piface, simgrid::s4u::Host* host_PM,
                                        int core_amount, size_t ramsize)
-    : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), user_bound_(std::numeric_limits<double>::max()), ramsize_(ramsize)
+    : HostImpl(piface), physical_host_(host_PM), core_amount_(core_amount), ramsize_(ramsize)
 {
   /* Register this VM to the list of all VMs */
   allVms_.push_back(piface);
index 8f27c16..aa9013b 100644 (file)
@@ -66,7 +66,7 @@ public:
 private:
   s4u::Host* physical_host_;
   int core_amount_;
-  double user_bound_;
+  double user_bound_                   = std::numeric_limits<double>::max();
   size_t ramsize_            = 0;
   s4u::VirtualMachine::state vm_state_ = s4u::VirtualMachine::state::CREATED;
 };
index 3f57cfa..5c9c915 100644 (file)
@@ -19,22 +19,22 @@ namespace smpi{
 class Comm : public F2C, public Keyval{
   friend Topo;
   MPI_Group group_;
-  SMPI_Topo_type topoType_;
+  SMPI_Topo_type topoType_ = MPI_INVALID_TOPO;
   MPI_Topology topo_; // to be replaced by an union
-  int refcount_;
+  int refcount_ = 1;
   MPI_Comm leaders_comm_; // inter-node communicator
   MPI_Comm intra_comm_;   // intra-node communicator . For MPI_COMM_WORLD this can't be used, as var is global.
   // use an intracomm stored in the process data instead
-  int* leaders_map_; // who is the leader of each process
-  int is_uniform_;
-  int* non_uniform_map_;        // set if smp nodes have a different number of processes allocated
-  int is_blocked_;              // are ranks allocated on the same smp node contiguous ?
+  int* leaders_map_     = nullptr; // who is the leader of each process
+  int is_uniform_       = 1;
+  int* non_uniform_map_ = nullptr; // set if smp nodes have a different number of processes allocated
+  int is_blocked_       = 0;       // are ranks allocated on the same smp node contiguous ?
   int is_smp_comm_;             // set to 0 in case this is already an intra-comm or a leader-comm to avoid recursion
   std::list<MPI_Win> rma_wins_; // attached windows for synchronization.
   std::string name_;
   MPI_Info info_;
   int id_;
-  MPI_Errhandler errhandler_;
+  MPI_Errhandler errhandler_ = MPI_ERRORS_ARE_FATAL;
 
 public:
   static std::unordered_map<int, smpi_key_elem> keyvals_;
index e4e9929..b9cee01 100644 (file)
@@ -30,16 +30,9 @@ int Comm::keyval_id_=0;
 
 Comm::Comm(MPI_Group group, MPI_Topology topo, int smp, int in_id) : group_(group), topo_(topo),is_smp_comm_(smp), id_(in_id)
 {
-  refcount_        = 1;
-  topoType_        = MPI_INVALID_TOPO;
   intra_comm_      = MPI_COMM_NULL;
   leaders_comm_    = MPI_COMM_NULL;
-  is_uniform_      = 1;
-  non_uniform_map_ = nullptr;
-  leaders_map_     = nullptr;
-  is_blocked_      = 0;
   info_            = MPI_INFO_NULL;
-  errhandler_      = MPI_ERRORS_ARE_FATAL;
   errhandler_->ref();
   //First creation of comm is done before SIMIX_run, so only do comms for others
   if(in_id==MPI_UNDEFINED && smp==0 && this->rank()!=MPI_UNDEFINED ){
index ee33677..b2eed0f 100644 (file)
@@ -21,10 +21,10 @@ class XBT_PRIVATE IBNode;
 
 class XBT_PRIVATE ActiveComm {
 public:
-  IBNode* destination;
-  NetworkAction* action;
-  double init_rate;
-  ActiveComm() : destination(nullptr), action(nullptr), init_rate(-1){};
+  IBNode* destination   = nullptr;
+  NetworkAction* action = nullptr;
+  double init_rate      = -1;
+  ActiveComm()          = default;
   virtual ~ActiveComm() = default;
 };
 
@@ -36,8 +36,8 @@ public:
   // store the number of comms received from each node
   std::map<IBNode*, int> ActiveCommsDown;
   // number of comms the node is receiving
-  int nbActiveCommsDown;
-  explicit IBNode(int id) : id(id), nbActiveCommsDown(0){};
+  int nbActiveCommsDown = 0;
+  explicit IBNode(int id) : id(id){};
   virtual ~IBNode() = default;
 };