Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 2 Feb 2022 11:21:13 +0000 (12:21 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 8 Feb 2022 20:37:31 +0000 (21:37 +0100)
src/kernel/activity/ActivityImpl.cpp
src/kernel/actor/SimcallObserver.cpp

index 22402f0..2e1de24 100644 (file)
@@ -111,8 +111,7 @@ void ActivityImpl::wait_for(actor::ActorImpl* issuer, double timeout)
   } else {
     /* we need a sleep action (even when the timeout is infinite) to be notified of host failures */
     /* Comms handle that a bit differently of the other activities */
-    auto* comm = dynamic_cast<CommImpl*>(this);
-    if (comm != nullptr) {
+    if (auto* comm = dynamic_cast<CommImpl*>(this)) {
       resource::Action* sleep = issuer->get_host()->get_cpu()->sleep(timeout);
       sleep->set_activity(comm);
 
index d0dfbd6..a2df655 100644 (file)
@@ -240,8 +240,7 @@ bool ActivityTestSimcall::depends(SimcallObserver* other)
 std::string ActivityTestSimcall::to_string(int times_considered) const
 {
   std::string res = SimcallObserver::to_string(times_considered) + "Test ";
-  auto* comm      = dynamic_cast<activity::CommImpl*>(activity_);
-  if (comm) {
+  if (const auto* comm = dynamic_cast<activity::CommImpl*>(activity_)) {
     if (comm->src_actor_.get() == nullptr || comm->dst_actor_.get() == nullptr) {
       res += "FALSE(comm=";
       res += XBT_LOG_ISENABLED(mc_observer, xbt_log_priority_verbose) ? xbt::string_printf("%p)", comm)