From 9075ee30418590d5cfd216f7ae86e77dd7ebf936 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 16 Mar 2022 23:36:27 +0100 Subject: [PATCH 1/1] Fix spurious compilation warning. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit warning: ‘main’ may be used uninitialized in this function. --- .../monkey-masterworkers.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp b/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp index 183179a5f1..b6334cf3b3 100644 --- a/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp +++ b/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp @@ -102,25 +102,21 @@ int main(int argc, char* argv[]) sg4::Engine e(&argc, argv); auto* rootzone = sg4::create_full_zone("root"); - sg4::Host* main; // First host created, where the master will stay std::vector worker_hosts; xbt_assert(cfg_host_count > 2, "You need at least 2 workers (i.e., 3 hosts) or the master will be auto-killed when " "the only worker gets killed."); - for (int i = 0; i < cfg_host_count; i++) { + sg4::Host* master_host = rootzone->create_host("lilibeth 0", 1e9); // Host where the master will stay + for (int i = 1; i < cfg_host_count; i++) { auto hostname = std::string("lilibeth ") + std::to_string(i); auto* host = rootzone->create_host(hostname, 1e9); - if (i == 0) { - main = host; - } else { - sg4::LinkInRoute link(rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal()); - rootzone->add_route(main->get_netpoint(), host->get_netpoint(), nullptr, nullptr, {link}, true); - worker_hosts.push_back(host); - } + sg4::LinkInRoute link(rootzone->create_link(hostname, "1MBps")->set_latency("24us")->seal()); + rootzone->add_route(master_host->get_netpoint(), host->get_netpoint(), nullptr, nullptr, {link}, true); + worker_hosts.push_back(host); } rootzone->seal(); - sg4::Actor::create("master", main, master)->daemonize()->set_auto_restart(true); + sg4::Actor::create("master", master_host, master)->daemonize()->set_auto_restart(true); int id = 0; for (auto* h : worker_hosts) { sg4::Actor::create("worker", h, worker, id)->set_auto_restart(true); -- 2.20.1