Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into fix/execute_benched
[simgrid.git] / examples / msg / app-chainsend / broadcaster.c
index f17ed64..23c4484 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. 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. */
@@ -80,6 +79,7 @@ broadcaster_t broadcaster_init(xbt_dynar_t host_list, unsigned int piece_count)
   int status;
   broadcaster_t bc = xbt_new(s_broadcaster_t, 1);
 
+  bc->first             = NULL;
   bc->piece_count = piece_count;
   bc->current_piece = 0;
   bc->host_list = host_list;
@@ -105,27 +105,24 @@ static void broadcaster_destroy(broadcaster_t bc)
 /** Emitter function  */
 int broadcaster(int argc, char *argv[])
 {
-  broadcaster_t bc = NULL;
-  xbt_dynar_t host_list = NULL;
-  int status;
   unsigned int piece_count = PIECE_COUNT;
 
   XBT_DEBUG("broadcaster");
 
   /* Add every mailbox given by the hostcount in argv[1] to a dynamic array */
-  host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
+  xbt_dynar_t host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s"));
 
   /* argv[2] is the number of pieces */
   if (argc > 2) {
     piece_count = xbt_str_parse_int(argv[2], "Invalid number of pieces: %s");
-    XBT_DEBUG("piece_count set to %d", piece_count);
+    XBT_DEBUG("piece_count set to %u", piece_count);
   } else {
-    XBT_DEBUG("No piece_count specified, defaulting to %d", piece_count);
+    XBT_DEBUG("No piece_count specified, defaulting to %u", piece_count);
   }
-  bc = broadcaster_init(host_list, piece_count);
+  broadcaster_t bc = broadcaster_init(host_list, piece_count);
 
   /* TODO: Error checking */
-  status = broadcaster_send_file(bc);
+  int status = broadcaster_send_file(bc);
 
   broadcaster_destroy(bc);