Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Dont declare variables at the middle of nowhere.
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 15 Jun 2010 14:00:44 +0000 (14:00 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 15 Jun 2010 14:00:44 +0000 (14:00 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7863 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/interface.c
src/instr/msg_process_instr.c
src/instr/msg_task_instr.c
src/instr/msg_volume.c
src/instr/smx_instr.c
src/instr/surf_instr.c
src/instr/variables_instr.c
src/msg/msg_mailbox.c
src/surf/cpu_im.c

index 323b79a..f41ecc7 100644 (file)
@@ -37,6 +37,7 @@ int TRACE_start (const char *filename)
  * \return 0 if everything is ok
  */
 int TRACE_start_with_mask(const char *filename, int mask) {
+       FILE *file = NULL;
   if (IS_TRACING) { /* what? trace is already active... ignore.. */
        THROW0 (tracing_error, TRACE_ERROR_START,
                "TRACE_start called, but tracing is already active");
@@ -52,7 +53,7 @@ int TRACE_start_with_mask(const char *filename, int mask) {
           "unknown tracing mask");
   }
 
-  FILE *file = fopen(filename, "w");
+  file = fopen(filename, "w");
   if (!file) {
     THROW1 (tracing_error, TRACE_ERROR_START,
                "Tracefile %s could not be opened for writing.", filename);
@@ -110,16 +111,18 @@ int TRACE_start_with_mask(const char *filename, int mask) {
 }
 
 int TRACE_end() {
+       FILE *file = NULL;
   if (!IS_TRACING) return 1;
-  FILE *file = TRACE_paje_end();
+  file = TRACE_paje_end();
   fclose (file);
   return 0;
 }
 
 int TRACE_category (const char *category)
 {
-  if (!IS_TRACING) return 1;
   static int first_time = 1;
+  if (!IS_TRACING) return 1;
+
   if (first_time){
          TRACE_define_type ("user_type", "0", 1);
          first_time = 0;
@@ -129,6 +132,7 @@ int TRACE_category (const char *category)
 
 void TRACE_define_type (const char *type,
                const char *parent_type, int final) {
+       char *val_one = NULL;
   if (!IS_TRACING) return;
 
   //check if type is already defined
@@ -149,13 +153,15 @@ void TRACE_define_type (const char *type,
     if (IS_TRACING_TASKS) pajeDefineContainerType ("task", type, "task");
     if (IS_TRACING_TASKS) pajeDefineStateType ("task-state", "task", "task-state");
   }
-  char *val_one = xbt_strdup ("1");
+  val_one = xbt_strdup ("1");
   xbt_dict_set (defined_types, type, &val_one, xbt_free);
 }
 
 int TRACE_create_category (const char *category,
                const char *type, const char *parent_category)
 {
+  char state[100];
+  char *val_one = NULL;
   if (!IS_TRACING) return 1;
 
   //check if type is defined
@@ -176,13 +182,13 @@ int TRACE_create_category (const char *category,
   pajeCreateContainer(MSG_get_clock(), category, type, parent_category, category);
 
   /* for registering application categories on top of platform */
-  char state[100];
+
   snprintf (state, 100, "b%s", category);
   if (IS_TRACING_PLATFORM) pajeDefineVariableType (state, "LINK", state);
   snprintf (state, 100, "p%s", category);
   if (IS_TRACING_PLATFORM) pajeDefineVariableType (state, "HOST", state);
 
-  char *val_one = xbt_strdup ("1");
+  val_one = xbt_strdup ("1");
   xbt_dict_set (created_categories, category, &val_one, xbt_free);
   return 0;
 }
index 54f3bf6..38564b5 100644 (file)
@@ -17,10 +17,11 @@ void __TRACE_msg_process_init (void)
 
 void __TRACE_msg_process_location (m_process_t process)
 {
+       char name[200], alias[200];
+       m_host_t host = NULL;
   if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME)) return;
 
-  char name[200], alias[200];
-  m_host_t host = MSG_process_get_host (process);
+  host = MSG_process_get_host (process);
   TRACE_process_container (process, name, 200);
   TRACE_process_alias_container (process, host, alias, 200);
 
@@ -34,11 +35,12 @@ void __TRACE_msg_process_location (m_process_t process)
 
 void __TRACE_msg_process_present (m_process_t process)
 {
+       char alias[200];
+       m_host_t host = NULL;
   if (!IS_TRACING_PROCESSES) return;
 
   //updating presence state of this process location
-  char alias[200];
-  m_host_t host = MSG_process_get_host (process);
+  host = MSG_process_get_host (process);
   TRACE_process_alias_container (process, host, alias, 200);
   pajePushState (MSG_get_clock(), "presence", alias, "presence");
 }
@@ -48,6 +50,7 @@ void __TRACE_msg_process_present (m_process_t process)
  */
 void TRACE_msg_set_process_category (m_process_t process, const char *category)
 {
+       char name[200];
   if (!IS_TRACING) return;
 
   //set process category
@@ -58,7 +61,6 @@ void TRACE_msg_set_process_category (m_process_t process, const char *category)
   __TRACE_msg_process_present (process);
 
   //create container of type "process" to indicate behavior
-  char name[200];
   TRACE_process_container (process, name, 200);
   if (IS_TRACING_PROCESSES) pajeCreateContainer (MSG_get_clock(), name, "process", category, name);
   if (IS_TRACING_PROCESSES) pajeSetState (MSG_get_clock(), "process-state", name, "executing");
@@ -69,10 +71,10 @@ void TRACE_msg_set_process_category (m_process_t process, const char *category)
  */
 void TRACE_msg_process_change_host (m_process_t process, m_host_t old_host, m_host_t new_host)
 {
+       char alias[200];
   if (!(IS_TRACING_PROCESSES || IS_TRACING_VOLUME) || !IS_TRACED(process)) return;
 
   //disabling presence in old_host (__TRACE_msg_process_not_present)
-  char alias[200];
   TRACE_process_alias_container (process, old_host, alias, 200);
   if (IS_TRACING_PROCESSES) pajePopState (MSG_get_clock(), "presence", alias);
 
@@ -82,55 +84,55 @@ void TRACE_msg_process_change_host (m_process_t process, m_host_t old_host, m_ho
 
 void TRACE_msg_process_kill (m_process_t process)
 {
+       char name[200];
   if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
 
-  char name[200];
   TRACE_process_container (process, name, 200);
   pajeDestroyContainer (MSG_get_clock(), "process", name);
 }
 
 void TRACE_msg_process_suspend (m_process_t process)
-{
+{  char name[200];
   if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
 
-  char name[200];
   TRACE_process_container (process, name, 200);
   pajeSetState (MSG_get_clock(), "process-state", name, "suspend");
 }
 
 void TRACE_msg_process_resume (m_process_t process)
 {
+  char name[200];
   if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
 
-  char name[200];
   TRACE_process_container (process, name, 200);
   pajeSetState (MSG_get_clock(), "process-state", name, "executing");
 }
 
 void TRACE_msg_process_sleep_in (m_process_t process)
 {
+       char name[200];
   if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
 
-  char name[200];
   TRACE_process_container (process, name, 200);
   pajeSetState (MSG_get_clock(), "process-state", name, "sleep");
 }
 
 void TRACE_msg_process_sleep_out (m_process_t process)
 {
+       char name[200];
   if (!IS_TRACING_PROCESSES || !IS_TRACED(process)) return;
 
-  char name[200];
   TRACE_process_container (process, name, 200);
   pajeSetState (MSG_get_clock(), "process-state", name, "executing");
 }
 
 void TRACE_msg_process_end (m_process_t process)
 {
+       char name[200], alias[200];
+       m_host_t host = NULL;
   if (!IS_TRACED(process)) return;
 
-  char name[200], alias[200];
-  m_host_t host = MSG_process_get_host (process);
+  host = MSG_process_get_host (process);
   TRACE_process_container (process, name, 200);
   TRACE_process_alias_container (process, host, alias, 200);
   if (IS_TRACING_PROCESSES) pajeDestroyContainer (MSG_get_clock(), "process", name);
index 10f95ab..adfbc59 100644 (file)
@@ -20,8 +20,9 @@ void __TRACE_msg_init (void)
 void __TRACE_current_category_set (m_task_t task)
 {
   char processid[100];
+  char *var_cpy = NULL;
   snprintf (processid, 100, "%p", SIMIX_process_self());
-  char *var_cpy = xbt_strdup (task->category);
+  var_cpy = xbt_strdup (task->category);
   xbt_dict_set (current_task_category, processid, var_cpy, xbt_free);
 }
 
@@ -41,46 +42,52 @@ char *__TRACE_current_category_get (smx_process_t proc)
 
 void __TRACE_task_location (m_task_t task)
 {
+       char container[200];
+       char name[200], alias[200];
+       char *val_one = NULL;
+       m_process_t process = NULL;
+       m_host_t host = NULL;
   if (!IS_TRACING_TASKS) return;
-  char container[200];
-  m_process_t process = MSG_process_self();
-  m_host_t host = MSG_process_get_host (process);
+  process = MSG_process_self();
+  host = MSG_process_get_host (process);
 
   //tasks are grouped by host
   TRACE_host_container (host, container, 200);
-
-  char name[200], alias[200];
   TRACE_task_container (task, name, 200);
   TRACE_task_alias_container (task, process, host, alias, 200);
   //check if task container is already created
   if (!xbt_dict_get_or_null (task_containers, alias)){
     pajeCreateContainer (MSG_get_clock(), alias, "TASK", container, name);
     pajeSetState (MSG_get_clock(), "category", alias, task->category);
-    char *val_one = xbt_strdup ("1");
+    val_one = xbt_strdup ("1");
     xbt_dict_set (task_containers, alias, val_one, xbt_free);
   }
 }
 
 void __TRACE_task_location_present (m_task_t task)
 {
+       char alias[200];
+       m_process_t process = NULL;
+       m_host_t host = NULL;
   if (!IS_TRACING_TASKS) return;
   //updating presence state of this task location
-  m_process_t process = MSG_process_self();
-  m_host_t host = MSG_process_get_host (process);
+  process = MSG_process_self();
+  host = MSG_process_get_host (process);
 
-  char alias[200];
   TRACE_task_alias_container (task, process, host, alias, 200);
   pajePushState (MSG_get_clock(), "presence", alias, "presence");
 }
 
 void __TRACE_task_location_not_present (m_task_t task)
 {
+       char alias[200];
+       m_process_t process = NULL;
+       m_host_t host = NULL;
   if (!IS_TRACING_TASKS) return;
   //updating presence state of this task location
-  m_process_t process = MSG_process_self();
-  m_host_t host = MSG_process_get_host (process);
+  process = MSG_process_self();
+  host = MSG_process_get_host (process);
 
-  char alias[200];
   TRACE_task_alias_container (task, process, host, alias, 200);
   pajePopState (MSG_get_clock(), "presence", alias);
 }
@@ -90,6 +97,7 @@ void __TRACE_task_location_not_present (m_task_t task)
  */
 void TRACE_msg_set_task_category(m_task_t task, const char *category)
 {
+       char name[200];
   if (!IS_TRACING) return;
 
   //set task category
@@ -100,7 +108,6 @@ void TRACE_msg_set_task_category(m_task_t task, const char *category)
   __TRACE_task_location (task);
   __TRACE_task_location_present (task);
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   //create container of type "task" to indicate behavior
   if (IS_TRACING_TASKS) pajeCreateContainer (MSG_get_clock(), name, "task", category, name);
@@ -118,9 +125,9 @@ void TRACE_msg_task_create (m_task_t task)
 /* MSG_task_execute related functions */
 void TRACE_msg_task_execute_start (m_task_t task)
 {
+       char name[200];
   if (!IS_TRACING || !IS_TRACED(task)) return;
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "execute");
 
@@ -129,9 +136,9 @@ void TRACE_msg_task_execute_start (m_task_t task)
 
 void TRACE_msg_task_execute_end (m_task_t task)
 {
+       char name[200];
   if (!IS_TRACING || !IS_TRACED(task)) return;
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
 
@@ -141,9 +148,9 @@ void TRACE_msg_task_execute_end (m_task_t task)
 /* MSG_task_destroy related functions */
 void TRACE_msg_task_destroy (m_task_t task)
 {
+       char name[200];
   if (!IS_TRACING || !IS_TRACED(task)) return;
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajeDestroyContainer (MSG_get_clock(), "task", name);
 
@@ -163,9 +170,9 @@ void TRACE_msg_task_get_start (void)
 
 void TRACE_msg_task_get_end (double start_time, m_task_t task)
 {
+       char name[200];
   if (!IS_TRACING || !IS_TRACED(task)) return;
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
 
@@ -178,9 +185,9 @@ void TRACE_msg_task_get_end (double start_time, m_task_t task)
 /* MSG_task_put related functions */
 int TRACE_msg_task_put_start (m_task_t task)
 {
+       char name[200];
   if (!IS_TRACING || !IS_TRACED(task)) return 0;
 
-  char name[200];
   TRACE_task_container (task, name, 200);
   if (IS_TRACING_TASKS) pajePopState (MSG_get_clock(), "task-state", name);
   if (IS_TRACING_TASKS) pajePushState (MSG_get_clock(), "task-state", name, "communicate");
index eafa26a..590a054 100644 (file)
 
 void __TRACE_msg_volume_start (m_task_t task)
 {
+       m_process_t process = NULL;
+       m_host_t host = NULL;
+       char process_name[200], process_alias[200];
+       char task_name[200];
+       double volume = 0;
   if (!IS_TRACING_VOLUME) return;
 
   /* check if task is traced */
   if (!IS_TRACED(task)) return;
 
   /* check if process is traced */
-  m_process_t process = MSG_process_self ();
+  process = MSG_process_self ();
   if (!IS_TRACED(process)) return;
 
-  char process_name[200], process_alias[200];
-  m_host_t host = MSG_process_get_host (process);
+  host = MSG_process_get_host (process);
   TRACE_process_container (process, process_name, 200);
   TRACE_process_alias_container (process, host, process_alias, 200);
-  char task_name[200];
   TRACE_task_container (task, task_name, 200);
 
-  double volume = MSG_task_get_data_size (task);
+  volume = MSG_task_get_data_size (task);
 
   pajeStartLinkWithVolume (MSG_get_clock(), "volume", "0", task->category, process_alias, task_name, volume);
 }
 
 void __TRACE_msg_volume_finish (m_task_t task)
 {
+       char process_name[200], process_alias[200];
+       char task_name[200];
+       m_process_t process = NULL;
+       m_host_t host = NULL;
   if (!IS_TRACING_VOLUME) return;
 
   /* check if task is traced */
   if (!IS_TRACED(task)) return;
 
   /* check if process is traced */
-  m_process_t process = MSG_process_self ();
+  process = MSG_process_self ();
   if (!IS_TRACED(process)) return;
 
-  char process_name[200], process_alias[200];
-  m_host_t host = MSG_process_get_host (process);
+  host = MSG_process_get_host (process);
   TRACE_process_container (process, process_name, 200);
   TRACE_process_alias_container (process, host, process_alias, 200);
-  char task_name[200];
   TRACE_task_container (task, task_name, 200);
 
   pajeEndLink (MSG_get_clock(), "volume", "0", task->category, process_alias, task_name);
index 848eb6f..c95ac72 100644 (file)
@@ -12,10 +12,11 @@ static long long int counter = 0; /* to uniquely identify simix actions */
 
 void TRACE_smx_action_execute (smx_action_t act)
 {
+       char *category = NULL;
   if (!IS_TRACING) return;
 
   act->counter = counter++;
-  char *category = __TRACE_current_category_get (SIMIX_process_self());
+  category = __TRACE_current_category_get (SIMIX_process_self());
   if (category){
        act->category = xbt_new (char, strlen (category)+1);
        strncpy (act->category, category, strlen(category)+1);
@@ -24,10 +25,11 @@ void TRACE_smx_action_execute (smx_action_t act)
 
 void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
 {
+       char *category = NULL;
   if (!IS_TRACING) return;
 
   act->counter = counter++;
-  char *category = __TRACE_current_category_get (proc);
+  category = __TRACE_current_category_get (proc);
   if (category){
     act->category = xbt_strdup (category);
   }
index b04ade2..ca683f5 100644 (file)
@@ -45,6 +45,7 @@ void __TRACE_surf_init (void)
 
 static char *strsplit (char *input, int field, char del) //caller should free the returned string
 {
+       char *ret = NULL;
   int length = strlen(input), i;
   int s = 0, e = length+1;
   int current_field = 0;
@@ -60,7 +61,7 @@ static char *strsplit (char *input, int field, char del) //caller should free th
      }
   }
   //copy string from s to e (with length equal to e-s) and return
-  char *ret = malloc ((e-s+2)*sizeof(char));
+  ret = malloc ((e-s+2)*sizeof(char));
   strncpy (ret, input+s, e-s+1);
   ret[e-s+1] = '\0';
   return ret;
@@ -68,22 +69,24 @@ static char *strsplit (char *input, int field, char del) //caller should free th
 
 void __TRACE_surf_finalize (void)
 {
+       xbt_dict_cursor_t cursor = NULL;
+       unsigned int cursor_ar = 0;
+    char *key, *value, *res;
+    char *resource;
+    char *aux = NULL;
+    char *var_cpy = NULL;
+    xbt_dynar_t resources = NULL;
   if (!IS_TRACING_PLATFORM) return;
   if (!xbt_dict_length(last_platform_variables)){
     return;
   }else{
-    xbt_dict_cursor_t cursor = NULL;
-    unsigned int cursor_ar = 0;
-    char *key, *value, *res;
-    char *resource;
-
     /* get all resources from last_platform_variables */
-    xbt_dynar_t resources = xbt_dynar_new(sizeof(char*), xbt_free);
+    resources = xbt_dynar_new(sizeof(char*), xbt_free);
     xbt_dict_foreach(last_platform_variables, cursor, key, value) {
       res = strsplit (key, 0, VARIABLE_SEPARATOR);
-      char *aux = strsplit (key, 1, VARIABLE_SEPARATOR);
+      aux = strsplit (key, 1, VARIABLE_SEPARATOR);
       if (strcmp (aux, "Time") == 0){ //only need to add one of three
-        char *var_cpy = xbt_strdup (res);
+        var_cpy = xbt_strdup (res);
         xbt_dynar_push (resources, &var_cpy);
       }
       free (aux);
@@ -93,14 +96,17 @@ void __TRACE_surf_finalize (void)
     /* iterate through resources array */
     xbt_dynar_foreach (resources, cursor_ar, resource) {
       char timekey[100], valuekey[100], variablekey[100];
+      char *time = NULL;
+      char *value = NULL;
+      char *variable = NULL;
       snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
       snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
       snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
 
-      char *time = xbt_dict_get_or_null (last_platform_variables, timekey);
+      time = xbt_dict_get_or_null (last_platform_variables, timekey);
       if (!time) continue;
-      char *value = xbt_dict_get (last_platform_variables, valuekey);
-      char *variable = xbt_dict_get (last_platform_variables, variablekey);
+      value = xbt_dict_get (last_platform_variables, valuekey);
+      variable = xbt_dict_get (last_platform_variables, variablekey);
       pajeSubVariable (atof(time), variable, resource, value);
 
       xbt_dict_remove (last_platform_variables, timekey);
@@ -140,9 +146,18 @@ void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable,
 
 void __TRACE_surf_update_action_state_resource (double now, double delta, const char *variable, const char *resource, double value)
 {
+       char valuestr[100];
+       char nowstr[100], nowdeltastr[100];
+       char timekey[100], valuekey[100], variablekey[100];
+       char *lastvariable = NULL;
+       char *lasttime = NULL;
+    char *lastvalue = NULL;
+    char *nowdeltastr_cpy = NULL;
+    char *valuestr_cpy = NULL;
+    char *variable_cpy = NULL;
+
   if (!IS_TRACING_PLATFORM) return;
 
-  char valuestr[100];
   snprintf (valuestr, 100, "%f", value);
 
   /*
@@ -161,28 +176,26 @@ void __TRACE_surf_update_action_state_resource (double now, double delta, const
    * variables. It should be re-checked before put in production.
    */
 
-  char nowstr[100], nowdeltastr[100];
   snprintf (nowstr, 100, "%.15f", now);
   snprintf (nowdeltastr, 100, "%.15f", now+delta);
 
-  char timekey[100], valuekey[100], variablekey[100];
   snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
   snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
   snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
 
-  char *lastvariable = xbt_dict_get_or_null (last_platform_variables, variablekey);
+  lastvariable = xbt_dict_get_or_null (last_platform_variables, variablekey);
   if (lastvariable == NULL){
     __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
     pajeAddVariable (now, variable, resource, valuestr);
-    char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-    char *valuestr_cpy = xbt_strdup (valuestr);
-    char *variable_cpy = xbt_strdup (variable);
+    nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+    valuestr_cpy = xbt_strdup (valuestr);
+    variable_cpy = xbt_strdup (variable);
     xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
     xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
     xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
   }else{
-    char *lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
-    char *lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
+    lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
+    lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
 
     /* check if it is the same variable */
     if (strcmp(lastvariable, variable) == 0){ /* same variable */
@@ -196,8 +209,8 @@ void __TRACE_surf_update_action_state_resource (double now, double delta, const
           /* value has changed, subtract previous value, add new one */
           pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
           pajeAddVariable (atof(nowstr), variable, resource, valuestr);
-          char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-          char *valuestr_cpy = xbt_strdup (valuestr);
+          nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+          valuestr_cpy = xbt_strdup (valuestr);
           xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
           xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
         }
@@ -205,8 +218,8 @@ void __TRACE_surf_update_action_state_resource (double now, double delta, const
         /* the last time is different from new starting time, subtract to lasttime and add from nowstr */
         pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
         pajeAddVariable (atof(nowstr), variable, resource, valuestr);
-        char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-        char *valuestr_cpy = xbt_strdup (valuestr);
+        nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+        valuestr_cpy = xbt_strdup (valuestr);
         xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
         xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
       }
@@ -214,9 +227,9 @@ void __TRACE_surf_update_action_state_resource (double now, double delta, const
       pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
       __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
       pajeAddVariable (now, variable, resource, valuestr);
-      char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-      char *valuestr_cpy = xbt_strdup (valuestr);
-      char *variable_cpy = xbt_strdup (variable);
+      nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+      valuestr_cpy = xbt_strdup (valuestr);
+      variable_cpy = xbt_strdup (variable);
       xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
       xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
       xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
@@ -227,12 +240,13 @@ void __TRACE_surf_update_action_state_resource (double now, double delta, const
 
 void __TRACE_surf_set_resource_variable (double date, const char *variable, const char *resource, double value)
 {
+       char aux[100], key[100];
+       char *last_value = NULL;
   if (!IS_TRACING) return;
-  char aux[100], key[100];
   snprintf (aux, 100, "%f", value);
   snprintf (key, 100, "%s%c%s", resource, VARIABLE_SEPARATOR, variable);
 
-  char *last_value = xbt_dict_get_or_null(resource_variables, key);
+  last_value = xbt_dict_get_or_null(resource_variables, key);
   if (last_value){
     if (atof(last_value) == value){
       return;
@@ -244,6 +258,7 @@ void __TRACE_surf_set_resource_variable (double date, const char *variable, cons
 
 void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
 {
+       char type[100];
   if (!IS_TRACING || !IS_TRACED(smx_action)) return;
 
   if (strcmp (name, "__loopback__")==0 ||
@@ -258,7 +273,6 @@ void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action,
     return;
   }
 
-  char type[100];
   snprintf (type, 100, "b%s", smx_action->category);
   __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
   return;
@@ -266,13 +280,13 @@ void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action,
 
 void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
 {
+       char type[100];
   if (!IS_TRACING || !IS_TRACED(smx_action)) return;
 
   if (value==0){
     return;
   }
 
-  char type[100];
   snprintf (type, 100, "p%s", smx_action->category);
   __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
   return;
@@ -280,10 +294,10 @@ void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action,
 
 void TRACE_surf_link_declaration (char *name, double bw, double lat)
 {
+       double *bw_ptr, *lat_ptr;
   if (!IS_TRACING) return;
   //if (IS_TRACING_PLATFORM) pajeCreateContainerWithBandwidthLatency (SIMIX_get_clock(), name, "LINK", "platform", name, bw, lat);
   //save bw and lat information for this link
-  double *bw_ptr, *lat_ptr;
   bw_ptr = xbt_new (double, 1);
   lat_ptr = xbt_new (double, 1);
   *bw_ptr = bw;
@@ -304,14 +318,17 @@ void TRACE_surf_host_declaration (char *name, double power)
 
 void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst)
 {
+       char srcidstr[100], dstidstr[100];
+       char key[100];
+       char *srcname = NULL;
+       char *dstname = NULL;
+    double *bw = 0;
+    double *lat = 0;
   if (!IS_TRACING) return;
-  char srcidstr[100], dstidstr[100];
   snprintf (srcidstr, 100, "%d", src);
   snprintf (dstidstr, 100, "%d", dst);
-  char *srcname = xbt_dict_get (hosts_id, srcidstr);
-  char *dstname = xbt_dict_get (hosts_id, dstidstr);
-
-  char key[100];
+  srcname = xbt_dict_get (hosts_id, srcidstr);
+  dstname = xbt_dict_get (hosts_id, dstidstr);
   snprintf (key, 100, "l%d-%d", src, dst);
 
   if (strcmp (link_name, "__loopback__")==0 ||
@@ -322,8 +339,8 @@ void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst)
   if (!xbt_dict_get_or_null (created_links, link_name)){
     //if (IS_TRACING_PLATFORM) pajeStartLink (SIMIX_get_clock(), "edge", "platform", "route", srcname, key);
     //if (IS_TRACING_PLATFORM) pajeEndLink (SIMIX_get_clock()+0.1, "edge", "platform", "route", dstname, key);
-    double *bw = xbt_dict_get (link_bandwidth, link_name);
-    double *lat = xbt_dict_get (link_latency, link_name);
+    bw = xbt_dict_get (link_bandwidth, link_name);
+    lat = xbt_dict_get (link_latency, link_name);
     pajeCreateContainerWithBandwidthLatencySrcDst (SIMIX_get_clock(), link_name, "LINK", "platform", link_name, *bw, *lat, srcname, dstname);
     if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "bandwidth", link_name, *bw);
     if (IS_TRACING_PLATFORM) __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "latency", link_name, *lat);
@@ -348,8 +365,8 @@ void TRACE_surf_link_set_latency (double date, char *resource, double latency)
 
 void TRACE_surf_host_define_id (const char *name, int host_id)
 {
+       char strid[100];
   if (!IS_TRACING) return;
-  char strid[100];
   snprintf (strid, 100, "%d", host_id);
   xbt_dict_set (hosts_id, name, strdup(strid), free);
   xbt_dict_set (hosts_id, strid, strdup(name), free);
@@ -358,8 +375,8 @@ void TRACE_surf_host_define_id (const char *name, int host_id)
 /* to trace gtnets */
 void TRACE_surf_gtnets_communicate (void *action, int src, int dst)
 {
+       char key[100], aux[100];
   if (!IS_TRACING) return;
-  char key[100], aux[100];
   snprintf (key, 100, "%p", action);
 
   snprintf (aux, 100, "%d", src);
@@ -370,11 +387,12 @@ void TRACE_surf_gtnets_communicate (void *action, int src, int dst)
 
 int TRACE_surf_gtnets_get_src (void *action)
 {
+       char key[100];
+       char *aux = NULL;
   if (!IS_TRACING) return -1;
-  char key[100];
   snprintf (key, 100, "%p", action);
 
-  char *aux = xbt_dict_get_or_null (gtnets_src, key);
+  aux = xbt_dict_get_or_null (gtnets_src, key);
   if (aux){
        return atoi(aux);
   }else{
@@ -384,11 +402,12 @@ int TRACE_surf_gtnets_get_src (void *action)
 
 int TRACE_surf_gtnets_get_dst (void *action)
 {
+       char key[100];
+       char *aux = NULL;
   if (!IS_TRACING) return -1;
-  char key[100];
   snprintf (key, 100, "%p", action);
 
-  char *aux = xbt_dict_get_or_null (gtnets_dst, key);
+  aux = xbt_dict_get_or_null (gtnets_dst, key);
   if (aux){
        return atoi(aux);
   }else{
@@ -398,8 +417,8 @@ int TRACE_surf_gtnets_get_dst (void *action)
 
 void TRACE_surf_gtnets_destroy (void *action)
 {
-  if (!IS_TRACING) return;
   char key[100];
+  if (!IS_TRACING) return;
   snprintf (key, 100, "%p", action);
   xbt_dict_remove (gtnets_src, key);
   xbt_dict_remove (gtnets_dst, key);
@@ -415,10 +434,9 @@ void TRACE_surf_link_missing (void)
 
 void TRACE_msg_clean (void)
 {
-  __TRACE_surf_finalize();
-
-  xbt_dict_cursor_t cursor = NULL;
   char *key, *value;
+  xbt_dict_cursor_t cursor = NULL;
+  __TRACE_surf_finalize();
 
   /* get all host from host_containers */
   xbt_dict_foreach(host_containers, cursor, key, value) {
@@ -428,9 +446,9 @@ void TRACE_msg_clean (void)
 
 void TRACE_surf_host_vivaldi_parse (char *host, double x, double y, double h)
 {
+       char valuestr[100];
   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
 
-  char valuestr[100];
   snprintf (valuestr, 100, "%g", x);
   pajeSetVariable (0, "vivaldi_x", host, valuestr);
   snprintf (valuestr, 100, "%g", y);
index b69ee94..6c1d84c 100644 (file)
@@ -14,9 +14,14 @@ extern routing_t used_routing;
 
 void __TRACE_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what)
 {
+       char valuestr[100];
+       int src_id, dst_id;
+       xbt_dynar_t route = NULL;
+       unsigned int i;
+    void *link_ptr;
+    char *link = NULL;
   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
 
-  char valuestr[100];
   snprintf (valuestr, 100, "%g", value);
 
   if (strcmp (what, "declare") == 0){
@@ -26,15 +31,12 @@ void __TRACE_link_variable (double time, const char *src, const char *dst, const
 
   if (!used_routing) return;
 
-  int src_id, dst_id;
   src_id = *(int*)xbt_dict_get(used_routing->host_id,src);
   dst_id = *(int*)xbt_dict_get(used_routing->host_id,dst);
-  xbt_dynar_t route = used_routing->get_route(src_id, dst_id);
+  route = used_routing->get_route(src_id, dst_id);
 
-  unsigned int i;
-  void *link_ptr;
   xbt_dynar_foreach(route, i, link_ptr) {
-       char *link = (*(link_CM02_t)link_ptr).lmm_resource.generic_resource.name;
+       link = (*(link_CM02_t)link_ptr).lmm_resource.generic_resource.name;
 
        if (strcmp (what, "set") == 0){
          pajeSetVariable (time, variable, link, valuestr);
@@ -48,9 +50,9 @@ void __TRACE_link_variable (double time, const char *src, const char *dst, const
 
 void __TRACE_host_variable (double time, const char *variable, double value, const char *what)
 {
+       char valuestr[100];
   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
 
-  char valuestr[100];
   snprintf (valuestr, 100, "%g", value);
 
   if (strcmp (what, "declare") == 0){
index 409801c..ab3e89f 100644 (file)
@@ -119,14 +119,16 @@ MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t *task, m_host_t host,
   xbt_ex_t e;
   MSG_error_t ret = MSG_OK;
   smx_comm_t comm;
-
+#ifdef HAVE_TRACING
+  double start_time = 0;
+#endif
   /* We no longer support getting a task from a specific host */
   if (host) THROW_UNIMPLEMENTED;
 
   CHECK_HOST();
 #ifdef HAVE_TRACING
   TRACE_msg_task_get_start ();
-  double start_time = MSG_get_clock();
+  start_time = MSG_get_clock();
 #endif
 
   memset(&comm,0,sizeof(comm));
@@ -183,11 +185,13 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task,
   MSG_error_t ret = MSG_OK;
   simdata_task_t t_simdata = NULL;
   m_process_t process = MSG_process_self();
-  
+#ifdef HAVE_TRACING
+  int call_end = 0;
+#endif
   CHECK_HOST();
 
 #ifdef HAVE_TRACING
-  int call_end = TRACE_msg_task_put_start (task); //must be after CHECK_HOST()
+  call_end = TRACE_msg_task_put_start (task); //must be after CHECK_HOST()
 #endif
 
 
index 694b8e8..c170565 100644 (file)
@@ -52,12 +52,14 @@ static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
                               tmgr_trace_t state_trace,
                               xbt_dict_t cpu_properties)
 {
-#ifdef HAVE_TRACING
+  cpu_Cas01_im_t cpu = NULL;
+  s_surf_action_cpu_Cas01_im_t action;
+  cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
+
+  #ifdef HAVE_TRACING
   TRACE_surf_host_declaration (name, power_scale * power_peak);
-#endif
+  #endif
 
-  cpu_Cas01_im_t cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
-  s_surf_action_cpu_Cas01_im_t action;
   xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
               "Host '%s' declared several times in the platform file", name);
   cpu->generic_resource.model = surf_cpu_model;