Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
yet another bunch of critical
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 1 Jun 2016 10:34:56 +0000 (12:34 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 1 Jun 2016 10:34:56 +0000 (12:34 +0200)
examples/msg/actions-storage/actions-storage.c
examples/msg/app-chainsend/peer.c
examples/msg/app-masterworker/app-masterworker.c
examples/msg/cloud-masterworker/cloud-masterworker.c
examples/msg/cloud-masterworker/cloud-masterworker.tesh
examples/msg/dht-kademlia/answer.c
examples/msg/trace-categories/trace-categories.c
examples/msg/trace-host-user-variables/trace-host-user-variables.c
examples/msg/trace-masterworker/trace-masterworker.c
examples/msg/trace-process-migration/trace-process-migration.c
examples/simdag/availability/sd_availability.c

index 76d399a..d975652 100644 (file)
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
   xbt_replay_action_register("read", action_read);
   xbt_replay_action_register("close", action_close);
 
-  if (!opened_files)
+  if (opened_files == NULL)
     opened_files = xbt_dict_new_homogeneous(NULL);
   /* Actually do the simulation using MSG_action_trace_run */
   res = MSG_action_trace_run(argv[3]);  // it's ok to pass a NULL argument here
index 433200e..70e7673 100644 (file)
@@ -31,21 +31,18 @@ int peer_execute_task(peer_t peer, msg_task_t task)
   message_t msg = MSG_task_get_data(task);
   
   XBT_DEBUG("Peer %s got message of type %d\n", peer->me, msg->type);
-  switch (msg->type) {
-    case MESSAGE_BUILD_CHAIN:
-      peer_init_chain(peer, msg);
-      break;
-    case MESSAGE_SEND_DATA:
-      xbt_assert(peer->init, "peer_execute_task() failed: got msg_type %d before initialization", msg->type);
-      if (peer->next != NULL)
-        peer_forward_msg(peer, msg);
-      peer->pieces++;
-      peer->bytes += msg->data_length;
-      if (peer->pieces >= peer->total_pieces) {
-        XBT_DEBUG("%d pieces receieved", peer->pieces);
-        done = 1;
-      }
-      break;
+  if (msg->type == MESSAGE_BUILD_CHAIN)
+    peer_init_chain(peer, msg);
+  if (msg->type == MESSAGE_SEND_DATA){
+    xbt_assert(peer->init, "peer_execute_task() failed: got msg_type %d before initialization", msg->type);
+    if (peer->next != NULL)
+      peer_forward_msg(peer, msg);
+    peer->pieces++;
+    peer->bytes += msg->data_length;
+    if (peer->pieces >= peer->total_pieces) {
+      XBT_DEBUG("%d pieces receieved", peer->pieces);
+      done = 1;
+    }
   }
 
   MSG_task_execute(task);
@@ -58,14 +55,13 @@ msg_error_t peer_wait_for_message(peer_t peer)
   msg_error_t status;
   msg_comm_t comm = NULL;
   msg_task_t task = NULL;
-  int idx = -1;
   int done = 0;
 
-  while (!done) {
+  while (done == 0) {
     comm = MSG_task_irecv(&task, peer->me);
     queue_pending_connection(comm, peer->pending_recvs);
-
-    if ((idx = MSG_comm_waitany(peer->pending_recvs)) != -1) {
+    int idx = MSG_comm_waitany(peer->pending_recvs);
+    if (idx != -1) {
       comm = xbt_dynar_get_as(peer->pending_recvs, idx, msg_comm_t);
       status = MSG_comm_get_status(comm);
       XBT_DEBUG("peer_wait_for_message: error code = %d", status);
@@ -141,17 +137,16 @@ void peer_print_stats(peer_t p, float elapsed_time)
 /** Peer function  */
 int peer(int argc, char *argv[])
 {
-  float start_time, end_time;
   peer_t p = xbt_new(s_peer_t, 1);
   msg_error_t status;
 
   XBT_DEBUG("peer");
 
   peer_init(p, argc, argv);
-  start_time = MSG_get_clock();
+  float start_time = MSG_get_clock();
   status = peer_wait_for_message(p);
   peer_shutdown(p);
-  end_time = MSG_get_clock();
+  float end_time = MSG_get_clock();
   peer_print_stats(p, end_time - start_time);
   peer_delete(p);
 
index 899253d..ee480f1 100644 (file)
@@ -59,14 +59,11 @@ static int worker(int argc, char *argv[])
     int res = MSG_task_receive(&(task), mailbox);
     xbt_assert(res == MSG_OK, "MSG_task_get failed");
 
-//  XBT_INFO("Received \"%s\"", MSG_task_get_name(task));
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);  /* - Exit if 'finalize' is received */
       break;
     }
-//    XBT_INFO("Processing \"%s\"", MSG_task_get_name(task));
     MSG_task_execute(task);    /*  - Otherwise, process the task */
-//    XBT_INFO("\"%s\" done", MSG_task_get_name(task));
     MSG_task_destroy(task);
     task = NULL;
   }
index a2ba395..ab01626 100644 (file)
@@ -47,14 +47,11 @@ static int worker_fun(int argc, char *argv[])
     msg_task_t task = NULL;
 
     msg_error_t res = MSG_task_receive(&task, mbox);
-    if (res != MSG_OK) {
-      XBT_CRITICAL("MSG_task_get failed");
-      DIE_IMPOSSIBLE;
-    }
+    xbt_assert(res == MSG_OK, "MSG_task_get failed");
 
     XBT_INFO("%s received task(%s) from mailbox(%s)", pr_name, MSG_task_get_name(task), mbox);
 
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);
       break;
     }
@@ -108,8 +105,7 @@ static int master_fun(int argc, char *argv[])
 
   XBT_INFO("# Suspend all VMs");
   xbt_dynar_foreach(vms, i, vm) {
-    const char *vm_name = MSG_host_get_name(vm);
-    XBT_INFO("suspend %s", vm_name);
+    XBT_INFO("suspend %s", MSG_host_get_name(vm));
     MSG_vm_suspend(vm);
   }
 
@@ -153,7 +149,7 @@ static int master_fun(int argc, char *argv[])
     MSG_vm_migrate(vm, worker_pm1);
   }
 
-  XBT_INFO("# Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed.");
+  XBT_INFO("# Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.");
   for (i = 0; i < nb_workers; i++) {
     char mbox[MAXMBOXLEN];
     snprintf(mbox, MAXMBOXLEN, "MBOX:WRK%02d", i);
index d4b71a5..9411992 100644 (file)
@@ -47,7 +47,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/cloud-masterworker$EXEEXT --log=no_loc ${srcdir:=.
 > [Jacquelin:master:(1) 3567.161124] [msg_test/INFO] # Migrate all VMs to PM(Provost)
 > [Intel:__pr_mig_tx:VM00(Intel-Provost):(11) 3567.161124] [msg_vm/WARNING] use the default max_downtime value 30ms
 > [Intel:__pr_mig_tx:VM01(Intel-Provost):(13) 6034.900487] [msg_vm/WARNING] use the default max_downtime value 30ms
-> [Jacquelin:master:(1) 8502.639850] [msg_test/INFO] # Shutdown the half of worker processes gracefuly. The remaining half will be forcibly killed.
+> [Jacquelin:master:(1) 8502.639850] [msg_test/INFO] # Shutdown the half of worker processes gracefully. The remaining half will be forcibly killed.
 > [VM00:WRK00:(2) 8504.519504] [msg_test/INFO] WRK00 received task(finalize) from mailbox(MBOX:WRK00)
 > [VM01:WRK01:(3) 8506.399157] [msg_test/INFO] WRK01 received task(finalize) from mailbox(MBOX:WRK01)
 > [Jacquelin:master:(1) 8506.399157] [msg_test/INFO] # Wait a while before effective shutdown.
index 5aa893f..ce1d586 100644 (file)
@@ -47,12 +47,13 @@ void answer_print(answer_t answer)
   */
 unsigned int answer_merge(answer_t destination, answer_t source)
 {
-  node_contact_t contact, contact_copy;
+  node_contact_t contact;
+  node_contact_t contact_copy;
   unsigned int cpt;
   unsigned int nb_added = 0;
   /* TODO: Check if same destination */
   xbt_dynar_foreach(source->nodes, cpt, contact) {
-    if (!answer_contains(destination, contact->id)) {
+    if (answer_contains(destination, contact->id) == 0) {
       contact_copy = node_contact_copy(contact);
       xbt_dynar_push(destination->nodes, &contact_copy);
       destination->size++;
@@ -109,7 +110,8 @@ void answer_trim(answer_t answer)
 void answer_add_bucket(bucket_t bucket, answer_t answer)
 {
   unsigned int cpt;
-  unsigned int id, distance;
+  unsigned int id;
+  unsigned int distance;
   node_contact_t contact;
   xbt_assert((bucket != NULL), "Provided a NULL bucket");
   xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
index a33b4b5..43cfa5e 100644 (file)
@@ -43,7 +43,7 @@ static int worker(int argc, char *argv[])
   while (1) {
     MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);
       break;
     }
index f25f77b..82313df 100644 (file)
@@ -78,9 +78,9 @@ int main(int argc, char *argv[])
   }
 
   //create a customized viva graph configuration file
-  FILE *fp;
+  FILE *fp = NULL;
   fp = fopen ("viva_graph.plist", "w");
-  if (!fp){
+  if (fp == NULL){
     return 1;
   }
   fprintf (fp, "{\n node = (");
index abe6bad..651d968 100644 (file)
@@ -50,7 +50,7 @@ static int worker(int argc, char *argv[])
   while (1) {
     MSG_task_receive(&(task), "master_mailbox");
 
-    if (!strcmp(MSG_task_get_name(task), "finalize")) {
+    if (strcmp(MSG_task_get_name(task), "finalize") == 0) {
       MSG_task_destroy(task);
       break;
     }
index fffb9c0..bf27730 100644 (file)
@@ -17,7 +17,8 @@ static int emigrant(int argc, char *argv[])
     MSG_task_receive(&(task), "master_mailbox");
     destination = (char*)MSG_task_get_data (task);
     MSG_task_destroy (task);
-    if (!destination) break; //there is no destination, die
+    if (destination == NULL)
+      break; //there is no destination, die
     MSG_process_migrate(MSG_process_self(), MSG_host_by_name(destination));
     MSG_process_sleep(2); // I am tired, have to sleep for 2 seconds
     free (destination);
@@ -47,7 +48,7 @@ static int policeman(int argc, char *argv[])
   unsigned int i;
   xbt_dynar_foreach(destinations, i, destination){
     task = MSG_task_create("task", 0, 0, NULL);
-    if (destination){
+    if (destination != NULL){
       MSG_task_set_data(task, xbt_strdup (destination));
     }
     MSG_task_set_category(task, "migration_order");
index f966a04..2371c56 100644 (file)
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
   SD_task_watch(c3, SD_DONE);
   SD_task_watch(t4, SD_DONE);
 
-  while (!xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0)))) {
+  while (xbt_dynar_is_empty((changed_tasks = SD_simulate(-1.0))) == 0) {
     XBT_INFO("link1: bw=%.0f, lat=%f", SD_route_get_bandwidth(hosts[0], hosts[1]),
              SD_route_get_latency(hosts[0], hosts[1]));
     XBT_INFO("Jupiter: speed=%.0f", sg_host_speed(hosts[0])* sg_host_get_available_speed(hosts[0]));