Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 24 May 2017 07:37:54 +0000 (09:37 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 24 May 2017 07:37:54 +0000 (09:37 +0200)
22 files changed:
examples/msg/app-chainsend/iterator.c
examples/msg/dht-chord/dht-chord.c
examples/msg/dht-kademlia/answer.c
examples/msg/dht-kademlia/dht-kademlia.c
examples/msg/mc/electric_fence.c
examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
include/simgrid/kernel/future.hpp
include/xbt/str.h
sonar-project.properties
src/instr/instr_paje_trace.cpp
src/simgrid/sg_config.cpp
src/simix/simcalls.py
src/smpi/smpi_group.cpp
src/smpi/smpi_group.hpp
src/xbt/automaton/automaton.c
src/xbt/mmalloc/mm_module.c
src/xbt/xbt_os_thread.c
teshsuite/java/CMakeLists.txt
teshsuite/java/semaphoreGC/semaphoreGC.tesh [moved from teshsuite/java/semaphoreGC/SemaphoreGC.tesh with 100% similarity]
teshsuite/java/sleepHostOff/sleepHostOff.tesh [moved from teshsuite/java/sleepHostOff/SleepHostOff.tesh with 100% similarity]
tools/cmake/MaintainerMode.cmake
tools/tesh/tesh.py

index e36ab5d..a6f7e44 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2012, 2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -27,11 +26,10 @@ xbt_dynar_iterator_t xbt_dynar_iterator_new(xbt_dynar_t list, xbt_dynar_t (*crit
 /* Returns the next element iterated by iterator it, NULL if there are no more elements */
 void *xbt_dynar_iterator_next(xbt_dynar_iterator_t it)
 {
-  int *next;
   if (it->current >= it->length) {
     return NULL;
   } else {
-    next = xbt_dynar_get_ptr(it->indices_list, it->current);
+    int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
     it->current++;
     return xbt_dynar_get_ptr(it->list, *next);
   }
index 717b19d..66faa97 100644 (file)
@@ -327,7 +327,6 @@ void quit_notify(node_t node)
   get_mailbox(node->pred_id, mailbox);
   task_data_t req_data_s = xbt_new0(s_task_data_t,1);
   req_data_s->type = TASK_SUCCESSOR_LEAVING;
-  req_data_s->request_id = node->fingers[0].id;
   req_data_s->request_id = node->pred_id;
   get_mailbox(node->id, req_data_s->answer_to);
   req_data_s->issuer_host_name = MSG_host_get_name(MSG_host_self());
index 1cd48a0..6fb5f75 100644 (file)
@@ -109,15 +109,14 @@ void answer_trim(answer_t answer)
   */
 void answer_add_bucket(bucket_t bucket, answer_t answer)
 {
-  unsigned int cpt;
-  unsigned int id;
-  unsigned int distance;
-  node_contact_t contact;
   xbt_assert((bucket != NULL), "Provided a NULL bucket");
   xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL");
+
+  unsigned int cpt;
+  unsigned int id;
   xbt_dynar_foreach(bucket->nodes, cpt, id) {
-    distance = id ^ answer->destination_id;
-    contact = node_contact_new(id, distance);
+    unsigned int distance  = id ^ answer->destination_id;
+    node_contact_t contact = node_contact_new(id, distance);
     xbt_dynar_push(answer->nodes, &contact);
     answer->size++;
   }
index 463fd01..439ad0f 100644 (file)
@@ -360,11 +360,10 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list)
   unsigned int i = 0;
   unsigned int j = 0;
   unsigned int destination = node_list->destination_id;
-  node_contact_t node_to_query;
   while (j < kademlia_alpha && i < node_list->size) {
     /* We need to have at most "kademlia_alpha" requests each time, according to the protocol */
     /* Gets the node we want to send the query to */
-    node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
+    node_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
     if (node_to_query->id != node->id) {        /* No need to query ourselves */
       send_find_node(node, node_to_query->id, destination);
       j++;
index f260cd9..7d32c04 100644 (file)
@@ -22,10 +22,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(electric_fence, "Example to check the soundness of
 static int server(int argc, char *argv[])
 {
   msg_task_t task1 = NULL, task2 = NULL;
-  msg_comm_t comm_received1 = NULL, comm_received2 = NULL;
 
-  comm_received1 = MSG_task_irecv(&task1, "mymailbox");
-  comm_received2 = MSG_task_irecv(&task2, "mymailbox");
+  msg_comm_t comm_received1 = MSG_task_irecv(&task1, "mymailbox");
+  msg_comm_t comm_received2 = MSG_task_irecv(&task2, "mymailbox");
 
   MSG_comm_wait(comm_received1, -1);
   MSG_comm_wait(comm_received2, -1);
index 7180271..51cc923 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -15,18 +14,15 @@ static int master(int argc, char *argv[])
   double task_comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s");
   long slaves_count = xbt_str_parse_int(argv[4], "Invalid amount of slaves: %s");
 
-  int i;
-
   XBT_INFO("Got %ld slaves and %ld tasks to process", slaves_count, number_of_tasks);
 
-  for (i = 0; i < number_of_tasks; i++) {
+  for (int i = 0; i < number_of_tasks; i++) {
     char mailbox[256];
     char sprintf_buffer[256];
-    msg_task_t task = NULL;
 
     snprintf(mailbox,256, "slave-%ld", i % slaves_count);
     snprintf(sprintf_buffer,256, "Task_%d", i);
-    task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
+    msg_task_t task = MSG_task_create(sprintf_buffer, task_comp_size, task_comm_size, NULL);
     if (number_of_tasks < 10000 || i % 10000 == 0)
       XBT_INFO("Sending \"%s\" (of %ld) to mailbox \"%s\"", task->name, number_of_tasks, mailbox);
 
@@ -34,7 +30,7 @@ static int master(int argc, char *argv[])
   }
 
   XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
-  for (i = 0; i < slaves_count; i++) {
+  for (int i = 0; i < slaves_count; i++) {
     char mailbox[80];
 
     snprintf(mailbox,80, "slave-%ld", i % slaves_count);
index 8f0c25d..777a9f4 100644 (file)
@@ -282,7 +282,7 @@ template<class T>
 class Future {
 public:
   Future() = default;
-  Future(std::shared_ptr<FutureState<T>> state): state_(std::move(state)) {}
+  Future(std::shared_ptr<FutureState<T>> state) : state_(std::move(state)) {}
 
   // Move type:
   Future(Future&) = delete;
index 0f10bef..c89cf98 100644 (file)
@@ -55,11 +55,10 @@ static inline unsigned int xbt_str_hash_ext(const char *str, int str_len)
 {
 #ifdef XBT_DJB2_HASH_FUNCTION
   /* fast implementation of djb2 algorithm */
-  int c;
   unsigned int hash = 5381;
 
   while (str_len--) {
-    c = *str++;
+    int c = *str++;
     hash = ((hash << 5) + hash) + c;    /* hash * 33 + c */
   }
 # elif defined(XBT_FNV_HASH_FUNCTION)
index 0b96f58..2151a65 100644 (file)
@@ -13,7 +13,7 @@ sonar.sources=src,examples,include,teshsuite
 
 
 # Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5,f1
+sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,c5a,c5b,f1
 
 # The Object.finalize() method should not be overriden
 # But we need to clean the native memory with JNI
@@ -57,8 +57,10 @@ sonar.issue.ignore.multicriteria.c4b.resourceKey=examples/**/*.hpp
 
 # Replace alternative operator "not" with "!"
 # I like it better so please leave me alone
-sonar.issue.ignore.multicriteria.c5.ruleKey=cpp:S3659
-sonar.issue.ignore.multicriteria.c5.resourceKey=**/*.cpp
+sonar.issue.ignore.multicriteria.c5a.ruleKey=cpp:S3659
+sonar.issue.ignore.multicriteria.c5a.resourceKey=**/*.cpp
+sonar.issue.ignore.multicriteria.c5b.ruleKey=cpp:S3659
+sonar.issue.ignore.multicriteria.c5b.resourceKey=**/*.hpp
 
 
 # "reinterpret_cast" should not be used
index 463cadf..dce4b1e 100644 (file)
@@ -244,7 +244,6 @@ void DefineContainerEvent::print() {
 }
 
 
-
 DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type)
 {
   this->event_type                           = PAJE_DefineVariableType;
index 22ac710..8aa0849 100644 (file)
@@ -575,7 +575,7 @@ void sg_config_init(int *argc, char **argv)
 
 void sg_config_finalize()
 {
-  if (!_sg_cfg_init_status)
+  if (not _sg_cfg_init_status)
     return;                     /* Not initialized yet. Nothing to do */
 
   xbt_cfg_free(&simgrid_config);
index d0f33d4..7474d22 100755 (executable)
@@ -233,13 +233,13 @@ def header(name):
 
 
 def handle(fd, func, simcalls, guarded_simcalls):
-    def nonempty(e): 
+    def nonempty(e):
         return e != ''
     fd.write('\n'.join(filter(nonempty, (func(simcall) for simcall in simcalls))))
 
-    for guard, list in guarded_simcalls.items():
+    for guard, ll in guarded_simcalls.items():
         fd.write('\n#if %s\n' % (guard))
-        fd.write('\n'.join(func(simcall) for simcall in list))
+        fd.write('\n'.join(func(simcall) for simcall in ll))
         fd.write('\n#endif\n')
 
 if __name__ == '__main__':
index 590ba5e..f12c5cf 100644 (file)
@@ -24,22 +24,16 @@ Group::Group()
 
 Group::Group(int n) : size_(n)
 {
-  int i;
   rank_to_index_map_ = xbt_new(int, size_);
   index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
   refcount_ = 1;
-  for (i = 0; i < size_; i++) {
+  for (int i = 0; i < size_; i++) {
     rank_to_index_map_[i] = MPI_UNDEFINED;
   }
 }
 
 Group::Group(MPI_Group origin)
 {
-  char *key;
-  char *ptr_rank;
-  xbt_dict_cursor_t cursor = nullptr;
-  
-  int i;
   if(origin != MPI_GROUP_NULL
             && origin != MPI_GROUP_EMPTY)
     {
@@ -47,10 +41,13 @@ Group::Group(MPI_Group origin)
       rank_to_index_map_ = xbt_new(int, size_);
       index_to_rank_map_ = xbt_dict_new_homogeneous(xbt_free_f);
       refcount_ = 1;
-      for (i = 0; i < size_; i++) {
+      for (int i = 0; i < size_; i++) {
         rank_to_index_map_[i] = origin->rank_to_index_map_[i];
       }
 
+      char* key;
+      char* ptr_rank;
+      xbt_dict_cursor_t cursor = nullptr;
       xbt_dict_foreach(origin->index_to_rank_map_, cursor, key, ptr_rank) {
         int * cp = static_cast<int*>(xbt_malloc(sizeof(int)));
         *cp=*reinterpret_cast<int*>(ptr_rank);
@@ -130,13 +127,12 @@ int Group::compare(MPI_Group group2)
   int i;
   int index;
   int rank;
-  int sz;
 
   result = MPI_IDENT;
   if (size_ != group2->size()) {
     result = MPI_UNEQUAL;
   } else {
-    sz = group2->size();
+    int sz = group2->size();
     for (i = 0; i < sz; i++) {
       index = this->index(i);
       rank = group2->rank(index);
index aa01f3c..9c40f5e 100644 (file)
@@ -19,9 +19,9 @@ class Group : public F2C{
     xbt_dict_t index_to_rank_map_;
     int refcount_;
   public:
-    Group();
-    Group(int size);
-    Group(Group* origin);
+    explicit Group();
+    explicit Group(int size);
+    explicit Group(Group* origin);
     ~Group();
 
     void set_mapping(int index, int rank);
index 39ec972..2fb1c6a 100644 (file)
@@ -57,8 +57,7 @@ xbt_automaton_transition_t xbt_automaton_transition_new(xbt_automaton_t a, xbt_a
 }
 
 xbt_automaton_exp_label_t xbt_automaton_exp_label_new(int type, ...){
-  xbt_automaton_exp_label_t label = NULL;
-  label = xbt_new0(struct xbt_automaton_exp_label, 1);
+  xbt_automaton_exp_label_t label = xbt_new0(struct xbt_automaton_exp_label, 1);
   label->type = type;
   xbt_automaton_exp_label_t left;
   xbt_automaton_exp_label_t right;
index 4ca13af..096941c 100644 (file)
@@ -327,7 +327,6 @@ static void mmalloc_fork_child(void)
 /* Initialize the default malloc descriptor. */
 void *mmalloc_preinit(void)
 {
-  int res;
   if (__mmalloc_default_mdp == NULL) {
     if(!xbt_pagesize)
       xbt_pagesize = getpagesize();
@@ -337,8 +336,7 @@ void *mmalloc_preinit(void)
     /* Fixme? only the default mdp in protected against forks */
     // This is mandated to protect the mmalloced areas through forks. Think of tesh.
     // Nah, removing the mutex isn't a good idea either for tesh
-    res = xbt_os_thread_atfork(mmalloc_fork_prepare,  
-                               mmalloc_fork_parent, mmalloc_fork_child);
+    int res = xbt_os_thread_atfork(mmalloc_fork_prepare, mmalloc_fork_parent, mmalloc_fork_child);
     if (res != 0)
       THROWF(system_error,0,"xbt_os_thread_atfork() failed: return value %d",res);
   }
index 613869a..b83e310 100644 (file)
@@ -122,6 +122,7 @@ void xbt_os_thread_mod_postexit(void)
 
   //   if ((errcode=pthread_key_delete(xbt_self_thread_key)))
   //     THROWF(system_error,errcode,"pthread_key_delete failed for xbt_self_thread_key");
+  free(main_thread->name);
   free(main_thread);
   main_thread = NULL;
   thread_mod_inited = 0;
index e782127..2d9d5df 100644 (file)
@@ -27,6 +27,6 @@ set(examples_src ${examples_src} ${sources}
 set(tesh_files   ${tesh_files}                                                                 PARENT_SCOPE)
 
 if(enable_java)
-  ADD_TESH(tesh-java-semaphoreGC  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoreGC  ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoreGC/SemaphoreGC.tesh)
-  ADD_TESH(tesh-java-sleepHostOff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleepHostOff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleepHostOff/SleepHostOff.tesh)
+  ADD_TESH(tesh-java-semaphoreGC  --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/semaphoreGC  ${CMAKE_HOME_DIRECTORY}/teshsuite/java/semaphoreGC/semaphoreGC.tesh)
+  ADD_TESH(tesh-java-sleepHostOff --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/teshsuite/java/sleepHostOff ${CMAKE_HOME_DIRECTORY}/teshsuite/java/sleepHostOff/sleepHostOff.tesh)
 endif()
index af2714f..eff28d8 100644 (file)
@@ -209,7 +209,7 @@ if(enable_maintainer_mode AND NOT WIN32)
       COMMAND ${SED_EXE} -i ${string15} src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i 's/int yyl\;/unsigned int yyl\;/' src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i 's/int surf_parse_leng\;/unsigned int surf_parse_leng\;/' src/surf/xml/simgrid_dtd.c
-      COMMAND ${SED_EXE} -i 's/n = 0\; n < max_size/n = 0\; n < (size_t)max_size/' src/surf/xml/simgrid_dtd.c
+      COMMAND ${SED_EXE} -i 's/n = 0\; n < max_size/n = 0\; n < (size_t) max_size/' src/surf/xml/simgrid_dtd.c
       COMMAND ${SED_EXE} -i "s/register //" src/surf/xml/simgrid_dtd.c
       COMMAND ${CMAKE_COMMAND} -E echo "       Generated surf/xml/simgrid_dtd.c"
 
index 7febe40..be40773 100755 (executable)
@@ -28,7 +28,7 @@ under the terms of the license (GNU LGPL) which comes with this package.
 # print "WARNING: Output were only sorted using the $sort_prefix first chars.\n"
 #    if ( $sort_prefix > 0 );
 # print "WARNING: Use <! output sort 19> to sort by simulated date and process ID only.\n";
-#    
+#
 # print "----8<---------------  Begin of unprocessed observed output (as it should appear in file):\n";
 # map {print "> $_\n"} @{$cmd{'unsorted got'}};
 # print "--------------->8----  End of the unprocessed observed output.\n";
@@ -292,7 +292,7 @@ class Cmd(object):
             self.timeout *= 20
             self.args = TeshState().wrapper + self.args
         elif re.match(".*smpirun.*", self.args) is not None:
-            self.args = "sh " + self.args 
+            self.args = "sh " + self.args
         if TeshState().jenkins and self.timeout != None:
             self.timeout *= 10