Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] correct impossible code.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 13 Jun 2012 17:16:52 +0000 (19:16 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Wed, 13 Jun 2012 17:17:29 +0000 (19:17 +0200)
PJ_value_get() can't return NULL.  Use PJ_value_get_or_new() instead.
Fixes test smpi-tracing-ptp.

src/instr/instr_interface.c
src/instr/instr_smpi.c

index de4e65f..713a0e9 100644 (file)
@@ -201,10 +201,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value)
   if (type == NULL){
     THROWF (tracing_error, 1, "mark_type with name (%s) not declared before", mark_type);
   }
-  val_t value = PJ_value_get (mark_value, type);
-  if (value == NULL){
-    value = PJ_value_new (mark_value, NULL, type);
-  }
+  val_t value = PJ_value_get_or_new (mark_value, NULL, type);
   new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
 }
 
@@ -835,11 +832,7 @@ void TRACE_host_set_state (const char *host, const char *state, const char *valu
 {
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
-  val_t val = PJ_value_get (value, type);
-  if (val == NULL){
-    //if user didn't declare a value with a color, user a NULL color
-    PJ_value_new (value, NULL, type);
-  }
+  val_t val = PJ_value_get_or_new (value, NULL, type); /* if user didn't declare a value with a color, user a NULL color */
   new_pajeSetState(MSG_get_clock(), container, type, val);
 }
 
@@ -858,11 +851,7 @@ void TRACE_host_push_state (const char *host, const char *state, const char *val
 {
   container_t container = PJ_container_get(host);
   type_t type = PJ_type_get (state, container->type);
-  val_t val = PJ_value_get (value, type);
-  if (val == NULL){
-    //if user didn't declare a value with a color, user a NULL color
-    PJ_value_new (value, NULL, type);
-  }
+  val_t val = PJ_value_get_or_new (value, NULL, type); /* if user didn't declare a value with a color, user a NULL color */
   new_pajePushState(MSG_get_clock(), container, type, val);
 }
 
index 92914be..060f0a9 100644 (file)
@@ -184,10 +184,7 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
-  val_t value = PJ_value_get (operation, type);
-  if (value == NULL){
-    value = PJ_value_new (operation, color, type);
-  }
+  val_t value = PJ_value_get_or_new (operation, color, type);
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
@@ -213,10 +210,7 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation)
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
-  val_t value = PJ_value_get (operation, type);
-  if (value == NULL){
-    value = PJ_value_new (operation, color, type);
-  }
+  val_t value = PJ_value_get_or_new (operation, color, type);
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }