From: Martin Quinson Date: Sun, 7 Feb 2016 16:51:06 +0000 (+0100) Subject: greatly reduce the amount of atoi in our codebase X-Git-Tag: v3_13~945 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a6842b518fd3973d810bae84ad5110c26b20953b?ds=inline greatly reduce the amount of atoi in our codebase Some remain and should be hunted down. atol and atof will follow. --- diff --git a/examples/msg/bittorrent/bittorrent.xml b/examples/msg/bittorrent/bittorrent.xml index 58627ee9c5..c15bcfe903 100644 --- a/examples/msg/bittorrent/bittorrent.xml +++ b/examples/msg/bittorrent/bittorrent.xml @@ -9,7 +9,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/examples/msg/bittorrent/peer.c b/examples/msg/bittorrent/peer.c index 4382710951..fcd1a0ffde 100644 --- a/examples/msg/bittorrent/peer.c +++ b/examples/msg/bittorrent/peer.c @@ -47,12 +47,12 @@ int peer(int argc, char *argv[]) xbt_assert(argc == 3 || argc == 4, "Wrong number of arguments"); //Build peer object if (argc == 4) { - peer_init(&peer, atoi(argv[1]), 1); + peer_init(&peer, xbt_str_parse_int(argv[1],"Invalid ID: %s"), 1); } else { - peer_init(&peer, atoi(argv[1]), 0); + peer_init(&peer, xbt_str_parse_int(argv[1],"Invalid ID: %s"), 0); } //Retrieve deadline - double deadline = atof(argv[2]); + double deadline = xbt_str_parse_double(argv[2],"Invalid deadline: %s"); xbt_assert(deadline > 0, "Wrong deadline supplied"); XBT_INFO("Hi, I'm joining the network with id %d", peer.id); //Getting peer data from the tracker. diff --git a/examples/msg/chainsend/broadcaster.c b/examples/msg/chainsend/broadcaster.c index 5daf3d5fa7..112bb25db2 100644 --- a/examples/msg/chainsend/broadcaster.c +++ b/examples/msg/chainsend/broadcaster.c @@ -118,11 +118,11 @@ int broadcaster(int argc, char *argv[]) XBT_DEBUG("broadcaster"); /* Add every mailbox given by the hostcount in argv[1] to a dynamic array */ - host_list = build_hostlist_from_hostcount(atoi(argv[1])); + host_list = build_hostlist_from_hostcount(xbt_str_parse_int(argv[1], "Invalid number of peers: %s")); /* argv[2] is the number of pieces */ if (argc > 2) { - piece_count = atoi(argv[2]); + piece_count = xbt_str_parse_int(argv[2], "Invalid number of pieces: %s"); XBT_DEBUG("piece_count set to %d", piece_count); } else { XBT_DEBUG("No piece_count specified, defaulting to %d", piece_count); diff --git a/examples/msg/chord/chord.c b/examples/msg/chord/chord.c index 8de01ef2b0..ef8324c8e3 100644 --- a/examples/msg/chord/chord.c +++ b/examples/msg/chord/chord.c @@ -322,9 +322,8 @@ int node(int argc, char *argv[]) // initialize my node s_node_t node = {0}; - node.id = atoi(argv[1]); - node.stream = - (RngStream)MSG_host_get_property_value(MSG_host_self(), "stream"); + node.id = xbt_str_parse_int(argv[1],"Invalid ID: %s"); + node.stream = (RngStream)MSG_host_get_property_value(MSG_host_self(), "stream"); get_mailbox(node.id, node.mailbox); node.next_finger_to_fix = 0; node.fingers = xbt_new0(s_finger_t, nb_bits); @@ -336,14 +335,14 @@ int node(int argc, char *argv[]) } if (argc == 3) { // first ring - deadline = atof(argv[2]); + deadline = xbt_str_parse_double(argv[2],"Invalid deadline: %s"); create(&node); join_success = 1; - } - else { - int known_id = atoi(argv[2]); + + } else { + int known_id = xbt_str_parse_int(argv[2],"Invalid root ID: %s"); //double sleep_time = atof(argv[3]); - deadline = atof(argv[4]); + deadline = xbt_str_parse_double(argv[4],"Invalid deadline: %s"); /* // sleep before starting @@ -1036,14 +1035,14 @@ int main(int argc, char *argv[]) int length = strlen("-nb_bits="); if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { - nb_bits = atoi(options[0] + length); + nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"); XBT_DEBUG("Set nb_bits to %d", nb_bits); } else { length = strlen("-timeout="); if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { - timeout = atoi(options[0] + length); + timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"); XBT_DEBUG("Set timeout to %d", timeout); } else { diff --git a/examples/msg/cloud/bound.c b/examples/msg/cloud/bound.c index 8316bb5eb8..06a059b63c 100644 --- a/examples/msg/cloud/bound.c +++ b/examples/msg/cloud/bound.c @@ -24,9 +24,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, static int worker_main(int argc, char *argv[]) { - double computation_amount = atof(argv[1]); - int use_bound = atoi(argv[2]); - double bound = atof(argv[3]); + 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 clock_sta = MSG_get_clock(); diff --git a/examples/msg/io/remote.c b/examples/msg/io/remote.c index 5661b619e8..cc84983669 100644 --- a/examples/msg/io/remote.c +++ b/examples/msg/io/remote.c @@ -54,7 +54,7 @@ int host(int argc, char *argv[]){ msg_host_t src, dest; src= MSG_host_self(); dest = MSG_host_by_name(argv[3]); - if (atoi(argv[5])){ + if (xbt_str_parse_int(argv[5], "Argument 5 (move or copy) must be an int, not '%s'")) { XBT_INFO("Move '%s' (of size %llu) from '%s' to '%s'", filename, MSG_file_get_size(file), MSG_host_get_name(src), argv[3]); diff --git a/examples/msg/mc/bugged1.c b/examples/msg/mc/bugged1.c index 1954933a5c..aa397f8d53 100644 --- a/examples/msg/mc/bugged1.c +++ b/examples/msg/mc/bugged1.c @@ -31,7 +31,7 @@ int server(int argc, char *argv[]) MSG_task_receive(&task, "mymailbox"); count++; } - MC_assert(atoi(MSG_task_get_name(task)) == 3); + MC_assert(xbt_str_parse_int(MSG_task_get_name(task), "Task names must be integers, not '%s'") == 3); XBT_INFO("OK"); return 0; diff --git a/examples/msg/mc/bugged2.c b/examples/msg/mc/bugged2.c index 70cff38d03..bd916c09c5 100644 --- a/examples/msg/mc/bugged2.c +++ b/examples/msg/mc/bugged2.c @@ -54,15 +54,14 @@ int server(int argc, char *argv[]) int client(int argc, char *argv[]) { - msg_task_t task1 = - MSG_task_create("task", 0, 10000, (void *) atol(argv[1])); - msg_task_t task2 = - MSG_task_create("task", 0, 10000, (void *) atol(argv[1])); + int ID = xbt_str_parse_int(argv[1], "Arg 1 is not a numerical ID: %s"); + msg_task_t task1 = MSG_task_create("task", 0, 10000, (void *) ID); + msg_task_t task2 = MSG_task_create("task", 0, 10000, (void *) ID); - XBT_INFO("Send %d!", atoi(argv[1])); + XBT_INFO("Send %d!", ID); MSG_task_send(task1, "mymailbox"); - XBT_INFO("Send %d!", atoi(argv[1])); + XBT_INFO("Send %d!", ID); MSG_task_send(task2, "mymailbox"); return 0; diff --git a/examples/msg/mc/bugged3.c b/examples/msg/mc/bugged3.c index 33dc2d1482..e43e802d93 100644 --- a/examples/msg/mc/bugged3.c +++ b/examples/msg/mc/bugged3.c @@ -43,15 +43,13 @@ int server(int argc, char *argv[]) int client(int argc, char *argv[]) { - msg_comm_t comm; - char *mbox; - msg_task_t task1 = - MSG_task_create("task", 0, 10000, (void *) atol(argv[1])); + int ID = xbt_str_parse_int(argv[1], "Arg 1 is not a numerical ID: %s"); + msg_task_t task1 = MSG_task_create("task", 0, 10000, (void *) ID); - mbox = bprintf("mymailbox%s", argv[1]); + char *mbox = bprintf("mymailbox%s", argv[1]); - XBT_INFO("Send %d!", atoi(argv[1])); - comm = MSG_task_isend(task1, mbox); + XBT_INFO("Send %d!", ID); + msg_comm_t comm = MSG_task_isend(task1, mbox); MSG_comm_wait(comm, -1); xbt_free(mbox); @@ -66,9 +64,7 @@ int main(int argc, char *argv[]) MSG_create_environment("platform.xml"); MSG_function_register("server", server); - MSG_function_register("client", client); - MSG_launch_application("deploy_bugged3.xml"); MSG_main(); diff --git a/examples/msg/ns3/ns3.c b/examples/msg/ns3/ns3.c index ac1b6adf04..42fa9d1594 100644 --- a/examples/msg/ns3/ns3.c +++ b/examples/msg/ns3/ns3.c @@ -56,7 +56,6 @@ int count_finished = 0; /** master */ int master(int argc, char *argv[]) { - double task_comm_size = 0; msg_task_t todo; xbt_assert(argc==4,"Strange number of arguments expected 3 got %d", argc - 1); @@ -64,13 +63,11 @@ int master(int argc, char *argv[]) XBT_DEBUG ("Master started"); /* data size */ - int read; - read = sscanf(argv[1], "%lg", &task_comm_size); - xbt_assert(read, "Invalid argument %s\n", argv[1]); + double task_comm_size = xbt_str_parse_double(argv[1], "Invalid task communication size: %s"); /* slave name */ char *slavename = argv[2]; - int id = atoi(argv[3]); //unique id to control statistics + int id = xbt_str_parse_int(argv[3], "Invalid ID as argument 3: %s"); //unique id to control statistics char *id_alias = bprintf("flow_%d", id); slavenames[id] = slavename; TRACE_category(id_alias); @@ -86,7 +83,7 @@ int master(int argc, char *argv[]) } { /* Process organization */ - MSG_get_host_by_name(slavename); + MSG_host_by_name(slavename); } count_finished++; @@ -143,7 +140,7 @@ int slave(int argc, char *argv[]) XBT_DEBUG ("Slave started"); - id = atoi(argv[1]); + id = xbt_str_parse_int(argv[1], "Invalid id: %s"); sprintf(id_alias, "%d", id); a = MSG_task_receive(&(task), id_alias); diff --git a/examples/msg/pastry/pastry.c b/examples/msg/pastry/pastry.c index bc85c04e86..37d443cfd6 100644 --- a/examples/msg/pastry/pastry.c +++ b/examples/msg/pastry/pastry.c @@ -517,7 +517,7 @@ static int 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 = atoi(argv[1]); + node.id = xbt_str_parse_int(argv[1], "Invalid ID: %s"); node.known_id = -1; node.ready = -1; node.pending_tasks = xbt_fifo_new(); @@ -539,14 +539,14 @@ static int node(int argc, char *argv[]) if (argc == 3) { // first ring XBT_DEBUG("Hey! Let's create the system."); - deadline = atof(argv[2]); + deadline = xbt_str_parse_double(argv[2], "Invalid deadline: %s"); create(&node); join_success = 1; } else { - node.known_id = atoi(argv[2]); - double sleep_time = atof(argv[3]); - deadline = atof(argv[4]); + node.known_id = 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"); // sleep before starting XBT_DEBUG("Let's sleep during %f", sleep_time); @@ -623,14 +623,14 @@ int main(int argc, char *argv[]) int length = strlen("-nb_bits="); if (!strncmp(options[0], "-nb_bits=", length) && strlen(options[0]) > length) { - nb_bits = atoi(options[0] + length); + nb_bits = xbt_str_parse_int(options[0] + length, "Invalid nb_bits parameter: %s"); XBT_DEBUG("Set nb_bits to %d", nb_bits); } else { length = strlen("-timeout="); if (!strncmp(options[0], "-timeout=", length) && strlen(options[0]) > length) { - timeout = atoi(options[0] + length); + timeout = xbt_str_parse_int(options[0] + length, "Invalid timeout parameter: %s"); XBT_DEBUG("Set timeout to %d", timeout); } else { diff --git a/examples/msg/pmm/msg_pmm.c b/examples/msg/pmm/msg_pmm.c index 530b15d734..f1e02aac43 100644 --- a/examples/msg/pmm/msg_pmm.c +++ b/examples/msg/pmm/msg_pmm.c @@ -77,7 +77,7 @@ int node(int argc, char **argv) xbt_assert(argc != 1, "Wrong number of arguments for this node"); /* Initialize the node's data-structures */ - myid = atoi(argv[1]); + myid = xbt_str_parse_int(argv[1], "Invalid ID received as first node parameter: %s"); snprintf(my_mbox, MAILBOX_NAME_SIZE - 1, "%d", myid); sC = xbt_matrix_double_new_zeros(NODE_MATRIX_SIZE, NODE_MATRIX_SIZE); diff --git a/examples/msg/start_kill_time/sk_time.c b/examples/msg/start_kill_time/sk_time.c index 00dfcbb2be..8442325d5c 100644 --- a/examples/msg/start_kill_time/sk_time.c +++ b/examples/msg/start_kill_time/sk_time.c @@ -22,7 +22,7 @@ static int sleeper(int argc, char *argv[]) XBT_INFO("Hello! I go to sleep."); MSG_process_on_exit(my_onexit, NULL); - MSG_process_sleep(atoi(argv[1])); + MSG_process_sleep(xbt_str_parse_int(argv[1], "sleeper process expects an integer parameter but got %s")); XBT_INFO("Done sleeping."); return 0; } diff --git a/examples/msg/token_ring/ring_call.c b/examples/msg/token_ring/ring_call.c index 6b00f34e19..06a46488bb 100644 --- a/examples/msg/token_ring/ring_call.c +++ b/examples/msg/token_ring/ring_call.c @@ -7,7 +7,6 @@ #include #include #include "simgrid/msg.h" -#include "src/surf/surf_private.h" int host(int argc, char *argv[]); unsigned int task_comp_size = 50000000; @@ -30,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(ring, int host(int argc, char *argv[]) { - int host_number = atoi(MSG_process_get_name(MSG_process_self())); + int host_number = xbt_str_parse_int(MSG_process_get_name(MSG_process_self()), "Process name must be an integer but is: %s"); char mailbox[256]; msg_task_t task = NULL; XBT_ATTRIB_UNUSED int res; diff --git a/examples/smpi/MM/MM_mpi.c b/examples/smpi/MM/MM_mpi.c index 6767ba47e9..d59b1227f3 100644 --- a/examples/smpi/MM/MM_mpi.c +++ b/examples/smpi/MM/MM_mpi.c @@ -84,41 +84,41 @@ int main(int argc, char ** argv) " -M I M size (default: %zu)\n" " -N I N size (default: %zu)\n" " -K I K size (default: %zu)\n" - " -B I Block size on the k dimension(default: %zu)\n" - " -G I Number of processor groups(default: %zu)\n" - " -g I group index(default: %zu)\n" - " -k I group rank(default: %zu)\n" + " -B I Block size on the k dimension (default: %zu)\n" + " -G I Number of processor groups (default: %zu)\n" + " -g I group index (default: %zu)\n" + " -k I group rank (default: %zu)\n" " -r I processor row size (default: %zu)\n" " -c I processor col size (default: %zu)\n" " -h help\n", m, n, k, Block_size, NB_groups, group, key, row, col); return 0; case 'M': - m = atoi(optarg); + m = xbt_str_parse_int(optarg, "Invalid M size: %s"); break; case 'N': - n = atoi(optarg); + n = xbt_str_parse_int(optarg, "Invalid N size: %s"); break; case 'K': - k = atoi(optarg); + k = xbt_str_parse_int(optarg, "Invalid K size: %s"); break; case 'B': - Block_size = atoi(optarg); + Block_size = xbt_str_parse_int(optarg, "Invalid block size: %s"); break; case 'G': - NB_groups = atoi(optarg); + NB_groups = xbt_str_parse_int(optarg, "Invalid number of processor groups: %s"); break; case 'g': - group = atoi(optarg); + group = xbt_str_parse_int(optarg, "Invalid group index: %s"); break; case 'k': - key = atoi(optarg); + key = xbt_str_parse_int(optarg, "Invalid group rank: %s"); break; case 'r': - size_row = atoi(optarg); + size_row = xbt_str_parse_int(optarg, "Invalid processor row size: %s"); break; case 'c': - size_col = atoi(optarg); + size_col = xbt_str_parse_int(optarg, "Invalid processor col size: %s"); break; /*case 'P': str_mask = strdup(optarg); diff --git a/examples/smpi/mvmul.c b/examples/smpi/mvmul.c index 15a9e7e0f7..c7e8353279 100644 --- a/examples/smpi/mvmul.c +++ b/examples/smpi/mvmul.c @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) exit(USAGE_ERROR); } - N = atoi(argv[1]); + N = xbt_str_parse_int(argv[1], "Invalid size: %s"); start_time = (struct timeval *) malloc(sizeof(struct timeval)); stop_time = (struct timeval *) malloc(sizeof(struct timeval)); diff --git a/examples/smpi/replay_multiple/replay_multiple.c b/examples/smpi/replay_multiple/replay_multiple.c index 03ec4b4c20..969fe9ac7a 100644 --- a/examples/smpi/replay_multiple/replay_multiple.c +++ b/examples/smpi/replay_multiple/replay_multiple.c @@ -58,7 +58,7 @@ int main(int argc, char *argv[]){ const char** line_char= xbt_dynar_to_array(elems); instance_id = line_char[0]; - instance_size = atoi(line_char[2]); + instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s"); XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size); SMPI_app_instance_register(instance_id, smpi_replay,instance_size); diff --git a/examples/xbt/sem_sched.c b/examples/xbt/sem_sched.c index c6af2d926c..607a4a7454 100644 --- a/examples/xbt/sem_sched.c +++ b/examples/xbt/sem_sched.c @@ -99,8 +99,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - - size = atoi(argv[1]); + size = xbt_str_parse_int(argv[1], "Invalid size: %s"); /* create a new scheduler */ sched = sched_new(size); @@ -113,10 +112,7 @@ int main(int argc, char *argv[]) __argv = xbt_new0(char *, MAX_ARGS); for (i = 0; i < MAX_ARGS; i++) { - sprintf(arg, "arg_%d", i); - __argv[i] = strdup(arg); - memset(arg, 0, MAX_ARG); - + __argv[i] = bprintf("arg_%d", i); } for (i = 0; i < size; i++) diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index e774f9dd40..b585d51d18 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -155,7 +155,7 @@ static void add_subsets_to(xbt_dynar_t subset_list, xbt_dynar_t hostgroup, nb_ids = xbt_dynar_length(id_list); id_ar = xbt_new0(int,nb_ids); xbt_dynar_foreach(id_list, iter, id_str) { - id_ar[iter] = atoi(id_str); + id_ar[iter] = xbt_str_parse_int(id_str, "Parse error: not a number: %s"); } qsort (id_ar, nb_ids, sizeof(int), &compare_ids); diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index fca86d0aee..ef98cce2e7 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -497,7 +497,7 @@ static std::vector MC_get_current_fds(pid_t pid) struct dirent* fd_number; while ((fd_number = readdir(fd_dir))) { - int fd_value = atoi(fd_number->d_name); + int fd_value = xbt_str_parse_int(fd_number->d_name, "Found a non-numerical FD: %s. Freaking out!"); if(fd_value < 3) continue; diff --git a/src/mc/mc_client.cpp b/src/mc/mc_client.cpp index 3956391ae0..07e65fb66c 100644 --- a/src/mc/mc_client.cpp +++ b/src/mc/mc_client.cpp @@ -47,7 +47,7 @@ void MC_client_init(void) if (!fd_env) xbt_die("MC socket not found"); - int fd = atoi(fd_env); + int fd = xbt_str_parse_int(fd_env,bprintf("Variable %s should contain a number but contains '%%s'", MC_ENV_SOCKET_FD)); XBT_DEBUG("Model-checked application found socket FD %i", fd); int type; diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index bf3b7cf585..2dc16b63b2 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -82,7 +82,7 @@ void smpi_process_init(int *argc, char ***argv) //FIXME: dirty cleanup method to avoid using msg cleanup functions on these processes when using MSG+SMPI SIMIX_process_set_cleanup_function(proc, SIMIX_process_cleanup); char* instance_id = (*argv)[1]; - int rank = atoi((*argv)[2]); + int rank = xbt_str_parse_int((*argv)[2], "Invalid rank: %s"); index = smpi_process_index_of_smx_process(proc); if(!index_to_process_data){ @@ -207,13 +207,9 @@ int smpi_process_get_replaying(){ int smpi_global_size(void) { char *value = getenv("SMPI_GLOBAL_SIZE"); + xbt_assert(value,"Please set env var SMPI_GLOBAL_SIZE to the expected number of processes."); - if (!value) { - fprintf(stderr, - "Please set env var SMPI_GLOBAL_SIZE to expected number of processes.\n"); - xbt_abort(); - } - return atoi(value); + return xbt_str_parse_int(value, "SMPI_GLOBAL_SIZE contains a non-numerical value: %s"); } smpi_process_data_t smpi_process_data(void) diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 041abb77bb..9ecbb8ad1f 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -431,7 +431,7 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t } // The first parts of topo_parameters should be the levels number - this->levels = std::atoi(parameters[0].c_str()); // stoi() only in C++11... + this->levels = xbt_str_parse_int(parameters[0].c_str(), "First parameter is not the amount of levels: %s"); // Then, a l-sized vector standing for the childs number by level boost::split(tmp, parameters[1], boost::is_any_of(",")); @@ -440,7 +440,7 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t ", see the documentation for more informations"); } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->lowerLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); + this->lowerLevelNodesNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); } // Then, a l-sized vector standing for the parents number by level @@ -450,7 +450,7 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t ", see the documentation for more informations"); } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->upperLevelNodesNumber.push_back(std::atoi(tmp[i].c_str())); + this->upperLevelNodesNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid upper level node number: %s")); } // Finally, a l-sized vector standing for the ports number with the lower level @@ -461,7 +461,7 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->lowerLevelPortsNumber.push_back(std::atoi(tmp[i].c_str())); + this->lowerLevelPortsNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); } this->cluster = cluster; }