Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Shell scripts: remove useless variable expansion in arithmetic expressions.
[simgrid.git] / examples / smpi / replay_multiple / replay_multiple.c
index 39697b0..a7cfeb5 100644 (file)
@@ -29,12 +29,10 @@ int main(int argc, char *argv[]){
   FILE* fp = fopen(argv[1], "r");
   if (fp == NULL)
     xbt_die("Cannot open %s", argv[1]);
-  ssize_t read;
-  char   *line = NULL;
+  char *line = NULL;
   size_t n   = 0;
-  int instance_size = 0;
   const char* instance_id = NULL;
-  while ((read = xbt_getline(&line, &n, fp)) != -1 ){
+  while (xbt_getline(&line, &n, fp) != -1 ){
     xbt_dynar_t elems = xbt_str_split_quoted_in_place(line);
     if(xbt_dynar_length(elems)<3){
       xbt_die ("Not enough elements in the line");
@@ -42,13 +40,16 @@ int main(int argc, char *argv[]){
 
     const char** line_char= xbt_dynar_to_array(elems);
     instance_id = line_char[0];
-    instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s");
+    int 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);
 
     xbt_free(line_char);
   }
+  xbt_free(line);
+
+  fclose(fp);
 
   MSG_launch_application(argv[3]);
   SMPI_init();