Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
morning routine of chasings sonar bugs
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 28 Jul 2016 08:34:38 +0000 (10:34 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 28 Jul 2016 08:34:38 +0000 (10:34 +0200)
src/msg/msg_task.cpp
src/msg/msg_vm.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp

index a19d803..dee4345 100644 (file)
@@ -161,7 +161,7 @@ void MSG_task_set_copy_callback(void (*callback) (msg_task_t task, msg_process_t
 msg_process_t MSG_task_get_sender(msg_task_t task)
 {
   xbt_assert(task, "Invalid parameters");
 msg_process_t MSG_task_get_sender(msg_task_t task)
 {
   xbt_assert(task, "Invalid parameters");
-  return ((simdata_task_t) task->simdata)->sender;
+  return (static_cast<simdata_task_t> (task->simdata)->sender);
 }
 
 /** \ingroup m_task_management
 }
 
 /** \ingroup m_task_management
@@ -172,7 +172,7 @@ msg_process_t MSG_task_get_sender(msg_task_t task)
 msg_host_t MSG_task_get_source(msg_task_t task)
 {
   xbt_assert(task, "Invalid parameters");
 msg_host_t MSG_task_get_source(msg_task_t task)
 {
   xbt_assert(task, "Invalid parameters");
-  return ((simdata_task_t) task->simdata)->source;
+  return (static_cast<simdata_task_t> (task->simdata)->source);
 }
 
 /** \ingroup m_task_management
 }
 
 /** \ingroup m_task_management
@@ -326,7 +326,7 @@ void MSG_task_set_bound(msg_task_t task, double bound)
   xbt_assert(task, "Invalid parameter");
   xbt_assert(task->simdata, "Invalid parameter");
 
   xbt_assert(task, "Invalid parameter");
   xbt_assert(task->simdata, "Invalid parameter");
 
-  if (bound == 0)
+  if (bound < 1e-12) /* close enough to 0 without any floating precision surprise */
     XBT_INFO("bound == 0 means no capping (i.e., unlimited).");
 
   task->simdata->bound = bound;
     XBT_INFO("bound == 0 means no capping (i.e., unlimited).");
 
   task->simdata->bound = bound;
@@ -390,24 +390,19 @@ void MSG_task_set_affinity(msg_task_t task, msg_host_t host, unsigned long mask)
     return;
   }
 
     return;
   }
 
-  {
-    simgrid::simix::Exec *compute = task->simdata->compute;
-    msg_host_t host_now = compute->host;  // simix_private.h is necessary
-    if (host_now != host) {
-      /* task is not yet executed on this host */
-      XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host),
-               MSG_task_get_name(task));
-      return;
-    }
-
-    /* task is being executed on this host. so change the affinity now */
-    {
-      /* check it works. remove me if it works. */
-      xbt_assert((unsigned long)(uintptr_t) xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db,
-                 (char *) host, sizeof(msg_host_t)) == mask);
-    }
-
-    XBT_INFO("set affinity(0x%04lx@%s) for %s", mask, MSG_host_get_name(host), MSG_task_get_name(task));
-    simcall_execution_set_affinity(task->simdata->compute, host, mask);
+  simgrid::simix::Exec *compute = task->simdata->compute;
+  msg_host_t host_now = compute->host;  // simix_private.h is necessary
+  if (host_now != host) {
+    /* task is not yet executed on this host */
+    XBT_INFO("set affinity(0x%04lx@%s) for %s (not active now)", mask, MSG_host_get_name(host),
+             MSG_task_get_name(task));
+    return;
   }
   }
+
+  /* task is being executed on this host. so change the affinity now */
+  /* check it works. remove me if it works. */
+  xbt_assert(static_cast<unsigned long>((uintptr_t) xbt_dict_get_or_null_ext(task->simdata->affinity_mask_db,
+             (char*)(host), sizeof(msg_host_t))) == mask);
+  XBT_INFO("set affinity(0x%04lx@%s) for %s", mask, MSG_host_get_name(host), MSG_task_get_name(task));
+  simcall_execution_set_affinity(task->simdata->compute, host, mask);
 }
 }
index c341322..0589041 100644 (file)
@@ -669,7 +669,7 @@ static int migration_tx_fun(int argc, char *argv[])
   if (ramsize == 0)
     XBT_WARN("migrate a VM, but ramsize is zero");
 
   if (ramsize == 0)
     XBT_WARN("migrate a VM, but ramsize is zero");
 
-  if (max_downtime == 0) {
+  if (max_downtime <= 0) {
     XBT_WARN("use the default max_downtime value 30ms");
     max_downtime = 0.03;
   }
     XBT_WARN("use the default max_downtime value 30ms");
     max_downtime = 0.03;
   }
index 5683d9e..da719bf 100644 (file)
@@ -60,15 +60,21 @@ int main(int argc, char **argv)
         XBT_DEBUG("\t Running that model");
         running = 1;
       }
         XBT_DEBUG("\t Running that model");
         running = 1;
       }
-      while ((action = surf_model_extract_failed_action_set((surf_model_t)model))) {
+
+      action = surf_model_extract_failed_action_set(static_cast<surf_model_t>(model));
+      while (action != nullptr) {
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Failed Action: %p", action);
         action->unref();
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Failed Action: %p", action);
         action->unref();
+        action = surf_model_extract_failed_action_set(static_cast<surf_model_t>(model));
       }
       }
-      while ((action = surf_model_extract_done_action_set((surf_model_t)model))) {
+
+      action = surf_model_extract_done_action_set(static_cast<surf_model_t>(model));
+      while (action != nullptr){
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Done Action: %p", action);
         action->unref();
         XBT_INFO("   * Done Action");
         XBT_DEBUG("\t * Done Action: %p", action);
         action->unref();
+        action = surf_model_extract_done_action_set(static_cast<surf_model_t>(model));
       }
     }
   } while (running && surf_solve(-1.0) >= 0.0);
       }
     }
   } while (running && surf_solve(-1.0) >= 0.0);