Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics: reduce scope for variables.
[simgrid.git] / examples / s4u / platform-failures / s4u-platform-failures.cpp
index d2271b2..a8104a5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2007-2020. 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. */
@@ -22,7 +22,7 @@
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example");
 
-static int master(int argc, char* argv[])
+static void master(int argc, char* argv[])
 {
   xbt_assert(argc == 5, "Expecting one parameter");
 
@@ -67,22 +67,19 @@ static int master(int argc, char* argv[])
   }
 
   XBT_INFO("Goodbye now!");
-  return 0;
 }
 
-static int worker(int argc, char* argv[])
+static void worker(int argc, char* argv[])
 {
   xbt_assert(argc == 2, "Expecting one parameter");
   long id                          = xbt_str_parse_int(argv[1], "Invalid argument %s");
   simgrid::s4u::Mailbox* mailbox   = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id));
-  const double* payload            = nullptr;
-  double comp_size                 = -1;
   while (1) {
     try {
       XBT_INFO("Waiting a message on %s", mailbox->get_cname());
-      payload   = static_cast<double*>(mailbox->get());
+      const double* payload = static_cast<double*>(mailbox->get());
       xbt_assert(payload != nullptr, "mailbox->get() failed");
-      comp_size = *payload;
+      double comp_size = *payload;
       delete payload;
       if (comp_size < 0) { /* - Exit when -1.0 is received */
         XBT_INFO("I'm done. See you!");
@@ -96,7 +93,6 @@ static int worker(int argc, char* argv[])
       XBT_INFO("Mmh. Something went wrong. Nevermind. Let's keep going!");
     }
   }
-  return 0;
 }
 
 int main(int argc, char* argv[])