From: Arnaud Giersch Date: Fri, 8 Mar 2019 14:34:00 +0000 (+0100) Subject: Cosmetics around std::unique_ptr. X-Git-Tag: v3_22~132 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/31a818b15a9657dd08268d473255481b2a2d197b Cosmetics around std::unique_ptr. --- diff --git a/src/mc/Session.cpp b/src/mc/Session.cpp index 7959e9f7df..a9279cacc4 100644 --- a/src/mc/Session.cpp +++ b/src/mc/Session.cpp @@ -91,8 +91,7 @@ Session::Session(pid_t pid, int socket) #else process->privatized(false); #endif - modelChecker_ = std::unique_ptr( - 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(); diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 082678e0e6..f67819bb38 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -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); - std::unique_ptr pattern = - std::unique_ptr(new simgrid::mc::PatternCommunication()); + std::unique_ptr pattern(new simgrid::mc::PatternCommunication()); 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); - comm_pattern = std::unique_ptr(temp); + comm_pattern.reset(temp); XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", issuer, cursor); break; } diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index 47cfabd67a..7149a715ef 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -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) - state_comparator = std::unique_ptr(new StateComparator()); + state_comparator.reset(new StateComparator()); else state_comparator->clear(); diff --git a/src/mc/remote/Client.cpp b/src/mc/remote/Client.cpp index 7cbff1f4b0..321aa3677a 100644 --- a/src/mc/remote/Client.cpp +++ b/src/mc/remote/Client.cpp @@ -54,7 +54,7 @@ Client* Client::initialize() xbt_die("Unexpected socket type %i", type); XBT_DEBUG("Model-checked application found expected socket type"); - instance_ = std::unique_ptr(new simgrid::mc::Client(fd)); + instance_.reset(new simgrid::mc::Client(fd)); // Wait for the model-checker: errno = 0; diff --git a/src/mc/remote/RemoteClient.cpp b/src/mc/remote/RemoteClient.cpp index 8766ad528d..9275ec5dd4 100644 --- a/src/mc/remote/RemoteClient.cpp +++ b/src/mc/remote/RemoteClient.cpp @@ -239,7 +239,7 @@ void RemoteClient::refresh_heap() { // Read/dereference/refresh the std_heap pointer: if (not this->heap) - this->heap = std::unique_ptr(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; } diff --git a/src/mc/sosp/PageStore_test.cpp b/src/mc/sosp/PageStore_test.cpp index b4f7ea9600..220065181d 100644 --- a/src/mc/sosp/PageStore_test.cpp +++ b/src/mc/sosp/PageStore_test.cpp @@ -49,7 +49,7 @@ int helper_tests::value = 0; void helper_tests::Init() { pagesize = (size_t)getpagesize(); - store = std::unique_ptr(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); } diff --git a/src/mc/sosp/mc_snapshot_test.cpp b/src/mc/sosp/mc_snapshot_test.cpp index 50cd1a209f..ef1591c8fa 100644 --- a/src/mc/sosp/mc_snapshot_test.cpp +++ b/src/mc/sosp/mc_snapshot_test.cpp @@ -66,7 +66,7 @@ void snap_test_helper::Init(bool sparse_ckpt) REQUIRE(xbt_pagesize == getpagesize()); REQUIRE(1 << xbt_pagebits == xbt_pagesize); - process = std::unique_ptr(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)); } diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 2686185031..9fe7ef1f54 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -199,7 +199,7 @@ void SIMIX_global_init(int *argc, char **argv) #endif if (simix_global == nullptr) { - simix_global = std::unique_ptr(new simgrid::simix::Global()); + simix_global.reset(new simgrid::simix::Global()); simix_global->maestro_process = nullptr; surf_init(argc, argv); /* Initialize SURF structures */ diff --git a/src/xbt/backtrace.cpp b/src/xbt/backtrace.cpp index c2ceee4268..837062a9a6 100644 --- a/src/xbt/backtrace.cpp +++ b/src/xbt/backtrace.cpp @@ -46,8 +46,8 @@ std::unique_ptr> demangle(const char* name) { #ifdef __GXX_ABI_VERSION int status; - auto res = std::unique_ptr>(abi::__cxa_demangle(name, nullptr, nullptr, &status), - &std::free); + std::unique_ptr> 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: