Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last bunch of codacy treats for tonight. Stop.
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 24 May 2017 00:35:16 +0000 (02:35 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 24 May 2017 00:35:16 +0000 (02:35 +0200)
examples/msg/app-chainsend/iterator.c
examples/msg/dht-chord/dht-chord.c
examples/msg/mc/electric_fence.c
examples/smpi/smpi_msg_masterslave/masterslave_mailbox_smpi.c
src/xbt/automaton/automaton.c
src/xbt/mmalloc/mm_module.c

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 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 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);
   }