From ff2bf6c94637f28c0c219e9adc61a11e78be1900 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Wed, 1 Jun 2016 12:34:56 +0200 Subject: [PATCH] yet another bunch of critical --- .../msg/actions-storage/actions-storage.c | 2 +- examples/msg/app-chainsend/peer.c | 39 ++++++++----------- .../msg/app-masterworker/app-masterworker.c | 5 +-- .../cloud-masterworker/cloud-masterworker.c | 12 ++---- .../cloud-masterworker.tesh | 2 +- examples/msg/dht-kademlia/answer.c | 8 ++-- .../msg/trace-categories/trace-categories.c | 2 +- .../trace-host-user-variables.c | 4 +- .../trace-masterworker/trace-masterworker.c | 2 +- .../trace-process-migration.c | 5 ++- .../simdag/availability/sd_availability.c | 2 +- 11 files changed, 37 insertions(+), 46 deletions(-) diff --git a/examples/msg/actions-storage/actions-storage.c b/examples/msg/actions-storage/actions-storage.c index 76d399ae69..d975652270 100644 --- a/examples/msg/actions-storage/actions-storage.c +++ b/examples/msg/actions-storage/actions-storage.c @@ -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 diff --git a/examples/msg/app-chainsend/peer.c b/examples/msg/app-chainsend/peer.c index 433200e22a..70e7673bfb 100644 --- a/examples/msg/app-chainsend/peer.c +++ b/examples/msg/app-chainsend/peer.c @@ -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); diff --git a/examples/msg/app-masterworker/app-masterworker.c b/examples/msg/app-masterworker/app-masterworker.c index 899253db98..ee480f1280 100644 --- a/examples/msg/app-masterworker/app-masterworker.c +++ b/examples/msg/app-masterworker/app-masterworker.c @@ -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; } diff --git a/examples/msg/cloud-masterworker/cloud-masterworker.c b/examples/msg/cloud-masterworker/cloud-masterworker.c index a2ba395330..ab016267fb 100644 --- a/examples/msg/cloud-masterworker/cloud-masterworker.c +++ b/examples/msg/cloud-masterworker/cloud-masterworker.c @@ -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); diff --git a/examples/msg/cloud-masterworker/cloud-masterworker.tesh b/examples/msg/cloud-masterworker/cloud-masterworker.tesh index d4b71a5b48..94119926b0 100644 --- a/examples/msg/cloud-masterworker/cloud-masterworker.tesh +++ b/examples/msg/cloud-masterworker/cloud-masterworker.tesh @@ -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. diff --git a/examples/msg/dht-kademlia/answer.c b/examples/msg/dht-kademlia/answer.c index 5aa893ff62..ce1d586604 100644 --- a/examples/msg/dht-kademlia/answer.c +++ b/examples/msg/dht-kademlia/answer.c @@ -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"); diff --git a/examples/msg/trace-categories/trace-categories.c b/examples/msg/trace-categories/trace-categories.c index a33b4b5de0..43cfa5e932 100644 --- a/examples/msg/trace-categories/trace-categories.c +++ b/examples/msg/trace-categories/trace-categories.c @@ -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; } diff --git a/examples/msg/trace-host-user-variables/trace-host-user-variables.c b/examples/msg/trace-host-user-variables/trace-host-user-variables.c index f25f77b26b..82313df75a 100644 --- a/examples/msg/trace-host-user-variables/trace-host-user-variables.c +++ b/examples/msg/trace-host-user-variables/trace-host-user-variables.c @@ -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 = ("); diff --git a/examples/msg/trace-masterworker/trace-masterworker.c b/examples/msg/trace-masterworker/trace-masterworker.c index abe6badfa0..651d968a5d 100644 --- a/examples/msg/trace-masterworker/trace-masterworker.c +++ b/examples/msg/trace-masterworker/trace-masterworker.c @@ -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; } diff --git a/examples/msg/trace-process-migration/trace-process-migration.c b/examples/msg/trace-process-migration/trace-process-migration.c index fffb9c0e12..bf27730181 100644 --- a/examples/msg/trace-process-migration/trace-process-migration.c +++ b/examples/msg/trace-process-migration/trace-process-migration.c @@ -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"); diff --git a/examples/simdag/availability/sd_availability.c b/examples/simdag/availability/sd_availability.c index f966a04741..2371c56df6 100644 --- a/examples/simdag/availability/sd_availability.c +++ b/examples/simdag/availability/sd_availability.c @@ -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])); -- 2.20.1