X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b9625f82f86db0674e911887addce45dca31b57f..1363ce9624f4327f3ad5c934b15736a776637dfd:/examples/c/comm-waitany/comm-waitany.c diff --git a/examples/c/comm-waitany/comm-waitany.c b/examples/c/comm-waitany/comm-waitany.c index 9dd47e8503..03504d8037 100644 --- a/examples/c/comm-waitany/comm-waitany.c +++ b/examples/c/comm-waitany/comm-waitany.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2023. 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. */ @@ -8,9 +8,9 @@ #include "simgrid/engine.h" #include "simgrid/forward.h" #include "simgrid/mailbox.h" -#include "xbt/asserts.h" #include "xbt/log.h" #include "xbt/str.h" +#include "xbt/sysdep.h" #include /* snprintf */ @@ -19,9 +19,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(comm_waitany, "Messages specific for this example") static void sender(int argc, char* argv[]) { xbt_assert(argc == 4, "Expecting 3 parameters from the XML deployment file but got %d", argc); - long messages_count = xbt_str_parse_int(argv[1], "Invalid message count: %s"); - long msg_size = xbt_str_parse_int(argv[2], "Invalid message size: %s"); - long receivers_count = xbt_str_parse_int(argv[3], "Invalid amount of receivers: %s"); + long messages_count = xbt_str_parse_int(argv[1], "Invalid message count"); + long msg_size = xbt_str_parse_int(argv[2], "Invalid message size"); + long receivers_count = xbt_str_parse_int(argv[3], "Invalid amount of receivers"); xbt_assert(receivers_count > 0); /* Array in which we store all ongoing communications */ @@ -64,18 +64,18 @@ static void sender(int argc, char* argv[]) * Even in this simple example, the pending comms do not terminate in the exact same order of creation. */ while (pending_comms_count != 0) { - int changed_pos = sg_comm_wait_any(pending_comms, pending_comms_count); + ssize_t changed_pos = sg_comm_wait_any(pending_comms, pending_comms_count); memmove(pending_comms + changed_pos, pending_comms + changed_pos + 1, sizeof(sg_comm_t) * (pending_comms_count - changed_pos - 1)); pending_comms_count--; if (changed_pos != 0) - XBT_INFO("Remove the %dth pending comm: it terminated earlier than another comm that was initiated first.", + XBT_INFO("Remove the %zdth pending comm: it terminated earlier than another comm that was initiated first.", changed_pos); } - free(pending_comms); - free(mboxes); + xbt_free(pending_comms); + xbt_free(mboxes); XBT_INFO("Goodbye now!"); } @@ -83,7 +83,7 @@ static void sender(int argc, char* argv[]) static void receiver(int argc, char* argv[]) { xbt_assert(argc == 2, "Expecting one parameter from the XML deployment file but got %d", argc); - int id = (int)xbt_str_parse_int(argv[1], "ID should be numerical, not %s"); + int id = (int)xbt_str_parse_int(argv[1], "ID should be numerical"); char mailbox_name[80]; snprintf(mailbox_name, 79, "receiver-%d", id); sg_mailbox_t mbox = sg_mailbox_by_name(mailbox_name); @@ -106,7 +106,7 @@ int main(int argc, char* argv[]) simgrid_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" - "\tExample: %s msg_platform.xml msg_deployment.xml\n", + "\tExample: %s platform.xml deployment.xml\n", argv[0], argv[0]); simgrid_load_platform(argv[1]);