From c25a26b26202c93dc2bfa44d214b8f804b78b8b3 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 25 Feb 2019 15:16:32 +0100 Subject: [PATCH] do not promote bad practices: use "accessor" to get task name --- .../msg/app-masterworker/app-masterworker.c | 2 +- .../masterslave_mailbox_smpi.c | 2 +- teshsuite/msg/app-pingpong/app-pingpong.c | 4 ++-- teshsuite/msg/app-token-ring/app-token-ring.c | 4 ++-- teshsuite/msg/host_on_off/host_on_off.c | 10 +++++----- .../host_on_off_processes.cpp | 2 +- .../task_destroy_cancel/task_destroy_cancel.cpp | 16 ++++++++-------- teshsuite/msg/task_progress/task_progress.cpp | 14 +++++++------- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/deprecated/msg/app-masterworker/app-masterworker.c b/examples/deprecated/msg/app-masterworker/app-masterworker.c index e6190894aa..6100fb337e 100644 --- a/examples/deprecated/msg/app-masterworker/app-masterworker.c +++ b/examples/deprecated/msg/app-masterworker/app-masterworker.c @@ -28,7 +28,7 @@ static int master(int argc, char *argv[]) snprintf(task_name,79, "Task_%d", i); msg_task_t task = MSG_task_create(task_name, comp_size, comm_size, NULL); /* - Create a task */ if (number_of_tasks < 10000 || i % 10000 == 0) - XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox); + XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", MSG_task_get_name(task), number_of_tasks, mailbox); MSG_task_send(task, mailbox); /* - Send the task to the @ref worker */ } diff --git a/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c b/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c index c0562ea498..1fe801ae11 100644 --- a/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c +++ b/examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c @@ -27,7 +27,7 @@ static int master(int argc, char *argv[]) snprintf(sprintf_buffer,256, "Task_%d", i); msg_task_t task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL); if (number_of_tasks < 10000 || i % 10000 == 0) - XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox); + XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", MSG_task_get_name(task), number_of_tasks, mailbox); MSG_task_send(task, mailbox); } diff --git a/teshsuite/msg/app-pingpong/app-pingpong.c b/teshsuite/msg/app-pingpong/app-pingpong.c index 49fe3653cd..265c15f804 100644 --- a/teshsuite/msg/app-pingpong/app-pingpong.c +++ b/teshsuite/msg/app-pingpong/app-pingpong.c @@ -29,7 +29,7 @@ static int pinger(int argc, char* argv[]) double sender_time = *((double*)(pong_task->data)); double communication_time = MSG_get_clock() - sender_time; - XBT_INFO("Task received : %s", pong_task->name); + XBT_INFO("Task received : %s", MSG_task_get_name(pong_task)); xbt_free(pong_task->data); MSG_task_destroy(pong_task); XBT_INFO("Pong time (bandwidth bound): %.3f", communication_time); @@ -50,7 +50,7 @@ static int ponger(int argc, char* argv[]) double sender_time = *((double*)(ping_task->data)); double communication_time = MSG_get_clock() - sender_time; - XBT_INFO("Task received : %s", ping_task->name); + XBT_INFO("Task received : %s", MSG_task_get_name(ping_task)); xbt_free(ping_task->data); MSG_task_destroy(ping_task); XBT_INFO(" Ping time (latency bound) %f", communication_time); diff --git a/teshsuite/msg/app-token-ring/app-token-ring.c b/teshsuite/msg/app-token-ring/app-token-ring.c index d10112d54a..3c585b2688 100644 --- a/teshsuite/msg/app-token-ring/app-token-ring.c +++ b/teshsuite/msg/app-token-ring/app-token-ring.c @@ -22,7 +22,7 @@ static int relay_runner(int argc, char* argv[]) snprintf(mailbox, 255, "%d", rank + 1); unsigned int task_comm_size = 1000000; /* The token is 1MB long*/ msg_task_t task = MSG_task_create("Token", 0, task_comm_size, NULL); - XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name, mailbox); + XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox); MSG_task_send(task, mailbox); task = NULL; int res = MSG_task_receive(&task, MSG_process_get_name(MSG_process_self())); @@ -42,7 +42,7 @@ static int relay_runner(int argc, char* argv[]) snprintf(mailbox, 255, "0"); else snprintf(mailbox, 255, "%d", rank + 1); - XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, task->name, mailbox); + XBT_INFO("Host \"%d\" send '%s' to Host \"%s\"", rank, MSG_task_get_name(task), mailbox); MSG_task_send(task, mailbox); } return 0; diff --git a/teshsuite/msg/host_on_off/host_on_off.c b/teshsuite/msg/host_on_off/host_on_off.c index b91077b85d..db526a4302 100644 --- a/teshsuite/msg/host_on_off/host_on_off.c +++ b/teshsuite/msg/host_on_off/host_on_off.c @@ -47,7 +47,7 @@ static int master(int argc, char *argv[]) msg_host_t jupiter = MSG_host_by_name("Jupiter"); msg_task_t task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL); - XBT_INFO("Sending \"%s\"", task->name); + XBT_INFO("Sending \"%s\"", MSG_task_get_name(task)); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); @@ -55,7 +55,7 @@ static int master(int argc, char *argv[]) MSG_host_off(jupiter); task = MSG_task_create("task off", task_comp_size, task_comm_size, NULL); - XBT_INFO("Sending \"%s\"", task->name); + XBT_INFO("Sending \"%s\"", MSG_task_get_name(task)); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); @@ -71,7 +71,7 @@ static int master(int argc, char *argv[]) xbt_dynar_free(&jupi_processes); task = MSG_task_create("task on without proc", task_comp_size, task_comm_size, NULL); - XBT_INFO("Sending \"%s\"", task->name); + XBT_INFO("Sending \"%s\"", MSG_task_get_name(task)); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); @@ -80,12 +80,12 @@ static int master(int argc, char *argv[]) MSG_process_create_with_arguments("slave", slave, NULL, MSG_host_by_name("Jupiter"), 1, argvF); task = MSG_task_create("task on with proc", task_comp_size, task_comm_size, NULL); - XBT_INFO("Sending \"%s\"", task->name); + XBT_INFO("Sending \"%s\"", MSG_task_get_name(task)); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); task = MSG_task_create("finalize", 0, 0, 0); - XBT_INFO("Sending \"%s\"", task->name); + XBT_INFO("Sending \"%s\"", MSG_task_get_name(task)); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp index fe7a2f23ec..eb6b46359e 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.cpp @@ -61,7 +61,7 @@ static int commRX(int /*argc*/, char** /*argv*/) XBT_INFO(" Start RX"); msg_error_t error = MSG_task_receive(&(task), mailbox); if (error == MSG_OK) { - XBT_INFO(" Receive message: %s", task->name); + XBT_INFO(" Receive message: %s", MSG_task_get_name(task)); MSG_task_destroy(task); } else if (error == MSG_HOST_FAILURE) { XBT_INFO(" Receive message: HOST_FAILURE"); diff --git a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp index ed572286ae..e8e2aedd6f 100644 --- a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp +++ b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.cpp @@ -15,21 +15,21 @@ static int master(int /*argc*/, char* /*argv*/ []) double timeout = 1; msg_task_t task = MSG_task_create("normal", task_comp_size, task_comm_size, NULL); - XBT_INFO("Sending task: \"%s\"", task->name); + XBT_INFO("Sending task: \"%s\"", MSG_task_get_name(task)); MSG_task_send_with_timeout(task, "worker_mailbox", timeout); task = MSG_task_create("cancel directly", task_comp_size, task_comm_size, NULL); - XBT_INFO("Canceling task \"%s\" directly", task->name); + XBT_INFO("Canceling task \"%s\" directly", MSG_task_get_name(task)); MSG_task_cancel(task); MSG_task_destroy(task); task = MSG_task_create("destroy directly", task_comp_size, task_comm_size, NULL); - XBT_INFO("Destroying task \"%s\" directly", task->name); + XBT_INFO("Destroying task \"%s\" directly", MSG_task_get_name(task)); MSG_task_destroy(task); task = MSG_task_create("cancel", task_comp_size, task_comm_size, NULL); msg_comm_t comm = MSG_task_isend(task, "worker_mailbox"); - XBT_INFO("Canceling task \"%s\" during comm", task->name); + XBT_INFO("Canceling task \"%s\" during comm", MSG_task_get_name(task)); MSG_task_cancel(task); if (MSG_comm_wait(comm, -1) != MSG_OK) MSG_comm_destroy(comm); @@ -37,7 +37,7 @@ static int master(int /*argc*/, char* /*argv*/ []) task = MSG_task_create("finalize", task_comp_size, task_comm_size, NULL); comm = MSG_task_isend(task, "worker_mailbox"); - XBT_INFO("Destroying task \"%s\" during comm", task->name); + XBT_INFO("Destroying task \"%s\" during comm", MSG_task_get_name(task)); MSG_task_destroy(task); if (MSG_comm_wait(comm, -1) != MSG_OK) MSG_comm_destroy(comm); @@ -56,7 +56,7 @@ static int worker_main(int /*argc*/, char* /*argv*/ []) { msg_task_t task = (msg_task_t) MSG_process_get_data(MSG_process_self()); msg_error_t res; - XBT_INFO("Start %s", task->name); + XBT_INFO("Start %s", MSG_task_get_name(task)); res = MSG_task_execute(task); XBT_INFO("Task %s", res == MSG_OK ? "done" : "failed"); MSG_task_destroy(task); @@ -72,7 +72,7 @@ static int worker(int /*argc*/, char* /*argv*/ []) XBT_INFO("Handling task \"%s\"", MSG_task_get_name(task)); if (not strcmp(MSG_task_get_name(task), "finalize")) { - XBT_INFO("Destroying task \"%s\"", task->name); + XBT_INFO("Destroying task \"%s\"", MSG_task_get_name(task)); MSG_task_destroy(task); break; } @@ -80,7 +80,7 @@ static int worker(int /*argc*/, char* /*argv*/ []) if (not strcmp(MSG_task_get_name(task), "cancel")) { MSG_process_create("worker1", worker_main, task, MSG_host_self()); MSG_process_sleep(0.1); - XBT_INFO("Canceling task \"%s\"", task->name); + XBT_INFO("Canceling task \"%s\"", MSG_task_get_name(task)); MSG_task_cancel(task); continue; } diff --git a/teshsuite/msg/task_progress/task_progress.cpp b/teshsuite/msg/task_progress/task_progress.cpp index dc467feb89..65810c24c0 100644 --- a/teshsuite/msg/task_progress/task_progress.cpp +++ b/teshsuite/msg/task_progress/task_progress.cpp @@ -19,14 +19,14 @@ static int seq_task(int /*argc*/, char* /*argv*/ []) msg_task_t task = MSG_task_create("simple", task_comp_size, task_comm_size, NULL); tasks.push_back(task); - XBT_INFO("get the progress of %s before the task starts", task->name); + XBT_INFO("get the progress of %s before the task starts", MSG_task_get_name(task)); progress = MSG_task_get_remaining_work_ratio(task); xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress); - XBT_INFO("Executing task: \"%s\"", task->name); + XBT_INFO("Executing task: \"%s\"", MSG_task_get_name(task)); MSG_task_execute(task); - XBT_INFO("get the progress of %s after the task finishes", task->name); + XBT_INFO("get the progress of %s after the task finishes", MSG_task_get_name(task)); progress = MSG_task_get_remaining_work_ratio(task); xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress); @@ -48,14 +48,14 @@ static int par_task(int /*argc*/, char* /*argv*/ []) msg_task_t task = MSG_parallel_task_create("ptask", 2, hosts_to_use.data(), computation_amount, communication_amount, NULL); tasks.push_back(task); - XBT_INFO("get the progress of %s before the task starts", task->name); + XBT_INFO("get the progress of %s before the task starts", MSG_task_get_name(task)); progress = MSG_task_get_remaining_work_ratio(task); xbt_assert(progress == 1.0, "Progress should be 1.0 not %f", progress); - XBT_INFO("Executing task: \"%s\"", task->name); + XBT_INFO("Executing task: \"%s\"", MSG_task_get_name(task)); MSG_parallel_task_execute(task); - XBT_INFO("get the progress of %s after the task finishes", task->name); + XBT_INFO("get the progress of %s after the task finishes", MSG_task_get_name(task)); progress = MSG_task_get_remaining_work_ratio(task); xbt_assert(progress == 0.0, "Progress should be equal to 0.0 not %f", progress); @@ -80,7 +80,7 @@ static int get_progress(int /*argc*/, char* /*argv*/ []) progress = MSG_task_get_remaining_work_ratio(task); xbt_assert(progress >= 0 and progress < 1, "Progress should be in [0, 1[, and not %f", progress); xbt_assert(progress < progress_prev, "Progress should decrease, not increase"); - XBT_INFO("Progress of \"%s\": %f", task->name, progress); + XBT_INFO("Progress of \"%s\": %f", MSG_task_get_name(task), progress); progress_prev = progress; } } -- 2.20.1