Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix unused return value warning
authordegomme <augustin.degomme@unibas.ch>
Tue, 16 Jun 2015 08:06:44 +0000 (10:06 +0200)
committerdegomme <augustin.degomme@unibas.ch>
Tue, 16 Jun 2015 08:07:41 +0000 (10:07 +0200)
src/smpi/smpi_group.c
src/smpi/smpi_replay.c

index b9122e9..99f3c51 100644 (file)
@@ -92,9 +92,13 @@ void smpi_group_set_mapping(MPI_Group group, int index, int rank)
     if (index!=MPI_UNDEFINED ) {
       val_rank = (int *) malloc(sizeof(int));
       *val_rank = rank; 
     if (index!=MPI_UNDEFINED ) {
       val_rank = (int *) malloc(sizeof(int));
       *val_rank = rank; 
-      asprintf(&key, "%d", index);
-      xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL);
-      free(key);
+      int size = asprintf(&key, "%d", index);
+      if (size!=-1){
+        xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL);
+        free(key);
+      } else {
+        xbt_die("could not allocate memory for asprintf");
+      }
     }
   }
 }
     }
   }
 }
@@ -111,10 +115,13 @@ int smpi_group_index(MPI_Group group, int rank)
 
 int smpi_group_rank(MPI_Group group, int index)
 {
 
 int smpi_group_rank(MPI_Group group, int index)
 {
-  int * ptr_rank;
+  int * ptr_rank = NULL;
   char * key;
   char * key;
-  asprintf(&key, "%d", index);
-  ptr_rank = xbt_dict_get_or_null(group->index_to_rank_map, key);
+  int size = asprintf(&key, "%d", index);
+  if (size!=-1)
+    ptr_rank = xbt_dict_get_or_null(group->index_to_rank_map, key);
+  else
+    xbt_die("could not allocate memory for asprintf");
   if (!ptr_rank)
     return MPI_UNDEFINED;
   return *ptr_rank;
   if (!ptr_rank)
     return MPI_UNDEFINED;
   return *ptr_rank;
index 59c1601..33f1462 100644 (file)
@@ -37,7 +37,9 @@ static void log_timed_action (const char *const *action, double clock){
 static xbt_dynar_t get_reqq_self(){
    char * key;
    
 static xbt_dynar_t get_reqq_self(){
    char * key;
    
-   asprintf(&key, "%d", smpi_process_index());
+   int size = asprintf(&key, "%d", smpi_process_index());
+   if(size==-1)
+     xbt_die("could not allocate memory for asprintf");
    xbt_dynar_t dynar_mpi_request = (xbt_dynar_t) xbt_dict_get(reqq, key);
    free(key);
  
    xbt_dynar_t dynar_mpi_request = (xbt_dynar_t) xbt_dict_get(reqq, key);
    free(key);
  
@@ -47,7 +49,9 @@ static xbt_dynar_t get_reqq_self(){
 static void set_reqq_self(xbt_dynar_t mpi_request){
    char * key;
    
 static void set_reqq_self(xbt_dynar_t mpi_request){
    char * key;
    
-   asprintf(&key, "%d", smpi_process_index());
+   int size = asprintf(&key, "%d", smpi_process_index());
+   if(size==-1)
+     xbt_die("could not allocate memory for asprintf");
    xbt_dict_set(reqq, key, mpi_request, free);
    free(key);
 }
    xbt_dict_set(reqq, key, mpi_request, free);
    free(key);
 }