Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Use "std::make_shared" to construct "std::shared_ptr".
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Oct 2020 21:39:42 +0000 (23:39 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 2 Oct 2020 21:42:31 +0000 (23:42 +0200)
include/simgrid/kernel/future.hpp
src/mc/checker/LivenessChecker.cpp
src/smpi/internals/smpi_replay.cpp

index 906d702..b41008e 100644 (file)
@@ -485,7 +485,7 @@ public:
   }
 
 private:
-  std::shared_ptr<FutureState<T>> state_{new FutureState<T>()};
+  std::shared_ptr<FutureState<T>> state_ = std::make_shared<FutureState<T>>();
   bool future_get_ = false;
 };
 
@@ -536,7 +536,7 @@ public:
   }
 
 private:
-  std::shared_ptr<FutureState<void>> state_{new FutureState<void>()};
+  std::shared_ptr<FutureState<void>> state_ = std::make_shared<FutureState<void>>();
   bool future_get_ = false;
 };
 
index e22741d..37bf222 100644 (file)
@@ -266,7 +266,7 @@ std::shared_ptr<Pair> LivenessChecker::create_pair(const Pair* current_pair, xbt
   expanded_pairs_count_++;
   std::shared_ptr<Pair> next_pair = std::make_shared<Pair>(expanded_pairs_count_);
   next_pair->automaton_state      = state;
-  next_pair->graph_state          = std::shared_ptr<State>(new State(++expanded_states_count_));
+  next_pair->graph_state          = std::make_shared<State>(++expanded_states_count_);
   next_pair->atomic_propositions  = std::move(propositions);
   if (current_pair)
     next_pair->depth = current_pair->depth + 1;
index d05763b..527dd9e 100644 (file)
@@ -261,7 +261,7 @@ void GatherVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::stri
   CHECK_ACTION_PARAMS(action, comm_size + 1, 2)
   send_size  = parse_double(action[2]);
   disps      = std::vector<int>(comm_size, 0);
-  recvcounts = std::shared_ptr<std::vector<int>>(new std::vector<int>(comm_size));
+  recvcounts = std::make_shared<std::vector<int>>(comm_size);
 
   if (name == "gatherv") {
     root = (action.size() > 3 + comm_size) ? std::stoi(action[3 + comm_size]) : 0;
@@ -336,7 +336,7 @@ void ScatterVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::str
   CHECK_ACTION_PARAMS(action, comm_size + 1, 2)
   recv_size  = parse_double(action[2 + comm_size]);
   disps      = std::vector<int>(comm_size, 0);
-  sendcounts = std::shared_ptr<std::vector<int>>(new std::vector<int>(comm_size));
+  sendcounts = std::make_shared<std::vector<int>>(comm_size);
 
   if (action.size() > 5 + comm_size)
     datatype1 = simgrid::smpi::Datatype::decode(action[4 + comm_size]);
@@ -362,7 +362,7 @@ void ReduceScatterArgParser::parse(simgrid::xbt::ReplayAction& action, const std
   comm_size = MPI_COMM_WORLD->size();
   CHECK_ACTION_PARAMS(action, comm_size + 1, 1)
   comp_size  = parse_double(action[2 + comm_size]);
-  recvcounts = std::shared_ptr<std::vector<int>>(new std::vector<int>(comm_size));
+  recvcounts = std::make_shared<std::vector<int>>(comm_size);
   if (action.size() > 3 + comm_size)
     datatype1 = simgrid::smpi::Datatype::decode(action[3 + comm_size]);
 
@@ -384,8 +384,8 @@ void AllToAllVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::st
   */
   comm_size = MPI_COMM_WORLD->size();
   CHECK_ACTION_PARAMS(action, 2 * comm_size + 2, 2)
-  sendcounts = std::shared_ptr<std::vector<int>>(new std::vector<int>(comm_size));
-  recvcounts = std::shared_ptr<std::vector<int>>(new std::vector<int>(comm_size));
+  sendcounts = std::make_shared<std::vector<int>>(comm_size);
+  recvcounts = std::make_shared<std::vector<int>>(comm_size);
   senddisps  = std::vector<int>(comm_size, 0);
   recvdisps  = std::vector<int>(comm_size, 0);