Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
greatly reduce the amount of atoi in our codebase
[simgrid.git] / examples / msg / pmm / msg_pmm.c
index 209cc33..f1e02aa 100644 (file)
@@ -1,6 +1,6 @@
 /* pmm - parallel matrix multiplication "double diffusion"                  */
 
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2015. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@ int node(int argc, char **argv)
   xbt_assert(argc != 1, "Wrong number of arguments for this node");
 
   /* Initialize the node's data-structures */
-  myid = atoi(argv[1]);
+  myid = xbt_str_parse_int(argv[1], "Invalid ID received as first node parameter: %s");
   snprintf(my_mbox, MAILBOX_NAME_SIZE - 1, "%d", myid);
   sC = xbt_matrix_double_new_zeros(NODE_MATRIX_SIZE, NODE_MATRIX_SIZE);
 
@@ -217,8 +217,8 @@ static node_job_t wait_job(int selfid)
   msg_error_t err;
   snprintf(self_mbox, MAILBOX_NAME_SIZE - 1, "%d", selfid);
   err = MSG_task_receive(&task, self_mbox);
-  if (err != MSG_OK)
-    xbt_die("Error while receiving from %s (%d)", self_mbox, (int)err);
+  xbt_assert(err == MSG_OK, "Error while receiving from %s (%d)",
+             self_mbox, (int)err);
   job = (node_job_t)MSG_task_get_data(task);
   MSG_task_destroy(task);
   XBT_VERB("Got Job (%d,%d)", job->row, job->col);
@@ -295,10 +295,7 @@ int main(int argc, char *argv[])
 #endif
   XBT_CRITICAL("Simulated time: %g", MSG_get_clock());
 
-  if (res == MSG_OK)
-    return 0;
-  else
-    return 1;
+  return res != MSG_OK;
 }
 
 static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs)