From: Frederic Suter Date: Mon, 24 Oct 2016 08:54:13 +0000 (+0200) Subject: vacation commit X-Git-Tag: v3_14~277^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7dc01ca1e4dcb01739599d8eb8268629804d5051 vacation commit chase some sonar minor smells --- diff --git a/examples/msg/actions-comm/actions-comm.c b/examples/msg/actions-comm/actions-comm.c index 8bcbc17cb7..b5dcc48b24 100644 --- a/examples/msg/actions-comm/actions-comm.c +++ b/examples/msg/actions-comm/actions-comm.c @@ -19,7 +19,9 @@ typedef struct { /* Used to implement irecv+wait */ xbt_dynar_t irecvs; /* of msg_comm_t */ xbt_dynar_t tasks; /* of msg_task_t */ -} s_process_globals_t, *process_globals_t; +} s_process_globals_t; + +typedef s_process_globals_t *process_globals_t; /* Helper function */ static double parse_double(const char *string) @@ -172,7 +174,8 @@ static void action_barrier(const char *const *action) ACT_DEBUG("Entering barrier: %s (%d already there)", NAME, processes_arrived_sofar); simcall_mutex_lock(mutex); - if (++processes_arrived_sofar == communicator_size) { + processes_arrived_sofar++; + if (processes_arrived_sofar == communicator_size) { simcall_cond_broadcast(cond); simcall_mutex_unlock(mutex); } else { @@ -203,7 +206,8 @@ static void action_bcast(const char *const *action) const char * process_name = MSG_process_get_name(MSG_process_self()); - char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter++); + char *bcast_identifier = bprintf("bcast_%d", counters->bcast_counter); + counters->bcast_counter++; if (!strcmp(process_name, "p0")) { XBT_DEBUG("%s: %s is the Root", bcast_identifier, process_name); diff --git a/examples/msg/app-bittorrent/connection.h b/examples/msg/app-bittorrent/connection.h index 0bfcde0d95..30e6ba4774 100644 --- a/examples/msg/app-bittorrent/connection.h +++ b/examples/msg/app-bittorrent/connection.h @@ -20,7 +20,9 @@ typedef struct s_connection { unsigned int interested:1; //Indicates if the peer is interested in one of our pieces unsigned int choked_upload:1; //Indicates if the peer is choked for the current peer unsigned int choked_download:1; //Indicates if the peer has choked the current peer -} s_connection_t, *connection_t; +} s_connection_t; + +typedef s_connection_t *connection_t; /** @brief Build a new connection object from the peer id. * @param id id of the peer diff --git a/examples/msg/app-chainsend/broadcaster.h b/examples/msg/app-chainsend/broadcaster.h index e9aca94e69..d4413d4573 100644 --- a/examples/msg/app-chainsend/broadcaster.h +++ b/examples/msg/app-chainsend/broadcaster.h @@ -28,7 +28,9 @@ typedef struct s_broadcaster { xbt_dynar_iterator_t it; int max_pending_sends; xbt_dynar_t pending_sends; -} s_broadcaster_t, *broadcaster_t; +} s_broadcaster_t; + +typedef s_broadcaster_t *broadcaster_t; xbt_dynar_t build_hostlist_from_hostcount(int hostcount); diff --git a/examples/msg/app-chainsend/messages.h b/examples/msg/app-chainsend/messages.h index e90bf626fc..e6855ea264 100644 --- a/examples/msg/app-chainsend/messages.h +++ b/examples/msg/app-chainsend/messages.h @@ -27,7 +27,9 @@ typedef struct s_message { const char *data_block; unsigned int data_length; unsigned int num_pieces; -} s_message_t, *message_t; +} s_message_t; + +typedef s_message_t *message_t; /* Message methods */ msg_task_t task_message_new(e_message_type type, unsigned int len); diff --git a/examples/msg/app-chainsend/peer.h b/examples/msg/app-chainsend/peer.h index 4ed5bcc085..5099d1b84b 100644 --- a/examples/msg/app-chainsend/peer.h +++ b/examples/msg/app-chainsend/peer.h @@ -26,7 +26,8 @@ typedef struct s_peer { xbt_dynar_t pending_recvs; xbt_dynar_t pending_sends; unsigned int total_pieces; -} s_peer_t, *peer_t; +} s_peer_t; +typedef s_peer_t *peer_t; /* Peer: helper functions */ msg_error_t peer_wait_for_message(peer_t peer); diff --git a/examples/msg/app-pmm/app-pmm.c b/examples/msg/app-pmm/app-pmm.c index 7ddb867e1e..e68636f771 100644 --- a/examples/msg/app-pmm/app-pmm.c +++ b/examples/msg/app-pmm/app-pmm.c @@ -20,9 +20,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_pmm, "Messages specific for this msg example"); #define MAILBOX_NAME_SIZE 10 #define NEIGHBOURS_COUNT GRID_SIZE - 1 -/* - * The job sent to every node - */ +/* The job sent to every node */ typedef struct s_node_job{ int row; int col; @@ -30,16 +28,18 @@ typedef struct s_node_job{ int nodes_in_col[NEIGHBOURS_COUNT]; xbt_matrix_t A; xbt_matrix_t B; -} s_node_job_t, *node_job_t; +} s_node_job_t; -/* - * Structure for recovering results - */ +typedef s_node_job_t *node_job_t; + +/* Structure for recovering results */ typedef struct s_result { int row; int col; xbt_matrix_t sC; -} s_result_t, *result_t; +} s_result_t; + +typedef s_result_t *result_t; int node(int argc, char **argv); static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs); @@ -53,7 +53,8 @@ static void task_cleanup(void *arg); int node(int argc, char **argv) { char my_mbox[MAILBOX_NAME_SIZE]; - node_job_t myjob, jobs[GRID_NUM_NODES]; + node_job_t myjob; + node_job_t jobs[GRID_NUM_NODES]; xbt_matrix_t A = NULL; xbt_matrix_t B = NULL; xbt_matrix_t C = NULL; @@ -274,16 +275,17 @@ static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs) jobs[node]->row = row; jobs[node]->col = col; - /* Compute who are the nodes in the same row and column */ - /* than the node receiving this job */ - for (int j = 0, k = 0; j < GRID_SIZE; j++) { + /* Compute who are the nodes in the same row and column than the node receiving this job */ + int k=0; + for (int j = 0; j < GRID_SIZE; j++) { if (node != (GRID_SIZE * row) + j) { jobs[node]->nodes_in_row[k] = (GRID_SIZE * row) + j; k++; } } - for (int j = 0, k = 0; j < GRID_SIZE; j++) { + k=0; + for (int j = 0; j < GRID_SIZE; j++) { if (node != (GRID_SIZE * j) + col) { jobs[node]->nodes_in_col[k] = (GRID_SIZE * j) + col; k++; @@ -296,7 +298,8 @@ static void create_jobs(xbt_matrix_t A, xbt_matrix_t B, node_job_t *jobs) jobs[node]->B = xbt_matrix_new_sub(B, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col, NULL); - if (++col >= GRID_SIZE){ + col++; + if (col >= GRID_SIZE){ col = 0; row++; } diff --git a/examples/msg/cloud-migration/cloud-migration.c b/examples/msg/cloud-migration/cloud-migration.c index 32015e7675..32265f50ca 100644 --- a/examples/msg/cloud-migration/cloud-migration.c +++ b/examples/msg/cloud-migration/cloud-migration.c @@ -55,11 +55,10 @@ static int master_main(int argc, char *argv[]) msg_host_t pm0 = MSG_host_by_name("Fafard"); msg_host_t pm1 = MSG_host_by_name("Tremblay"); msg_host_t pm2 = MSG_host_by_name("Bourassa"); - msg_vm_t vm0, vm1; s_vm_params_t params; memset(¶ms, 0, sizeof(params)); - vm0 = MSG_vm_create_core(pm0, "VM0"); + msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0"); params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes MSG_vm_set_params(vm0, ¶ms); MSG_vm_start(vm0); @@ -80,7 +79,7 @@ static int master_main(int argc, char *argv[]) MSG_vm_destroy(vm0); vm0 = MSG_vm_create_core(pm0, "VM0"); - vm1 = MSG_vm_create_core(pm0, "VM1"); + msg_vm_t vm1 = MSG_vm_create_core(pm0, "VM1"); params.ramsize = 1L * 1000 * 1000 * 1000; // 1Gbytes MSG_vm_set_params(vm0, ¶ms); diff --git a/examples/msg/cloud-two-tasks/cloud-two-tasks.c b/examples/msg/cloud-two-tasks/cloud-two-tasks.c index 285a69a2cf..c9afd7c6db 100644 --- a/examples/msg/cloud-two-tasks/cloud-two-tasks.c +++ b/examples/msg/cloud-two-tasks/cloud-two-tasks.c @@ -14,12 +14,11 @@ static int computation_fun(int argc, char *argv[]) { const char *pr_name = MSG_process_get_name(MSG_process_self()); const char *host_name = MSG_host_get_name(MSG_host_self()); - double clock_sta, clock_end; atask = MSG_task_create("Task1", 1e9, 1e9, NULL); - clock_sta = MSG_get_clock(); + double clock_sta = MSG_get_clock(); XBT_INFO("%s:%s task 1 created %g", host_name, pr_name, clock_sta); MSG_task_execute(atask); - clock_end = MSG_get_clock(); + double clock_end = MSG_get_clock(); XBT_INFO("%s:%s task 1 executed %g", host_name, pr_name, clock_end - clock_sta); @@ -57,10 +56,8 @@ static int master_main(int argc, char *argv[]) { xbt_dynar_t hosts_dynar = MSG_hosts_as_dynar(); msg_host_t pm0 = MSG_host_by_name("Fafard"); - msg_vm_t vm0; - vm0 = MSG_vm_create_core(pm0, "VM0"); + msg_vm_t vm0 = MSG_vm_create_core(pm0, "VM0"); MSG_vm_start(vm0); - //MSG_process_sleep(1); launch_computation_worker(vm0); diff --git a/examples/msg/dht-kademlia/answer.h b/examples/msg/dht-kademlia/answer.h index 03fe76511d..e381816507 100644 --- a/examples/msg/dht-kademlia/answer.h +++ b/examples/msg/dht-kademlia/answer.h @@ -14,7 +14,9 @@ typedef struct s_node_answer { unsigned int destination_id; xbt_dynar_t nodes; //Dynar of node_contact_t unsigned int size; -} s_answer_t, *answer_t; +} s_answer_t; + +typedef s_answer_t *answer_t; #include "node.h" diff --git a/examples/msg/dht-kademlia/dht-kademlia.c b/examples/msg/dht-kademlia/dht-kademlia.c index 1b0dc4460f..ad73ec1477 100644 --- a/examples/msg/dht-kademlia/dht-kademlia.c +++ b/examples/msg/dht-kademlia/dht-kademlia.c @@ -112,7 +112,8 @@ unsigned int join(node_t node, unsigned int id_known) answer_t node_list; msg_error_t status; unsigned int trial = 0; - unsigned int i, answer_got = 0; + unsigned int i; + unsigned int answer_got = 0; /* Add the guy we know to our routing table and ourselves. */ node_routing_table_update(node, node->id); @@ -178,11 +179,13 @@ unsigned int join(node_t node, unsigned int id_known) unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats) { unsigned int i = 0; - unsigned int queries, answers; + unsigned int queries; + unsigned int answers; unsigned int destination_found = 0; unsigned int nodes_added = 0; double time_beginreceive; - double timeout, global_timeout = MSG_get_clock() + find_node_global_timeout; + double timeout; + double global_timeout = MSG_get_clock() + find_node_global_timeout; unsigned int steps = 0; xbt_assert((id_to_find >= 0), "Id supplied incorrect"); @@ -358,7 +361,8 @@ void send_find_node(node_t node, unsigned int id, unsigned int destination) */ unsigned int send_find_node_to_best(node_t node, answer_t node_list) { - unsigned int i = 0, j = 0; + 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) { diff --git a/examples/msg/dht-kademlia/node.c b/examples/msg/dht-kademlia/node.c index 385d0d6b49..97a89a2a06 100644 --- a/examples/msg/dht-kademlia/node.c +++ b/examples/msg/dht-kademlia/node.c @@ -127,8 +127,8 @@ unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix) */ unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits) { - unsigned int j, size = sizeof(unsigned int) * 8; - for (j = 0; j < size; j++) { + unsigned int size = sizeof(unsigned int) * 8; + for (unsigned int j = 0; j < size; j++) { if (((id >> (size - 1 - j)) & 0x1) != 0) { return nb_bits - (j); } diff --git a/examples/msg/dht-kademlia/node.h b/examples/msg/dht-kademlia/node.h index b2ff73394a..0659d7db25 100644 --- a/examples/msg/dht-kademlia/node.h +++ b/examples/msg/dht-kademlia/node.h @@ -17,7 +17,9 @@ typedef struct s_node_contact { unsigned int id; //The node identifier unsigned int distance; //The distance from the node -} s_node_contact_t, *node_contact_t; +} s_node_contact_t; + +typedef s_node_contact_t *node_contact_t; /* Node data */ typedef struct s_node { @@ -30,7 +32,9 @@ typedef struct s_node { unsigned int find_node_success; //Number of find_node which have succeeded. unsigned int find_node_failed; //Number of find_node which have failed. -} s_node_t, *node_t; +} s_node_t; + +typedef s_node_t *node_t; // node functions node_t node_init(unsigned int id); diff --git a/examples/msg/dht-kademlia/routing_table.c b/examples/msg/dht-kademlia/routing_table.c index 20757af158..d39741e4fa 100644 --- a/examples/msg/dht-kademlia/routing_table.c +++ b/examples/msg/dht-kademlia/routing_table.c @@ -13,10 +13,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_routing_table, "Messages specific for /** @brief Initialization of a node routing table. */ routing_table_t routing_table_init(unsigned int node_id) { - unsigned int i; routing_table_t table = xbt_new(s_routing_table_t, 1); table->buckets = xbt_new(s_bucket_t, identifier_size + 1); - for (i = 0; i < identifier_size + 1; i++) { + for (unsigned int i = 0; i < identifier_size + 1; i++) { table->buckets[i].nodes = xbt_dynar_new(sizeof(unsigned int), NULL); table->buckets[i].id = i; } @@ -46,10 +45,11 @@ unsigned int routing_table_contains(routing_table_t table, unsigned int node_id) /**@brief prints the routing table, to debug stuff. */ void routing_table_print(routing_table_t table) { - unsigned int i, j, value; + unsigned int j; + unsigned int value; XBT_INFO("Routing table of %08x:", table->id); - for (i = 0; i <= identifier_size; i++) { + for (unsigned int i = 0; i <= identifier_size; i++) { if (!xbt_dynar_is_empty(table->buckets[i].nodes)) { XBT_INFO("Bucket number %d: ", i); xbt_dynar_foreach(table->buckets[i].nodes, j, value) { @@ -65,7 +65,8 @@ void routing_table_print(routing_table_t table) */ unsigned int bucket_find_id(bucket_t bucket, unsigned int id) { - unsigned int i, current_id; + unsigned int i; + unsigned int current_id; xbt_dynar_foreach(bucket->nodes, i, current_id){ if (id == current_id){ return i; diff --git a/examples/msg/dht-kademlia/routing_table.h b/examples/msg/dht-kademlia/routing_table.h index 63ae7b545e..388f59594d 100644 --- a/examples/msg/dht-kademlia/routing_table.h +++ b/examples/msg/dht-kademlia/routing_table.h @@ -13,13 +13,17 @@ typedef struct s_bucket { xbt_dynar_t nodes; //Nodes in the bucket. unsigned int id; //bucket id -} s_bucket_t, *bucket_t; +} s_bucket_t; + +typedef s_bucket_t *bucket_t; /* Node routing table */ typedef struct s_routing_table { unsigned int id; //node id of the client's routing table s_bucket_t *buckets; //Node bucket list - 160 sized. -} s_routing_table_t, *routing_table_t; +} s_routing_table_t; + +typedef s_routing_table_t *routing_table_t; // bucket functions unsigned int bucket_find_id(bucket_t bucket, unsigned int id); diff --git a/examples/msg/dht-kademlia/task.h b/examples/msg/dht-kademlia/task.h index a7cd143d91..cca5e2928b 100644 --- a/examples/msg/dht-kademlia/task.h +++ b/examples/msg/dht-kademlia/task.h @@ -29,7 +29,9 @@ typedef struct s_task_data { answer_t answer; //Answer to the request made, if needed. char *answer_to; // mailbox to send the answer to (if not an answer). const char *issuer_host_name; // used for logging -} s_task_data_t, *task_data_t; +} s_task_data_t; + +typedef s_task_data_t *task_data_t; //Task handling functions msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);