Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar, and other small cleanups
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 11 Dec 2016 20:29:50 +0000 (21:29 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 11 Dec 2016 20:51:33 +0000 (21:51 +0100)
- Init members during initialization
- One operation per line at most
- Don't let fields uninited after the constructor
- Obey our naming schema (fields' name end with _)

src/kernel/activity/SynchroExec.cpp
src/kernel/activity/SynchroExec.hpp
src/kernel/routing/AsClusterTorus.cpp
src/s4u/s4u_file.cpp
src/s4u/s4u_storage.cpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp

index 15d9a21..5954df6 100644 (file)
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
 
 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
 
-simgrid::kernel::activity::Exec::Exec(const char*name, sg_host_t hostarg)
+simgrid::kernel::activity::Exec::Exec(const char*name, sg_host_t host) :
+    host_(host)
 {
   if (name)
     this->name = name;
   this->state = SIMIX_RUNNING;
 {
   if (name)
     this->name = name;
   this->state = SIMIX_RUNNING;
-  this->host = hostarg;
 }
 
 simgrid::kernel::activity::Exec::~Exec()
 }
 
 simgrid::kernel::activity::Exec::~Exec()
@@ -50,7 +50,7 @@ double simgrid::kernel::activity::Exec::remains()
 
 void simgrid::kernel::activity::Exec::post()
 {
 
 void simgrid::kernel::activity::Exec::post()
 {
-  if (host && host->isOff()) {/* FIMXE: handle resource failure for parallel tasks too */
+  if (host_ && host_->isOff()) {/* FIMXE: handle resource failure for parallel tasks too */
     /* If the host running the synchro failed, notice it. This way, the asking
      * process can be killed if it runs on that host itself */
     state = SIMIX_FAILED;
     /* If the host running the synchro failed, notice it. This way, the asking
      * process can be killed if it runs on that host itself */
     state = SIMIX_FAILED;
index c0e315f..9269975 100644 (file)
@@ -22,7 +22,7 @@ namespace activity {
     void post() override;
     double remains();
 
     void post() override;
     double remains();
 
-    sg_host_t host = nullptr; /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf knows the hosts) */
+    sg_host_t host_ = nullptr; /* The host where the execution takes place. If nullptr, then this is a parallel exec (and only surf knows the hosts) */
     surf_action_t surf_exec = nullptr; /* The Surf execution action encapsulated */
     surf::Action* timeoutDetector = nullptr;
   };
     surf_action_t surf_exec = nullptr; /* The Surf execution action encapsulated */
     surf::Action* timeoutDetector = nullptr;
   };
index 017dbc0..495f5bb 100644 (file)
@@ -62,7 +62,8 @@ namespace simgrid {
         link.latency = cluster->lat;
         link.policy = cluster->sharing_policy;
         sg_platf_new_link(&link);
         link.latency = cluster->lat;
         link.policy = cluster->sharing_policy;
         sg_platf_new_link(&link);
-        Link *linkUp, *linkDown;
+        Link* linkUp;
+        Link* linkDown;
         if (link.policy == SURF_LINK_FULLDUPLEX) {
           char *tmp_link = bprintf("%s_UP", link_id);
           linkUp         = Link::byName(tmp_link);
         if (link.policy == SURF_LINK_FULLDUPLEX) {
           char *tmp_link = bprintf("%s_UP", link_id);
           linkUp         = Link::byName(tmp_link);
index 7512efb..e6fe865 100644 (file)
@@ -20,10 +20,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_file,"S4U files");
 namespace simgrid {
 namespace s4u {
 
 namespace simgrid {
 namespace s4u {
 
-File::File(const char*fullpath, void *userdata) {
+File::File(const char* fullpath, void* userdata) : path_(fullpath)
+{
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   pimpl_ = simcall_file_open(fullpath, Host::current());
   // this cannot fail because we get a xbt_die if the mountpoint does not exist
   pimpl_ = simcall_file_open(fullpath, Host::current());
-  path_ = fullpath;
 }
 
 File::~File() {
 }
 
 File::~File() {
index 04c1ee4..c6e3334 100644 (file)
@@ -13,16 +13,13 @@ namespace simgrid {
 namespace s4u {
 
 boost::unordered_map <std::string, Storage *> *Storage::storages_ = new boost::unordered_map<std::string, Storage*> ();
 namespace s4u {
 
 boost::unordered_map <std::string, Storage *> *Storage::storages_ = new boost::unordered_map<std::string, Storage*> ();
-Storage::Storage(std::string name, smx_storage_t inferior) {
-  name_ = name;
-  pimpl_ = inferior;
-
+Storage::Storage(std::string name, smx_storage_t inferior) :
+    name_(name), pimpl_(inferior)
+{
   storages_->insert({name, this});
 }
 
   storages_->insert({name, this});
 }
 
-Storage::~Storage() {
-  // TODO Auto-generated destructor stub
-}
+Storage::~Storage() = default;
 
 smx_storage_t Storage::inferior() {
   return pimpl_;
 
 smx_storage_t Storage::inferior() {
   return pimpl_;
index 97ee3c2..6e9afb5 100644 (file)
@@ -252,7 +252,8 @@ double CpuTiTgmr::getPowerScale(double a)
 * \param  value          Percentage of CPU speed available (useful to fixed tracing)
 * \return  Integration trace structure
 */
 * \param  value          Percentage of CPU speed available (useful to fixed tracing)
 * \return  Integration trace structure
 */
-CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value)
+CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value) :
+    speedTrace_(speedTrace)
 {
   double total_time = 0.0;
   trace_ = 0;
 {
   double total_time = 0.0;
   trace_ = 0;
@@ -274,12 +275,11 @@ CpuTiTgmr::CpuTiTgmr(tmgr_trace_t speedTrace, double value)
   }
 
   type_ = TRACE_DYNAMIC;
   }
 
   type_ = TRACE_DYNAMIC;
-  speedTrace_ = speedTrace;
 
   /* count the total time of trace file */
 
   /* count the total time of trace file */
-  for (auto val: speedTrace->event_list) {
+  for (auto val : speedTrace->event_list)
     total_time += val.delta;
     total_time += val.delta;
-  }
+
   trace_ = new CpuTiTrace(speedTrace);
   lastTime_ = total_time;
   total_ = trace_->integrateSimple(0, total_time);
   trace_ = new CpuTiTrace(speedTrace);
   lastTime_ = total_time;
   total_ = trace_->integrateSimple(0, total_time);
@@ -669,9 +669,8 @@ void CpuTi::modified(bool modified){
 
 CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, CpuTi *cpu)
  : CpuAction(model_, cost, failed)
 
 CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, CpuTi *cpu)
  : CpuAction(model_, cost, failed)
+ , cpu_(cpu)
 {
 {
-  cpu_ = cpu;
-  indexHeap_ = -1;
   cpu_->modified(true);
 }
 
   cpu_->modified(true);
 }
 
index 4636311..90f93fe 100644 (file)
@@ -97,7 +97,7 @@ public:
   double getRemains() override;
 
   CpuTi *cpu_;
   double getRemains() override;
 
   CpuTi *cpu_;
-  int indexHeap_;
+  int indexHeap_ = -1;
   int suspended_ = 0;
 public:
   boost::intrusive::list_member_hook<> action_ti_hook;
   int suspended_ = 0;
 public:
   boost::intrusive::list_member_hook<> action_ti_hook;
index f488f01..ebbd2cf 100644 (file)
@@ -150,10 +150,12 @@ Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t *host_list,
   return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate);
 }
 
   return new L07Action(this, host_nb, host_list, flops_amount, bytes_amount, rate);
 }
 
-
 L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
                      double *flops_amount, double *bytes_amount, double rate)
   : CpuAction(model, 1, 0)
 L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
                      double *flops_amount, double *bytes_amount, double rate)
   : CpuAction(model, 1, 0)
+  , computationAmount_(flops_amount)
+  , communicationAmount_(bytes_amount)
+  , rate_(rate)
 {
   int nb_link = 0;
   int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
 {
   int nb_link = 0;
   int nb_used_host = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
@@ -191,10 +193,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list,
       nb_used_host++;
 
   XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
       nb_used_host++;
 
   XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
-  this->computationAmount_ = flops_amount;
-  this->communicationAmount_ = bytes_amount;
   this->latency_ = latency;
   this->latency_ = latency;
-  this->rate_ = rate;
 
   this->variable_ = lmm_variable_new(model->getMaxminSystem(), this, 1.0,
       (rate > 0 ? rate : -1.0),
 
   this->variable_ = lmm_variable_new(model->getMaxminSystem(), this, 1.0,
       (rate > 0 ? rate : -1.0),
index 22ff980..bf31e1f 100644 (file)
@@ -265,7 +265,8 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
     }
 
     //add a limiter link (shared link to account for maximal bandwidth of the node)
     }
 
     //add a limiter link (shared link to account for maximal bandwidth of the node)
-    linkUp = linkDown = nullptr;
+    linkUp   = nullptr;
+    linkDown = nullptr;
     if(cluster->limiter_link!=0){
       char *tmp_link = bprintf("%s_limiter", link_id);
       XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->limiter_link);
     if(cluster->limiter_link!=0){
       char *tmp_link = bprintf("%s_limiter", link_id);
       XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->limiter_link);