From f05d4e0b1657f5cbb15fa2932c7d4a194f3804d9 Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Tue, 8 Feb 2022 11:12:05 +0100 Subject: [PATCH] [sonar] constify --- MANIFEST.in | 1 + src/kernel/EngineImpl.cpp | 2 +- src/kernel/activity/ActivityImpl.cpp | 1 - src/kernel/actor/SimcallObserver.cpp | 34 ++++++++++++++-------------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index d000497031..4b721fce06 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2335,6 +2335,7 @@ include src/mc/ModelChecker.cpp include src/mc/ModelChecker.hpp include src/mc/Session.cpp include src/mc/Session.hpp +include src/mc/Transition.cpp include src/mc/Transition.hpp include src/mc/VisitedState.cpp include src/mc/VisitedState.hpp diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 16b2c4814d..4e872cf114 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -542,7 +542,7 @@ void EngineImpl::display_all_actor_status() const /* List the actors and their state */ XBT_INFO("Legend of the following listing: \"Actor (@): \""); for (auto const& kv : actor_list_) { - actor::ActorImpl* actor = kv.second; + const actor::ActorImpl* actor = kv.second; if (actor->waiting_synchro_) { const char* synchro_description = "unknown"; diff --git a/src/kernel/activity/ActivityImpl.cpp b/src/kernel/activity/ActivityImpl.cpp index ed1f237f69..22402f0ac7 100644 --- a/src/kernel/activity/ActivityImpl.cpp +++ b/src/kernel/activity/ActivityImpl.cpp @@ -219,7 +219,6 @@ void ActivityImpl::handle_activity_waitany(smx_simcall_t simcall) if (not MC_is_active() && not MC_record_replay_is_active()) { auto element = std::find(activities.begin(), activities.end(), this); int rank = element != activities.end() ? static_cast(std::distance(activities.begin(), element)) : -1; - auto* observer = dynamic_cast(simcall->observer_); observer->set_result(rank); } } diff --git a/src/kernel/actor/SimcallObserver.cpp b/src/kernel/actor/SimcallObserver.cpp index d6795b4db4..d0dfbd6546 100644 --- a/src/kernel/actor/SimcallObserver.cpp +++ b/src/kernel/actor/SimcallObserver.cpp @@ -203,7 +203,7 @@ bool ActivityTestSimcall::depends(SimcallObserver* other) if (dynamic_cast(other)) return true; - auto* comm1 = dynamic_cast(activity_); + const auto* comm1 = dynamic_cast(activity_); if (comm1 == nullptr) return false; @@ -214,8 +214,8 @@ bool ActivityTestSimcall::depends(SimcallObserver* other) if (comm1->src_buff_ == nullptr || comm1->dst_buff_ == nullptr) return false; - if (auto* test = dynamic_cast(other)) { - auto* comm2 = dynamic_cast(test->get_activity()); + if (const auto* test = dynamic_cast(other)) { + const auto* comm2 = dynamic_cast(test->get_activity()); if (comm2 == nullptr) return false; else if (comm2->src_buff_ == nullptr || comm2->dst_buff_ == nullptr) @@ -264,8 +264,8 @@ std::string ActivityTestSimcall::to_string(int times_considered) const std::string ActivityTestSimcall::dot_label(int times_considered) const { - std::string res = SimcallObserver::dot_label(times_considered) + "Test "; - auto* comm = dynamic_cast(activity_); + std::string res = SimcallObserver::dot_label(times_considered) + "Test "; + const auto* comm = dynamic_cast(activity_); if (comm && (comm->src_actor_.get() == nullptr || comm->dst_actor_.get() == nullptr)) { res += "FALSE"; } else { @@ -305,11 +305,11 @@ bool ActivityWaitSimcall::depends(SimcallObserver* other) return irecv->depends(this); /* Timeouts in wait transitions are not considered by the independence theorem, thus assumed dependent */ - if (auto* wait = dynamic_cast(other)) { + if (const auto* wait = dynamic_cast(other)) { if (timeout_ > 0 || wait->get_timeout() > 0) return true; - auto* comm1 = dynamic_cast(activity_); - auto* comm2 = dynamic_cast(wait->get_activity()); + const auto* comm1 = dynamic_cast(activity_); + const auto* comm2 = dynamic_cast(wait->get_activity()); if (comm1 == nullptr || comm2 == nullptr) // One wait at least in not on a Comm return true; @@ -356,7 +356,7 @@ std::string ActivityWaitSimcall::dot_label(int times_considered) const std::string res = SimcallObserver::dot_label(times_considered); res += (times_considered == -1) ? "WaitTimeout " : "Wait "; - auto* comm = dynamic_cast(activity_); + const auto* comm = dynamic_cast(activity_); if (comm) { auto src = comm->src_actor_; auto dst = comm->dst_actor_; @@ -424,7 +424,7 @@ bool CommIsendSimcall::depends(SimcallObserver* other) if (get_issuer() == other->get_issuer()) return false; - if (auto* other_isend = dynamic_cast(other)) + if (const auto* other_isend = dynamic_cast(other)) return mbox_ == other_isend->get_mailbox(); // FIXME: Not in the former dependency check because of the ordering but seems logical to add it @@ -432,10 +432,10 @@ bool CommIsendSimcall::depends(SimcallObserver* other) return false; #if SIMGRID_HAVE_MC // FIXME needed to access mbox_cpy - if (auto* wait = dynamic_cast(other)) { - if (auto* comm2 = dynamic_cast(wait->get_activity())) { // this is a Comm::wait_for - auto* mbox1 = mbox_; - auto* mbox2 = comm2->mbox_cpy; + if (const auto* wait = dynamic_cast(other)) { + if (const auto* comm2 = dynamic_cast(wait->get_activity())) { // this is a Comm::wait_for + const auto* mbox1 = mbox_; + const auto* mbox2 = comm2->mbox_cpy; if (mbox1 != mbox2 && wait->get_timeout() <= 0) return false; @@ -477,7 +477,7 @@ bool CommIrecvSimcall::depends(SimcallObserver* other) if (get_issuer() == other->get_issuer()) return false; - if (auto* other_irecv = dynamic_cast(other)) + if (const auto* other_irecv = dynamic_cast(other)) return mbox_ == other_irecv->get_mailbox(); if (auto* isend = dynamic_cast(other)) @@ -486,8 +486,8 @@ bool CommIrecvSimcall::depends(SimcallObserver* other) #if SIMGRID_HAVE_MC // FIXME needed to access mbox_cpy if (auto* wait = dynamic_cast(other)) { if (auto* comm2 = dynamic_cast(wait->get_activity())) { // this is a Comm::wait_for - auto* mbox1 = mbox_; - auto* mbox2 = comm2->mbox_cpy; + const auto* mbox1 = mbox_; + const auto* mbox2 = comm2->mbox_cpy; if (mbox1 != mbox2 && wait->get_timeout() <= 0) return false; -- 2.20.1