Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics while hunting a bug of memory misbehavior
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 16 Feb 2016 20:58:05 +0000 (21:58 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 16 Feb 2016 20:58:05 +0000 (21:58 +0100)
src/surf/storage_interface.cpp
src/surf/surfxml_parse.cpp

index 1761cf6..026ed9a 100644 (file)
@@ -103,12 +103,9 @@ xbt_dict_t Storage::parseContent(const char *filename)
     return NULL;
 
   xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free_f);
     return NULL;
 
   xbt_dict_t parse_content = xbt_dict_new_homogeneous(xbt_free_f);
-  FILE *file = NULL;
 
 
-  file = surf_fopen(filename, "r");
-  if (file == NULL)
-    xbt_die("Cannot open file '%s' (path=%s)", filename,
-            xbt_str_join(surf_path, ":"));
+  FILE *file =  surf_fopen(filename, "r");
+  xbt_assert(file, "Cannot open file '%s' (path=%s)", filename, xbt_str_join(surf_path, ":"));
 
   char *line = NULL;
   size_t len = 0;
 
   char *line = NULL;
   size_t len = 0;
@@ -118,14 +115,12 @@ xbt_dict_t Storage::parseContent(const char *filename)
 
   while ((read = xbt_getline(&line, &len, file)) != -1) {
     if (read){
 
   while ((read = xbt_getline(&line, &len, file)) != -1) {
     if (read){
-      if(sscanf(line,"%s %llu", path, &size) == 2) {
-        m_usedSize += size;
-        sg_size_t *psize = xbt_new(sg_size_t, 1);
-        *psize = size;
-        xbt_dict_set(parse_content,path,psize,NULL);
-      } else {
-        xbt_die("Be sure of passing a good format for content file.\n");
-      }
+      xbt_assert(sscanf(line,"%s %llu", path, &size) == 2, "Parse error in %s: %s",filename,line);
+
+      m_usedSize += size;
+      sg_size_t *psize = xbt_new(sg_size_t, 1);
+      *psize = size;
+      xbt_dict_set(parse_content,path,psize,NULL);
     }
   }
   free(line);
     }
   }
   free(line);
index 7bb17c0..a0c9a43 100644 (file)
@@ -314,8 +314,8 @@ void STag_surfxml_include(void)
   xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse); //save old file descriptor
 
   surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new file descriptor
   xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse); //save old file descriptor
 
   surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new file descriptor
-  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n",
-              A_surfxml_include_file);
+  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", A_surfxml_include_file);
+
   xbt_dynar_push(surf_input_buffer_stack,&surf_input_buffer);
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse_push_buffer_state(surf_input_buffer);
   xbt_dynar_push(surf_input_buffer_stack,&surf_input_buffer);
   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse_push_buffer_state(surf_input_buffer);