From 4e3a5dfcf8e95dedcf2c6db54f782eccfd5554d9 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 24 May 2017 22:12:16 +0200 Subject: [PATCH] further codacy cleanups --- examples/msg/app-bittorrent/peer.c | 3 +-- examples/msg/dht-kademlia/dht-kademlia.c | 6 ++---- examples/msg/dht-pastry/dht-pastry.c | 5 ++--- src/xbt/dict_cursor.c | 4 +--- teshsuite/msg/host_on_off/host_on_off.c | 3 +-- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/examples/msg/app-bittorrent/peer.c b/examples/msg/app-bittorrent/peer.c index 172199aa39..d7875192ce 100644 --- a/examples/msg/app-bittorrent/peer.c +++ b/examples/msg/app-bittorrent/peer.c @@ -672,9 +672,8 @@ void update_interested_after_receive(peer_t peer) char *key; xbt_dict_cursor_t cursor; connection_t connection; - int interested; xbt_dict_foreach(peer->peers, cursor, key, connection) { - interested = 0; + int interested = 0; if (connection->am_interested != 0) { //Check if the peer still has a piece we want. for (int i = 0; i < FILE_PIECES; i++) { diff --git a/examples/msg/dht-kademlia/dht-kademlia.c b/examples/msg/dht-kademlia/dht-kademlia.c index 439ad0f7dc..317a646efb 100644 --- a/examples/msg/dht-kademlia/dht-kademlia.c +++ b/examples/msg/dht-kademlia/dht-kademlia.c @@ -183,8 +183,6 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ unsigned int answers; unsigned int destination_found = 0; unsigned int nodes_added = 0; - double time_beginreceive; - double timeout; double global_timeout = MSG_get_clock() + find_node_global_timeout; unsigned int steps = 0; @@ -203,9 +201,9 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ answers = 0; queries = send_find_node_to_best(node, node_list); nodes_added = 0; - timeout = MSG_get_clock() + find_node_timeout; + double timeout = MSG_get_clock() + find_node_timeout; steps++; - time_beginreceive = MSG_get_clock(); + double time_beginreceive = MSG_get_clock(); do { if (node->receive_comm == NULL) { node->task_received = NULL; diff --git a/examples/msg/dht-pastry/dht-pastry.c b/examples/msg/dht-pastry/dht-pastry.c index 782b7bad49..b9cac1eb3a 100644 --- a/examples/msg/dht-pastry/dht-pastry.c +++ b/examples/msg/dht-pastry/dht-pastry.c @@ -230,7 +230,6 @@ static void handle_task(node_t node, msg_task_t task) { int j; int min; int max; - int d; int next; msg_task_t task_sent; task_data_t req_data; @@ -303,11 +302,11 @@ static void handle_task(node_t node, msg_task_t task) { min = (node->id==task_data->answer_id) ? 0 : shl(node->id, task_data->answer_id); max = shl(node->id, task_data->sender_id)+1; for (i=min;iid, i); + int d = domain(node->id, i); for (j=0; jrouting_table[i][j] = task_data->state->routing_table[i][j]; - } + } node->ready--; // if the node is ready, do all the pending tasks and send update to known nodes diff --git a/src/xbt/dict_cursor.c b/src/xbt/dict_cursor.c index d9f3b14664..38c7930270 100644 --- a/src/xbt/dict_cursor.c +++ b/src/xbt/dict_cursor.c @@ -27,9 +27,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict_cursor, xbt_dict, "To traverse dictiona */ inline xbt_dict_cursor_t xbt_dict_cursor_new(const xbt_dict_t dict) { - xbt_dict_cursor_t res = NULL; - - res = xbt_new(s_xbt_dict_cursor_t, 1); + xbt_dict_cursor_t res = xbt_new(s_xbt_dict_cursor_t, 1); res->dict = dict; xbt_dict_cursor_rewind(res); diff --git a/teshsuite/msg/host_on_off/host_on_off.c b/teshsuite/msg/host_on_off/host_on_off.c index c7df9067a7..f714d3f12a 100644 --- a/teshsuite/msg/host_on_off/host_on_off.c +++ b/teshsuite/msg/host_on_off/host_on_off.c @@ -40,10 +40,9 @@ static int master(int argc, char *argv[]) double task_comm_size = 1E6; const char * mailbox = "jupi"; - msg_task_t task = NULL; msg_host_t jupiter = MSG_host_by_name("Jupiter"); - task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL); + msg_task_t task = MSG_task_create("task on", task_comp_size, task_comm_size, NULL); XBT_INFO("Sending \"%s\"", task->name); if (MSG_task_send_with_timeout(task, mailbox, 1) != MSG_OK) MSG_task_destroy(task); -- 2.20.1