Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics around std::unique_ptr.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 8 Mar 2019 14:34:00 +0000 (15:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 9 Mar 2019 20:27:44 +0000 (21:27 +0100)
src/mc/Session.cpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/compare.cpp
src/mc/remote/Client.cpp
src/mc/remote/RemoteClient.cpp
src/mc/sosp/PageStore_test.cpp
src/mc/sosp/mc_snapshot_test.cpp
src/simix/smx_global.cpp
src/xbt/backtrace.cpp

index 7959e9f..a9279ca 100644 (file)
@@ -91,8 +91,7 @@ Session::Session(pid_t pid, int socket)
 #else
   process->privatized(false);
 #endif
 #else
   process->privatized(false);
 #endif
-  modelChecker_ = std::unique_ptr<ModelChecker>(
-    new simgrid::mc::ModelChecker(std::move(process)));
+  modelChecker_.reset(new simgrid::mc::ModelChecker(std::move(process)));
   xbt_assert(mc_model_checker == nullptr);
   mc_model_checker = modelChecker_.get();
   mc_model_checker->start();
   xbt_assert(mc_model_checker == nullptr);
   mc_model_checker = modelChecker_.get();
   mc_model_checker->start();
index 082678e..f67819b 100644 (file)
@@ -175,8 +175,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
       xbt_dynar_get_as(initial_communications_pattern, issuer->get_pid(), simgrid::mc::PatternCommunicationList*);
   xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(incomplete_communications_pattern, issuer->get_pid(), xbt_dynar_t);
 
       xbt_dynar_get_as(initial_communications_pattern, issuer->get_pid(), simgrid::mc::PatternCommunicationList*);
   xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(incomplete_communications_pattern, issuer->get_pid(), xbt_dynar_t);
 
-  std::unique_ptr<simgrid::mc::PatternCommunication> pattern =
-      std::unique_ptr<simgrid::mc::PatternCommunication>(new simgrid::mc::PatternCommunication());
+  std::unique_ptr<simgrid::mc::PatternCommunication> pattern(new simgrid::mc::PatternCommunication());
   pattern->index = initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
 
   if (call_type == MC_CALL_TYPE_SEND) {
   pattern->index = initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
 
   if (call_type == MC_CALL_TYPE_SEND) {
@@ -271,7 +270,7 @@ void CommunicationDeterminismChecker::complete_comm_pattern(
       completed = 1;
       simgrid::mc::PatternCommunication* temp;
       xbt_dynar_remove_at(xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t), cursor, &temp);
       completed = 1;
       simgrid::mc::PatternCommunication* temp;
       xbt_dynar_remove_at(xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t), cursor, &temp);
-      comm_pattern = std::unique_ptr<simgrid::mc::PatternCommunication>(temp);
+      comm_pattern.reset(temp);
       XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", issuer, cursor);
       break;
     }
       XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", issuer, cursor);
       break;
     }
index 47cfabd..7149a71 100644 (file)
@@ -1480,7 +1480,7 @@ int snapshot_compare(int num1, simgrid::mc::Snapshot* s1, int num2, simgrid::mc:
   // TODO, make this a field of ModelChecker or something similar
 
   if (state_comparator == nullptr)
   // TODO, make this a field of ModelChecker or something similar
 
   if (state_comparator == nullptr)
-    state_comparator = std::unique_ptr<StateComparator>(new StateComparator());
+    state_comparator.reset(new StateComparator());
   else
     state_comparator->clear();
 
   else
     state_comparator->clear();
 
index 7cbff1f..321aa36 100644 (file)
@@ -54,7 +54,7 @@ Client* Client::initialize()
     xbt_die("Unexpected socket type %i", type);
   XBT_DEBUG("Model-checked application found expected socket type");
 
     xbt_die("Unexpected socket type %i", type);
   XBT_DEBUG("Model-checked application found expected socket type");
 
-  instance_ = std::unique_ptr<Client>(new simgrid::mc::Client(fd));
+  instance_.reset(new simgrid::mc::Client(fd));
 
   // Wait for the model-checker:
   errno = 0;
 
   // Wait for the model-checker:
   errno = 0;
index 8766ad5..9275ec5 100644 (file)
@@ -239,7 +239,7 @@ void RemoteClient::refresh_heap()
 {
   // Read/dereference/refresh the std_heap pointer:
   if (not this->heap)
 {
   // Read/dereference/refresh the std_heap pointer:
   if (not this->heap)
-    this->heap = std::unique_ptr<s_xbt_mheap_t>(new s_xbt_mheap_t());
+    this->heap.reset(new s_xbt_mheap_t());
   this->read_bytes(this->heap.get(), sizeof(mdesc), remote(this->heap_address), simgrid::mc::ProcessIndexDisabled);
   this->cache_flags_ |= RemoteClient::cache_heap;
 }
   this->read_bytes(this->heap.get(), sizeof(mdesc), remote(this->heap_address), simgrid::mc::ProcessIndexDisabled);
   this->cache_flags_ |= RemoteClient::cache_heap;
 }
index b4f7ea9..2200651 100644 (file)
@@ -49,7 +49,7 @@ int helper_tests::value                        = 0;
 void helper_tests::Init()
 {
   pagesize = (size_t)getpagesize();
 void helper_tests::Init()
 {
   pagesize = (size_t)getpagesize();
-  store    = std::unique_ptr<PageStore>(new simgrid::mc::PageStore(50));
+  store.reset(new simgrid::mc::PageStore(50));
   data     = mmap(nullptr, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   REQUIRE(store->size() == 0);
 }
   data     = mmap(nullptr, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
   REQUIRE(store->size() == 0);
 }
index 50cd1a2..ef1591c 100644 (file)
@@ -66,7 +66,7 @@ void snap_test_helper::Init(bool sparse_ckpt)
   REQUIRE(xbt_pagesize == getpagesize());
   REQUIRE(1 << xbt_pagebits == xbt_pagesize);
 
   REQUIRE(xbt_pagesize == getpagesize());
   REQUIRE(1 << xbt_pagebits == xbt_pagesize);
 
-  process = std::unique_ptr<simgrid::mc::RemoteClient>(new simgrid::mc::RemoteClient(getpid(), -1));
+  process.reset(new simgrid::mc::RemoteClient(getpid(), -1));
   process->init();
   mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
 }
   process->init();
   mc_model_checker = new ::simgrid::mc::ModelChecker(std::move(process));
 }
index 2686185..9fe7ef1 100644 (file)
@@ -199,7 +199,7 @@ void SIMIX_global_init(int *argc, char **argv)
 #endif
 
   if (simix_global == nullptr) {
 #endif
 
   if (simix_global == nullptr) {
-    simix_global = std::unique_ptr<simgrid::simix::Global>(new simgrid::simix::Global());
+    simix_global.reset(new simgrid::simix::Global());
     simix_global->maestro_process = nullptr;
 
     surf_init(argc, argv);      /* Initialize SURF structures */
     simix_global->maestro_process = nullptr;
 
     surf_init(argc, argv);      /* Initialize SURF structures */
index c2ceee4..837062a 100644 (file)
@@ -46,8 +46,8 @@ std::unique_ptr<char, std::function<void(char*)>> demangle(const char* name)
 {
 #ifdef __GXX_ABI_VERSION
   int status;
 {
 #ifdef __GXX_ABI_VERSION
   int status;
-  auto res = std::unique_ptr<char, std::function<void(char*)>>(abi::__cxa_demangle(name, nullptr, nullptr, &status),
-                                                               &std::free);
+  std::unique_ptr<char, std::function<void(char*)>> res(abi::__cxa_demangle(name, nullptr, nullptr, &status),
+                                                        &std::free);
   if (res != nullptr)
     return res;
   // We did not manage to resolve this. Probably because this is not a mangled symbol:
   if (res != nullptr)
     return res;
   // We did not manage to resolve this. Probably because this is not a mangled symbol: