Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Get rid of "%s" in second argument of function xbt_str_parse_*.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 2 Jun 2021 09:05:48 +0000 (11:05 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 2 Jun 2021 09:37:14 +0000 (11:37 +0200)
19 files changed:
examples/c/actor-yield/actor-yield.c
examples/c/app-bittorrent/bittorrent-peer.c
examples/c/app-bittorrent/tracker.c
examples/c/app-chainsend/broadcaster.c
examples/c/app-masterworker/app-masterworker.c
examples/c/app-token-ring/app-token-ring.c
examples/c/cloud-capping/cloud-capping.c
examples/c/comm-wait/comm-wait.c
examples/c/comm-waitall/comm-waitall.c
examples/c/comm-waitany/comm-waitany.c
examples/c/dht-pastry/dht-pastry.c
examples/c/platform-failures/platform-failures.c
examples/c/synchro-semaphore/synchro-semaphore.c
examples/cpp/dht-chord/s4u-dht-chord.cpp
examples/smpi/replay_multiple/replay_multiple.cpp
src/mc/remote/AppSide.cpp
src/plugins/host_energy.cpp
src/smpi/internals/smpi_replay.cpp
src/xbt/xbt_str.cpp

index 4420cd6..b105514 100644 (file)
@@ -25,7 +25,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(actor_yield, "Messages specific for this example");
 static void yielder(int argc, char* argv[])
 {
   xbt_assert(argc == 2, "The sender function expects 1 arguments from the XML deployment file");
-  long number_of_yields = xbt_str_parse_int(argv[1], "Invalid amount of yields: %s"); /* - number of yields */
+  long number_of_yields = xbt_str_parse_int(argv[1], "Invalid amount of yields");
 
   for (int i = 0; i < number_of_yields; i++)
     sg_actor_yield();
index 8b00e05..32f66ab 100644 (file)
@@ -83,10 +83,10 @@ void peer(int argc, char* argv[])
   xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments");
 
   // Build peer object
-  peer_t peer = peer_init((int)xbt_str_parse_int(argv[1], "Invalid ID: %s"), argc == 4 ? 1 : 0);
+  peer_t peer = peer_init((int)xbt_str_parse_int(argv[1], "Invalid ID"), argc == 4 ? 1 : 0);
 
   // Retrieve deadline
-  peer->deadline = xbt_str_parse_double(argv[2], "Invalid deadline: %s");
+  peer->deadline = xbt_str_parse_double(argv[2], "Invalid deadline");
   xbt_assert(peer->deadline > 0, "Wrong deadline supplied");
 
   char* status = xbt_malloc0(FILE_PIECES + 1);
index 48f2d5a..340ac61 100644 (file)
@@ -30,7 +30,7 @@ void tracker(int argc, char* argv[])
   // Checking arguments
   xbt_assert(argc == 2, "Wrong number of arguments for the tracker.");
   // Retrieving end time
-  double deadline = xbt_str_parse_double(argv[1], "Invalid deadline: %s");
+  double deadline = xbt_str_parse_double(argv[1], "Invalid deadline");
   xbt_assert(deadline > 0, "Wrong deadline supplied");
 
   // Building peers array
index 8c88dca..801df69 100644 (file)
@@ -75,7 +75,7 @@ void broadcaster(int argc, char* argv[])
 {
   XBT_DEBUG("broadcaster");
   xbt_assert(argc > 2);
-  unsigned int host_count = (unsigned int)xbt_str_parse_int(argv[1], "Invalid number of peers: %s");
+  unsigned int host_count = (unsigned int)xbt_str_parse_int(argv[1], "Invalid number of peers");
 
   sg_mailbox_t* mailboxes = xbt_malloc(sizeof(sg_mailbox_t) * host_count);
 
@@ -86,7 +86,7 @@ void broadcaster(int argc, char* argv[])
     free(name);
   }
 
-  unsigned int piece_count = (unsigned int)xbt_str_parse_int(argv[2], "Invalid number of pieces: %s");
+  unsigned int piece_count = (unsigned int)xbt_str_parse_int(argv[2], "Invalid number of pieces");
 
   broadcaster_t bc = broadcaster_init(mailboxes, host_count, piece_count);
 
index a7df2d8..c81825a 100644 (file)
@@ -21,10 +21,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(app_masterworker, "Messages specific for this examp
 static void master(int argc, char* argv[])
 {
   xbt_assert(argc == 5, "The master function expects 4 arguments from the XML deployment file");
-  long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");       /* - Number of tasks      */
-  double comp_size     = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /* - Compute cost    */
-  long comm_size       = xbt_str_parse_int(argv[3], "Invalid communication size: %s");    /* - Communication size */
-  long workers_count   = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");     /* - Number of workers    */
+  long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks");       /* - Number of tasks      */
+  double comp_size     = xbt_str_parse_double(argv[2], "Invalid computational size"); /* - Compute cost    */
+  long comm_size       = xbt_str_parse_int(argv[3], "Invalid communication size");    /* - Communication size */
+  long workers_count   = xbt_str_parse_int(argv[4], "Invalid amount of workers");     /* - Number of workers    */
 
   XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
 
@@ -62,7 +62,7 @@ static void worker(int argc, char* argv[])
              "The worker expects a single argument from the XML deployment file: its worker ID (its numerical rank)");
   char mailbox_name[80];
 
-  long id = xbt_str_parse_int(argv[1], "Invalid argument %s");
+  long id = xbt_str_parse_int(argv[1], "Invalid argument");
 
   snprintf(mailbox_name, 79, "worker-%ld", id);
   sg_mailbox_t mailbox = sg_mailbox_by_name(mailbox_name);
index 6046f63..0d9eafd 100644 (file)
@@ -23,7 +23,7 @@ static void relay_runner(int argc, char* argv[])
   xbt_assert(argc == 0, "The relay_runner function does not accept any parameter from the XML deployment file");
 
   const char* name = sg_actor_self_get_name();
-  int rank         = (int)xbt_str_parse_int(name, "Any actor of this example must have a numerical name, not %s");
+  int rank         = (int)xbt_str_parse_int(name, "Any actor of this example must have a numerical name");
 
   sg_mailbox_t my_mailbox = sg_mailbox_by_name(name);
 
index fd5fd66..0cccf01 100644 (file)
@@ -19,9 +19,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(cloud_capping, "Messages specific for this example"
 static void worker_main(int argc, char* argv[])
 {
   xbt_assert(argc == 4);
-  double computation_amount = xbt_str_parse_double(argv[1], "Invalid computation amount: %s");
-  int use_bound             = !!xbt_str_parse_int(argv[2], "Second parameter (use_bound) should be 0 or 1 but is: %s");
-  double bound              = xbt_str_parse_double(argv[3], "Invalid bound: %s");
+  double computation_amount = xbt_str_parse_double(argv[1], "Invalid computation amount");
+  int use_bound             = !!xbt_str_parse_int(argv[2], "Second parameter (use_bound) should be 0 or 1 but is");
+  double bound              = xbt_str_parse_double(argv[3], "Invalid bound");
 
   double clock_sta = simgrid_get_clock();
 
index 9e903db..9b39c6a 100644 (file)
@@ -20,10 +20,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(comm_wait, "Messages specific for this example");
 static void sender(int argc, char* argv[])
 {
   xbt_assert(argc == 5, "The sender function expects 4 arguments from the XML deployment file");
-  long messages_count     = xbt_str_parse_int(argv[1], "Invalid amount of messages: %s");  /* - number of messages */
-  long message_size       = xbt_str_parse_int(argv[2], "Invalid message size: %s");        /* - communication cost */
-  double sleep_start_time = xbt_str_parse_double(argv[3], "Invalid sleep start time: %s"); /* - start time */
-  double sleep_test_time  = xbt_str_parse_double(argv[4], "Invalid test time: %s");        /* - test time */
+  long messages_count     = xbt_str_parse_int(argv[1], "Invalid amount of messages");  /* - number of messages */
+  long message_size       = xbt_str_parse_int(argv[2], "Invalid message size");        /* - communication cost */
+  double sleep_start_time = xbt_str_parse_double(argv[3], "Invalid sleep start time"); /* - start time */
+  double sleep_test_time  = xbt_str_parse_double(argv[4], "Invalid test time");        /* - test time */
 
   XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
   sg_mailbox_t mailbox = sg_mailbox_by_name("receiver");
@@ -53,8 +53,8 @@ static void sender(int argc, char* argv[])
 static void receiver(int argc, char* argv[])
 {
   xbt_assert(argc == 3, "The relay_runner function does not accept any parameter from the XML deployment file");
-  double sleep_start_time = xbt_str_parse_double(argv[1], "Invalid sleep start parameter: %s"); /* - start time */
-  double sleep_test_time  = xbt_str_parse_double(argv[2], "Invalid sleep test parameter: %s");  /* - test time */
+  double sleep_start_time = xbt_str_parse_double(argv[1], "Invalid sleep start parameter"); /* - start time */
+  double sleep_test_time  = xbt_str_parse_double(argv[2], "Invalid sleep test parameter");  /* - test time */
   XBT_INFO("sleep_start_time : %f , sleep_test_time : %f", sleep_start_time, sleep_test_time);
 
   sg_actor_sleep_for(sleep_start_time); /* This actor first sleeps for "start time" seconds.  */
index a7d67a8..d095ce8 100644 (file)
@@ -20,9 +20,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(comm_waitall, "Messages specific for this msg examp
 static void sender(int argc, char* argv[])
 {
   xbt_assert(argc == 4, "This function expects 3 parameters from the XML deployment file");
-  long messages_count  = xbt_str_parse_int(argv[1], "Invalid message count: %s");
-  long message_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 message_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 */
@@ -70,7 +70,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);
index 96a23ab..ea987fb 100644 (file)
@@ -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 */
@@ -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);
index 0c1f981..45c1826 100644 (file)
@@ -447,7 +447,7 @@ static void node(int argc, char* argv[])
   double deadline;
   xbt_assert(argc == 3 || argc == 5, "Wrong number of arguments for this node");
   s_node_t node         = {0};
-  node.id               = (int)xbt_str_parse_int(argv[1], "Invalid ID: %s");
+  node.id               = (int)xbt_str_parse_int(argv[1], "Invalid ID");
   node.known_id         = -1;
   node.ready            = -1;
   node.pending_messages = xbt_dynar_new(sizeof(pastry_message_t), NULL);
@@ -469,14 +469,14 @@ static void node(int argc, char* argv[])
 
   if (argc == 3) { // first ring
     XBT_DEBUG("Hey! Let's create the system.");
-    deadline   = xbt_str_parse_double(argv[2], "Invalid deadline: %s");
+    deadline   = xbt_str_parse_double(argv[2], "Invalid deadline");
     node.ready = 0;
     XBT_DEBUG("Create a new Pastry ring...");
     join_success = 1;
   } else {
-    node.known_id     = (int)xbt_str_parse_int(argv[2], "Invalid known ID: %s");
-    double sleep_time = xbt_str_parse_double(argv[3], "Invalid sleep time: %s");
-    deadline          = xbt_str_parse_double(argv[4], "Invalid deadline: %s");
+    node.known_id     = (int)xbt_str_parse_int(argv[2], "Invalid known ID");
+    double sleep_time = xbt_str_parse_double(argv[3], "Invalid sleep time");
+    deadline          = xbt_str_parse_double(argv[4], "Invalid deadline");
 
     // sleep before starting
     XBT_DEBUG("Let's sleep during %f", sleep_time);
@@ -522,13 +522,13 @@ int main(int argc, char* argv[])
   while (!strncmp(options[0], "-", 1)) {
     int length = strlen("-nb_bits=");
     if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
-      nb_bits = (int)xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s");
+      nb_bits = (int)xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter");
       XBT_DEBUG("Set nb_bits to %d", nb_bits);
     } else {
       length = strlen("-timeout=");
       xbt_assert(strncmp(options[0], "-timeout=", length) == 0 && strlen(options[0]) > length,
                  "Invalid pastry option '%s'", options[0]);
-      timeout = (int)xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s");
+      timeout = (int)xbt_str_parse_int(options[0] + length, "Invalid timeout parameter");
       XBT_DEBUG("Set timeout to %d", timeout);
     }
     options++;
index e17fd2e..4472b55 100644 (file)
@@ -23,10 +23,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(platform_failures, "Messages specific for this exam
 static void master(int argc, char* argv[])
 {
   xbt_assert(argc == 5);
-  long number_of_tasks  = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");
-  double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size: %s");
-  long task_comm_size   = xbt_str_parse_int(argv[3], "Invalid communication size: %s");
-  long workers_count    = xbt_str_parse_int(argv[4], "Invalid amount of workers: %s");
+  long number_of_tasks  = xbt_str_parse_int(argv[1], "Invalid amount of tasks");
+  double task_comp_size = xbt_str_parse_double(argv[2], "Invalid computational size");
+  long task_comm_size   = xbt_str_parse_int(argv[3], "Invalid communication size");
+  long workers_count    = xbt_str_parse_int(argv[4], "Invalid amount of workers");
 
   XBT_INFO("Got %ld workers and %ld tasks to process", workers_count, number_of_tasks);
 
@@ -90,7 +90,7 @@ static void worker(int argc, char* argv[])
 {
   xbt_assert(argc == 2);
   char mailbox_name[80];
-  long id = xbt_str_parse_int(argv[1], "Invalid argument %s");
+  long id = xbt_str_parse_int(argv[1], "Invalid argument");
 
   snprintf(mailbox_name, 79, "worker-%ld", id);
   sg_mailbox_t mailbox = sg_mailbox_by_name(mailbox_name);
index bb0e3b8..8e6de3b 100644 (file)
@@ -20,7 +20,7 @@ static void peer(int argc, char* argv[])
 {
   int i = 0;
   while (i < argc) {
-    double wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
+    double wait_time = xbt_str_parse_double(argv[i], "Invalid wait time");
     i++;
     sg_actor_sleep_for(wait_time);
     XBT_INFO("Trying to acquire %d (%sblocking)", i, sg_sem_would_block(sem) ? "" : "not ");
@@ -33,7 +33,7 @@ static void peer(int argc, char* argv[])
     }
     XBT_INFO("Acquired %d", i);
 
-    wait_time = xbt_str_parse_double(argv[i], "Invalid wait time: %s");
+    wait_time = xbt_str_parse_double(argv[i], "Invalid wait time");
     i++;
     sg_actor_sleep_for(wait_time);
     XBT_INFO("Releasing %d", i);
index bc2fb64..73f797b 100644 (file)
@@ -22,13 +22,13 @@ int main(int argc, char* argv[])
   while (not strncmp(options[0], "-", 1)) {
     unsigned int length = strlen("-nb_bits=");
     if (not strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) {
-      nb_bits = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"));
+      nb_bits = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter"));
       XBT_DEBUG("Set nb_bits to %d", nb_bits);
     } else {
       length = strlen("-timeout=");
       xbt_assert(strncmp(options[0], "-timeout=", length) == 0 && strlen(options[0]) > length,
                  "Invalid chord option '%s'", options[0]);
-      timeout = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"));
+      timeout = static_cast<int>(xbt_str_parse_int(options[0] + length, "Invalid timeout parameter"));
       XBT_DEBUG("Set timeout to %d", timeout);
     }
     options++;
index 6faa87d..4049e42 100644 (file)
@@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example")
 static void smpi_replay(int argc, char* argv[])
 {
   const char* instance_id = argv[1];
-  int rank                = static_cast<int>(xbt_str_parse_int(argv[2], "Cannot parse rank '%s'"));
+  int rank                = static_cast<int>(xbt_str_parse_int(argv[2], "Cannot parse rank"));
   const char* shared_trace =
       simgrid::s4u::Actor::self()->get_property("tracefile"); // Cannot use properties because this can be nullptr
   const char* private_trace = argv[3];
index 8d90899..3798706 100644 (file)
@@ -49,7 +49,7 @@ AppSide* AppSide::initialize()
 
   // Fetch socket from MC_ENV_SOCKET_FD:
   const char* fd_env = std::getenv(MC_ENV_SOCKET_FD);
-  int fd = xbt_str_parse_int(fd_env, "Variable '" MC_ENV_SOCKET_FD "' should contain a number but contains '%s'");
+  int fd             = xbt_str_parse_int(fd_env, "Not a number in variable '" MC_ENV_SOCKET_FD "'");
   XBT_DEBUG("Model-checked application found socket FD %i", fd);
 
   // Check the socket type/validity:
index 6ace54b..450890c 100644 (file)
@@ -365,26 +365,23 @@ void HostEnergy::init_watts_range_list()
     double epsilon_power;
     double max_power;
 
-    char* msg_idle    = bprintf("Invalid Idle value for pstate %d on host %s: %%s", i, host_->get_cname());
-    char* msg_epsilon = bprintf("Invalid Epsilon value for pstate %d on host %s: %%s", i, host_->get_cname());
-    char* msg_max     = bprintf("Invalid AllCores value for pstate %d on host %s: %%s", i, host_->get_cname());
+    auto msg_idle    = xbt::string_printf("Invalid Idle value for pstate %d on host %s", i, host_->get_cname());
+    auto msg_epsilon = xbt::string_printf("Invalid Epsilon value for pstate %d on host %s", i, host_->get_cname());
+    auto msg_max     = xbt::string_printf("Invalid AllCores value for pstate %d on host %s", i, host_->get_cname());
 
-    idle_power = xbt_str_parse_double((current_power_values.at(0)).c_str(), msg_idle);
+    idle_power = xbt_str_parse_double((current_power_values.at(0)).c_str(), msg_idle.c_str());
     if (current_power_values.size() == 2) { // Case: Idle:AllCores
-      epsilon_power = xbt_str_parse_double((current_power_values.at(0)).c_str(), msg_idle);
-      max_power     = xbt_str_parse_double((current_power_values.at(1)).c_str(), msg_max);
+      epsilon_power = xbt_str_parse_double((current_power_values.at(0)).c_str(), msg_idle.c_str());
+      max_power     = xbt_str_parse_double((current_power_values.at(1)).c_str(), msg_max.c_str());
     } else { // Case: Idle:Epsilon:AllCores
-      epsilon_power = xbt_str_parse_double((current_power_values.at(1)).c_str(), msg_epsilon);
-      max_power     = xbt_str_parse_double((current_power_values.at(2)).c_str(), msg_max);
+      epsilon_power = xbt_str_parse_double((current_power_values.at(1)).c_str(), msg_epsilon.c_str());
+      max_power     = xbt_str_parse_double((current_power_values.at(2)).c_str(), msg_max.c_str());
     }
 
     XBT_DEBUG("Creating PowerRange for host %s. Idle:%f, Epsilon:%f, AllCores:%f.", host_->get_cname(), idle_power, epsilon_power, max_power);
 
     PowerRange range(idle_power, epsilon_power, max_power);
     power_range_watts_list_.push_back(range);
-    xbt_free(msg_idle);
-    xbt_free(msg_epsilon);
-    xbt_free(msg_max);
     ++i;
   }
 }
index 1c64f67..b2c2d76 100644 (file)
@@ -73,7 +73,7 @@ void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock)
 /* Helper function */
 static double parse_double(const std::string& string)
 {
-  return xbt_str_parse_double(string.c_str(), "%s is not a double");
+  return xbt_str_parse_double(string.c_str(), "not a double");
 }
 
 namespace simgrid {
index 3759f49..59fb4be 100644 (file)
 
 /** @brief Parse an integer out of a string, or raise an error
  *
- * The @a str is passed as argument to your @a error_msg, as follows:
- * @verbatim throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str)); @endverbatim
+ * The @a str is concatenated to your @a error_msg, as follows:
+ * @verbatim throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str)); @endverbatim
  */
 long int xbt_str_parse_int(const char* str, const char* error_msg)
 {
   char* endptr;
   if (str == nullptr || str[0] == '\0')
-    throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str));
+    throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str));
 
   long int res = strtol(str, &endptr, 10);
   if (endptr[0] != '\0')
-    throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str));
+    throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str));
 
   return res;
 }
 
 /** @brief Parse a double out of a string, or raise an error
  *
- * The @a str is passed as argument to your @a error_msg, as follows:
- * @verbatim throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str)); @endverbatim
+ * The @a str is concatenated to your @a error_msg, as follows:
+ * @verbatim throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str)); @endverbatim
  */
 double xbt_str_parse_double(const char* str, const char* error_msg)
 {
   char *endptr;
   if (str == nullptr || str[0] == '\0')
-    throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str));
+    throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str));
 
   double res = strtod(str, &endptr);
   if (endptr[0] != '\0')
-    throw std::invalid_argument(simgrid::xbt::string_printf(error_msg, str));
+    throw std::invalid_argument(simgrid::xbt::string_printf("%s: %s", error_msg, str));
 
   return res;
 }