Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cleanup work to make is_race_reversible() a method of Transition
[simgrid.git] / examples / cpp / dag-from-dot / s4u-dag-from-dot.cpp
index ca994ac0d26ff887147559fcb7a53fd12be7e015..30d2b751d46222c51f719b64505873e6db549720 100644 (file)
@@ -1,6 +1,6 @@
 /* simple test trying to load a DOT file.                                   */
 
-/* Copyright (c) 2010-2022. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2023. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -44,14 +44,13 @@ int main(int argc, char** argv)
   static_cast<sg4::Exec*>(dag.back().get())->set_host(hosts[0]);
 
   for (const auto& a : dag) {
-    auto* exec = dynamic_cast<sg4::Exec*>(a.get());
-    if (exec != nullptr && exec->get_name() != "end") {
+    if (auto* exec = dynamic_cast<sg4::Exec*>(a.get()); exec != nullptr && exec->get_name() != "end") {
       exec->set_host(hosts[cursor % count]);
       cursor++;
     }
     if (auto* comm = dynamic_cast<sg4::Comm*>(a.get())) {
-      auto pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
-      auto succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
+      const auto* pred = dynamic_cast<sg4::Exec*>((*comm->get_dependencies().begin()).get());
+      const auto* succ = dynamic_cast<sg4::Exec*>(comm->get_successors().front().get());
       comm->set_source(pred->get_host())->set_destination(succ->get_host());
     }
   }