From: Arnaud Giersch Date: Mon, 23 Dec 2019 23:16:01 +0000 (+0100) Subject: [sonar] Constify pointer and reference local variables in examples/. X-Git-Tag: v3.25~217 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7749be177cbd7d433ec389a155efff301969c6ee [sonar] Constify pointer and reference local variables in examples/. --- diff --git a/examples/deprecated/msg/dht-kademlia/answer.c b/examples/deprecated/msg/dht-kademlia/answer.c index fb3bcc2675..681a0af129 100644 --- a/examples/deprecated/msg/dht-kademlia/answer.c +++ b/examples/deprecated/msg/dht-kademlia/answer.c @@ -69,8 +69,8 @@ unsigned int answer_merge(answer_t destination, answer_t source) /** Helper to sort answer_t objects */ static int _answer_sort_function(const void *e1, const void *e2) { - node_contact_t c1 = *(const node_contact_t*)e1; - node_contact_t c2 = *(const node_contact_t*)e2; + const s_node_contact_t* c1 = *(const node_contact_t*)e1; + const s_node_contact_t* c2 = *(const node_contact_t*)e2; if (c1->distance == c2->distance) return 0; else @@ -147,6 +147,6 @@ unsigned int answer_destination_found(answer_t answer) if (xbt_dynar_is_empty(answer->nodes)) { return 0; } - node_contact_t contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t); + const s_node_contact_t* contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t); return contact_tail->distance == 0; } diff --git a/examples/deprecated/msg/dht-kademlia/dht-kademlia.c b/examples/deprecated/msg/dht-kademlia/dht-kademlia.c index 3ffb2893c0..f33ba10088 100644 --- a/examples/deprecated/msg/dht-kademlia/dht-kademlia.c +++ b/examples/deprecated/msg/dht-kademlia/dht-kademlia.c @@ -111,7 +111,7 @@ static int node(int argc, char *argv[]) */ unsigned int join(node_t node, unsigned int id_known) { - answer_t node_list; + const s_answer_t* node_list; msg_error_t status; unsigned int trial = 0; unsigned int i; @@ -137,7 +137,7 @@ unsigned int join(node_t node, unsigned int id_known) XBT_DEBUG("Received an answer from the node I know."); answer_got = 1; //retrieve the node list and ping them. - task_data_t data = MSG_task_get_data(node->task_received); + const s_task_data_t* data = MSG_task_get_data(node->task_received); xbt_assert((data != NULL), "Null data received"); if (data->type == TASK_FIND_NODE_ANSWER) { node_contact_t contact; @@ -217,7 +217,7 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_ if (status == MSG_OK) { xbt_assert((node->task_received != NULL), "Invalid task received"); //Figure out if we received an answer or something else - task_data_t data = MSG_task_get_data(node->task_received); + const s_task_data_t* data = MSG_task_get_data(node->task_received); xbt_assert((data != NULL), "No data in the task"); //Check if what we have received is what we are looking for. @@ -309,7 +309,7 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list) 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_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t); + const s_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++; diff --git a/examples/deprecated/msg/mc/bugged2_liveness.c b/examples/deprecated/msg/mc/bugged2_liveness.c index 2b68854dfa..a1a7efa7b7 100644 --- a/examples/deprecated/msg/mc/bugged2_liveness.c +++ b/examples/deprecated/msg/mc/bugged2_liveness.c @@ -25,7 +25,7 @@ static int coordinator(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[ MSG_task_receive(&task, "coordinator"); const char *kind = MSG_task_get_name(task); //is it a request or a release? if (!strcmp(kind, "request")) { // that's a request - char *req = MSG_task_get_data(task); + const char* req = MSG_task_get_data(task); if (CS_used) { XBT_INFO("CS already used."); msg_task_t answer = MSG_task_create("not grant", 0, 1000, NULL); diff --git a/examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c b/examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c index 95c8d81433..9bbb5591fb 100644 --- a/examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c +++ b/examples/deprecated/simdag/dag-dotload/sd_dag-dotload.c @@ -37,7 +37,7 @@ int main(int argc, char **argv) } char *tracefilename; - char *last = strrchr(argv[2], '.'); + const char* last = strrchr(argv[2], '.'); tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]); if (argc == 4) tracefilename = xbt_strdup(argv[3]); diff --git a/examples/deprecated/simdag/daxload/sd_daxload.c b/examples/deprecated/simdag/daxload/sd_daxload.c index 098c3e894e..376007d138 100644 --- a/examples/deprecated/simdag/daxload/sd_daxload.c +++ b/examples/deprecated/simdag/daxload/sd_daxload.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) xbt_assert(argc > 2, "Usage: %s platform_file dax_file [jedule_file]\n" "\tExample: %s simulacrum_7_hosts.xml Montage_25.xml Montage_25.jed", argv[0], argv[0]); - char *last = strrchr(argv[2], '.'); + const char* last = strrchr(argv[2], '.'); char * tracefilename = bprintf("%.*s.trace",(int) (last == NULL ? strlen(argv[2]):last - argv[2]), argv[2]); if (argc == 4) tracefilename = xbt_strdup(argv[3]); @@ -81,7 +81,7 @@ int main(int argc, char **argv) XBT_INFO("------------------- Run the schedule ---------------------------"); SD_simulate(-1); XBT_INFO("------------------- Produce the trace file---------------------------"); - char* basename = strrchr(tracefilename, '/'); + const char* basename = strrchr(tracefilename, '/'); XBT_INFO("Producing the trace of the run into %s", basename ? basename + 1 : tracefilename); FILE *out = fopen(tracefilename, "w"); xbt_assert(out, "Cannot write to %s", tracefilename); diff --git a/examples/deprecated/simdag/schedule-dotload/sd_schedule-dotload.c b/examples/deprecated/simdag/schedule-dotload/sd_schedule-dotload.c index 7a50b4cb03..6be282ed26 100644 --- a/examples/deprecated/simdag/schedule-dotload/sd_schedule-dotload.c +++ b/examples/deprecated/simdag/schedule-dotload/sd_schedule-dotload.c @@ -38,7 +38,7 @@ int main(int argc, char **argv) } char *tracefilename; - char *last = strrchr(argv[2], '.'); + const char* last = strrchr(argv[2], '.'); tracefilename = bprintf("%.*s.trace", (int) (last == NULL ? strlen(argv[2]) : last - argv[2]),argv[2]); if (argc == 4) tracefilename = xbt_strdup(argv[3]); diff --git a/examples/deprecated/simdag/scheduling/sd_scheduling.c b/examples/deprecated/simdag/scheduling/sd_scheduling.c index c7cd717c58..5da1b6adae 100644 --- a/examples/deprecated/simdag/scheduling/sd_scheduling.c +++ b/examples/deprecated/simdag/scheduling/sd_scheduling.c @@ -24,7 +24,7 @@ struct _HostAttribute { static double sg_host_get_available_at(sg_host_t host) { - HostAttribute attr = (HostAttribute)sg_host_data(host); + const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host); return attr->available_at; } @@ -36,7 +36,7 @@ static void sg_host_set_available_at(sg_host_t host, double time) } static SD_task_t sg_host_get_last_scheduled_task( sg_host_t host){ - HostAttribute attr = (HostAttribute)sg_host_data(host); + const struct _HostAttribute* attr = (HostAttribute)sg_host_data(host); return attr->last_scheduled_task; } diff --git a/examples/deprecated/simdag/test/sd_test.cpp b/examples/deprecated/simdag/test/sd_test.cpp index 59fead5068..d2d34c071f 100644 --- a/examples/deprecated/simdag/test/sd_test.cpp +++ b/examples/deprecated/simdag/test/sd_test.cpp @@ -119,7 +119,7 @@ int main(int argc, char **argv) SD_task_schedule(taskC, 2, host_list, computation_amount, communication_amount, -1); SD_task_schedule(taskD, 2, host_list, computation_amount, communication_amount, -1); - std::set *changed_tasks = simgrid::sd::simulate(-1.0); + const std::set* changed_tasks = simgrid::sd::simulate(-1.0); for (auto const& task : *changed_tasks) { XBT_INFO("Task '%s' start time: %f, finish time: %f", SD_task_get_name(task), SD_task_get_start_time(task), SD_task_get_finish_time(task)); diff --git a/examples/s4u/actor-create/s4u-actor-create.cpp b/examples/s4u/actor-create/s4u-actor-create.cpp index b587f42136..2bd2508328 100644 --- a/examples/s4u/actor-create/s4u-actor-create.cpp +++ b/examples/s4u/actor-create/s4u-actor-create.cpp @@ -33,9 +33,9 @@ static void receiver(const std::string& mailbox_name) XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname()); - std::string* msg1 = static_cast(mailbox->get()); - std::string* msg2 = static_cast(mailbox->get()); - std::string* msg3 = static_cast(mailbox->get()); + const std::string* msg1 = static_cast(mailbox->get()); + const std::string* msg2 = static_cast(mailbox->get()); + const std::string* msg3 = static_cast(mailbox->get()); XBT_INFO("I received '%s', '%s' and '%s'", msg1->c_str(), msg2->c_str(), msg3->c_str()); delete msg1; delete msg2; diff --git a/examples/s4u/app-chainsend/s4u-app-chainsend.cpp b/examples/s4u/app-chainsend/s4u-app-chainsend.cpp index dc1abf59f9..ffaff0a16f 100644 --- a/examples/s4u/app-chainsend/s4u-app-chainsend.cpp +++ b/examples/s4u/app-chainsend/s4u-app-chainsend.cpp @@ -47,7 +47,7 @@ public: void joinChain() { - ChainMessage* msg = static_cast(me->get()); + const ChainMessage* msg = static_cast(me->get()); prev = msg->prev_; next = msg->next_; total_pieces = msg->num_pieces; diff --git a/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp b/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp index a91f203ad8..8249b11d33 100644 --- a/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp +++ b/examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp @@ -67,7 +67,7 @@ public: { double compute_cost; do { - double* msg = static_cast(mailbox->get()); + const double* msg = static_cast(mailbox->get()); compute_cost = *msg; delete msg; diff --git a/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp b/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp index 40780fc0ff..6d57fefd4d 100644 --- a/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp +++ b/examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp @@ -49,12 +49,12 @@ static void worker(std::vector args) { xbt_assert(args.size() == 1, "The worker expects no argument"); - simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host(); + const simgrid::s4u::Host* my_host = simgrid::s4u::this_actor::get_host(); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(my_host->get_name()); double compute_cost; do { - double* msg = static_cast(mailbox->get()); + const double* msg = static_cast(mailbox->get()); compute_cost = *msg; delete msg; diff --git a/examples/s4u/app-pingpong/s4u-app-pingpong.cpp b/examples/s4u/app-pingpong/s4u-app-pingpong.cpp index 019d6b25c0..03fa89a99f 100644 --- a/examples/s4u/app-pingpong/s4u-app-pingpong.cpp +++ b/examples/s4u/app-pingpong/s4u-app-pingpong.cpp @@ -17,7 +17,7 @@ static void pinger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai mailbox_out->put(payload, 1); /* - ... then wait for the (large) pong */ - double* sender_time = static_cast(mailbox_in->get()); + const double* sender_time = static_cast(mailbox_in->get()); double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time; XBT_INFO("Task received : large communication (bandwidth bound)"); @@ -30,7 +30,7 @@ static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str()); /* - Receive the (small) ping first ....*/ - double* sender_time = static_cast(mailbox_in->get()); + const double* sender_time = static_cast(mailbox_in->get()); double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time; XBT_INFO("Task received : small communication (latency bound)"); XBT_INFO(" Ping time (latency bound) %f", communication_time); diff --git a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp index 27741143cc..50cd5ec51a 100644 --- a/examples/s4u/app-token-ring/s4u-app-token-ring.cpp +++ b/examples/s4u/app-token-ring/s4u-app-token-ring.cpp @@ -24,7 +24,7 @@ public: { try { rank = std::stoi(simgrid::s4u::this_actor::get_name()); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument& ia) { throw std::invalid_argument(std::string("Processes of this example must have a numerical name, not ") + ia.what()); } @@ -41,7 +41,7 @@ public: XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname()); std::string msg = "Token"; neighbor_mailbox->put(&msg, task_comm_size); - std::string* res = static_cast(my_mailbox->get()); + const std::string* res = static_cast(my_mailbox->get()); XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str()); } else { std::string* res = static_cast(my_mailbox->get()); diff --git a/examples/s4u/async-ready/s4u-async-ready.cpp b/examples/s4u/async-ready/s4u-async-ready.cpp index d73f2ce2b5..ca868e2604 100644 --- a/examples/s4u/async-ready/s4u-async-ready.cpp +++ b/examples/s4u/async-ready/s4u-async-ready.cpp @@ -72,7 +72,7 @@ static int peer(int argc, char** argv) while (pending_finalize_messages > 0) { if (my_mbox->ready()) { double start = simgrid::s4u::Engine::get_clock(); - std::string* received = static_cast(my_mbox->get()); + const std::string* received = static_cast(my_mbox->get()); double waiting_time = simgrid::s4u::Engine::get_clock() - start; xbt_assert(waiting_time == 0, "Expecting the waiting time to be 0 because the communication was supposedly ready, but got %f instead", waiting_time); XBT_INFO("I got a '%s'.", received->c_str()); diff --git a/examples/s4u/async-wait/s4u-async-wait.cpp b/examples/s4u/async-wait/s4u-async-wait.cpp index 009c9fadf6..4e06ea7ce3 100644 --- a/examples/s4u/async-wait/s4u-async-wait.cpp +++ b/examples/s4u/async-wait/s4u-async-wait.cpp @@ -74,7 +74,7 @@ static int receiver(int argc, char** argv) XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { - std::string* received = static_cast(mbox->get()); + const std::string* received = static_cast(mbox->get()); XBT_INFO("I got a '%s'.", received->c_str()); if (*received == "finalize") cont = false; // If it's a finalize message, we're done. diff --git a/examples/s4u/async-waitall/s4u-async-waitall.cpp b/examples/s4u/async-waitall/s4u-async-waitall.cpp index f23e55c449..53d2a3e05b 100644 --- a/examples/s4u/async-waitall/s4u-async-waitall.cpp +++ b/examples/s4u/async-waitall/s4u-async-waitall.cpp @@ -89,7 +89,7 @@ public: { XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { - std::string* received = static_cast(mbox->get()); + const std::string* received = static_cast(mbox->get()); XBT_INFO("I got a '%s'.", received->c_str()); cont = (*received != "finalize"); // If it's a finalize message, we're done // Receiving the message was all we were supposed to do diff --git a/examples/s4u/async-waitany/s4u-async-waitany.cpp b/examples/s4u/async-waitany/s4u-async-waitany.cpp index 407b4e56f6..5c5813104c 100644 --- a/examples/s4u/async-waitany/s4u-async-waitany.cpp +++ b/examples/s4u/async-waitany/s4u-async-waitany.cpp @@ -102,7 +102,7 @@ public: { XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { - std::string* received = static_cast(mbox->get()); + const std::string* received = static_cast(mbox->get()); XBT_INFO("I got a '%s'.", received->c_str()); cont = (*received != "finalize"); // If it's a finalize message, we're done // Receiving the message was all we were supposed to do diff --git a/examples/s4u/async-waituntil/s4u-async-waituntil.cpp b/examples/s4u/async-waituntil/s4u-async-waituntil.cpp index 33974081c8..3d5cfac94e 100644 --- a/examples/s4u/async-waituntil/s4u-async-waituntil.cpp +++ b/examples/s4u/async-waituntil/s4u-async-waituntil.cpp @@ -72,7 +72,7 @@ static int receiver(int argc, char** argv) XBT_INFO("Wait for my first message"); for (bool cont = true; cont;) { - std::string* received = static_cast(mbox->get()); + const std::string* received = static_cast(mbox->get()); XBT_INFO("I got a '%s'.", received->c_str()); if (*received == "finalize") cont = false; // If it's a finalize message, we're done. diff --git a/examples/s4u/cloud-migration/s4u-cloud-migration.cpp b/examples/s4u/cloud-migration/s4u-cloud-migration.cpp index 8add881ad1..ecceb5d420 100644 --- a/examples/s4u/cloud-migration/s4u-cloud-migration.cpp +++ b/examples/s4u/cloud-migration/s4u-cloud-migration.cpp @@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_migration, "Messages specific for this ex static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm) { - simgrid::s4u::Host* src_pm = vm->get_pm(); + const simgrid::s4u::Host* src_pm = vm->get_pm(); double mig_sta = simgrid::s4u::Engine::get_clock(); sg_vm_migrate(vm, dst_pm); double mig_end = simgrid::s4u::Engine::get_clock(); diff --git a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp index 08a341ab83..95e843d308 100644 --- a/examples/s4u/cloud-simple/s4u-cloud-simple.cpp +++ b/examples/s4u/cloud-simple/s4u-cloud-simple.cpp @@ -47,7 +47,7 @@ static void communication_rx_fun(std::vector args) const char* host_name = simgrid::s4u::this_actor::get_host()->get_cname(); simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(args.at(0)); - struct s_payload* payload = static_cast(mbox->get()); + const s_payload* payload = static_cast(mbox->get()); double clock_end = simgrid::s4u::Engine::get_clock(); XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name, diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index f76484cc29..7ea070edbd 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -267,7 +267,7 @@ int Node::remoteGetPredecessor(int ask_to) try { comm->wait_for(timeout); - ChordMessage* answer = static_cast(data); + const ChordMessage* answer = static_cast(data); XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to, answer->answer_id); predecessor_id = answer->answer_id; @@ -337,7 +337,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) try { comm->wait_for(timeout); - ChordMessage* answer = static_cast(data); + const ChordMessage* answer = static_cast(data); XBT_DEBUG("Received the answer to my 'Find Successor' request for id %d: the successor of key %d is %d", answer->request_id, id_, answer->answer_id); successor = answer->answer_id; diff --git a/examples/s4u/dht-kademlia/node.cpp b/examples/s4u/dht-kademlia/node.cpp index 617f382b9c..961e8b91a1 100644 --- a/examples/s4u/dht-kademlia/node.cpp +++ b/examples/s4u/dht-kademlia/node.cpp @@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia_node, "Messages specific for this example" namespace kademlia { static void destroy(void* message) { - Message* msg = static_cast(message); + const Message* msg = static_cast(message); delete msg->answer_; delete msg; } @@ -22,7 +22,7 @@ static void destroy(void* message) */ bool Node::join(unsigned int known_id) { - Answer* node_list; + const Answer* node_list; unsigned int i; bool got_answer = false; diff --git a/examples/s4u/exec-remote/s4u-exec-remote.cpp b/examples/s4u/exec-remote/s4u-exec-remote.cpp index 4c0699cbb2..49814cb858 100644 --- a/examples/s4u/exec-remote/s4u-exec-remote.cpp +++ b/examples/s4u/exec-remote/s4u-exec-remote.cpp @@ -9,7 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "Messages specific for this s4u example") static void wizard() { - simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard"); + const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard"); simgrid::s4u::Host* ginette = simgrid::s4u::Host::by_name("Ginette"); simgrid::s4u::Host* boivin = simgrid::s4u::Host::by_name("Boivin"); diff --git a/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp b/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp index 6aeccfef75..8644214fe2 100644 --- a/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp +++ b/examples/s4u/exec-waitfor/s4u-exec-waitfor.cpp @@ -20,7 +20,7 @@ static void worker() try { exec->wait_for(3); XBT_INFO("Execution complete"); - } catch (simgrid::TimeoutException&) { + } catch (const simgrid::TimeoutException&) { XBT_INFO("Execution Timeout!"); } @@ -30,7 +30,7 @@ static void worker() try { exec->wait_for(6); XBT_INFO("Execution complete"); - } catch (simgrid::TimeoutException&) { + } catch (const simgrid::TimeoutException&) { XBT_INFO("Execution Timeout!"); } @@ -50,7 +50,7 @@ static void worker() try { exec->wait_for(2); XBT_INFO("Parallel Execution complete"); - } catch (simgrid::TimeoutException&) { + } catch (const simgrid::TimeoutException&) { XBT_INFO("Parallel Execution Timeout!"); } } diff --git a/examples/s4u/io-async/s4u-io-async.cpp b/examples/s4u/io-async/s4u-io-async.cpp index fe9deac0a9..7ac77db73d 100644 --- a/examples/s4u/io-async/s4u-io-async.cpp +++ b/examples/s4u/io-async/s4u-io-async.cpp @@ -27,7 +27,7 @@ static void test_waitfor(sg_size_t size) simgrid::s4u::IoPtr activity = disk->write_async(size); try { activity->wait_for(0.5); - } catch (simgrid::TimeoutException&) { + } catch (const simgrid::TimeoutException&) { XBT_INFO("Asynchronous write: Timeout!"); } diff --git a/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp b/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp index d51781a432..49c9093846 100644 --- a/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp +++ b/examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp @@ -34,7 +34,7 @@ static void host() /* - Attach some user data to disk1 */ XBT_INFO("*** Get/set data for storage element: Disk1 ***"); - std::string* data = static_cast(disk->get_data()); + const std::string* data = static_cast(disk->get_data()); XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data"); diff --git a/examples/s4u/io-file-system/s4u-io-file-system.cpp b/examples/s4u/io-file-system/s4u-io-file-system.cpp index 6a74e1b282..fe5ad8dd0f 100644 --- a/examples/s4u/io-file-system/s4u-io-file-system.cpp +++ b/examples/s4u/io-file-system/s4u-io-file-system.cpp @@ -57,7 +57,7 @@ public: // Test attaching some user data to the file file->set_data(new std::string("777")); - std::string* file_data = static_cast(file->get_data()); + const std::string* file_data = static_cast(file->get_data()); XBT_INFO("User data attached to the file: %s", file_data->c_str()); delete file_data; diff --git a/examples/s4u/maestro-set/s4u-maestro-set.cpp b/examples/s4u/maestro-set/s4u-maestro-set.cpp index 108855976e..336c74db16 100644 --- a/examples/s4u/maestro-set/s4u-maestro-set.cpp +++ b/examples/s4u/maestro-set/s4u-maestro-set.cpp @@ -48,7 +48,7 @@ static void receiver() { ensure_other_tid(); - std::string* payload = static_cast(simgrid::s4u::Mailbox::by_name("some mailbox")->get()); + const std::string* payload = static_cast(simgrid::s4u::Mailbox::by_name("some mailbox")->get()); XBT_INFO("Task received"); delete payload; } diff --git a/examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp b/examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp index b87e6f44c2..7ce578c642 100644 --- a/examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp +++ b/examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp @@ -18,7 +18,7 @@ static int server(int worker_amount) int value_got = -1; simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server"); for (int count = 0; count < worker_amount; count++) { - int* msg = static_cast(mb->get()); + const int* msg = static_cast(mb->get()); value_got = *msg; delete msg; } diff --git a/examples/s4u/platform-failures/s4u-platform-failures.cpp b/examples/s4u/platform-failures/s4u-platform-failures.cpp index 0c5bf2d606..d2271b2eeb 100644 --- a/examples/s4u/platform-failures/s4u-platform-failures.cpp +++ b/examples/s4u/platform-failures/s4u-platform-failures.cpp @@ -75,7 +75,7 @@ static int worker(int argc, char* argv[]) xbt_assert(argc == 2, "Expecting one parameter"); long id = xbt_str_parse_int(argv[1], "Invalid argument %s"); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(id)); - double* payload = nullptr; + const double* payload = nullptr; double comp_size = -1; while (1) { try { diff --git a/examples/s4u/platform-profile/s4u-platform-profile.cpp b/examples/s4u/platform-profile/s4u-platform-profile.cpp index 5483c2fa0f..ceae1de95c 100644 --- a/examples/s4u/platform-profile/s4u-platform-profile.cpp +++ b/examples/s4u/platform-profile/s4u-platform-profile.cpp @@ -15,10 +15,10 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_platform_profile, "Messages specific for this s /* Main function of the Yielder process */ static void watcher() { - simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter"); - simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard"); - simgrid::s4u::Link* link1 = simgrid::s4u::Link::by_name("1"); - simgrid::s4u::Link* link2 = simgrid::s4u::Link::by_name("2"); + const simgrid::s4u::Host* jupiter = simgrid::s4u::Host::by_name("Jupiter"); + const simgrid::s4u::Host* fafard = simgrid::s4u::Host::by_name("Fafard"); + const simgrid::s4u::Link* link1 = simgrid::s4u::Link::by_name("1"); + const simgrid::s4u::Link* link2 = simgrid::s4u::Link::by_name("2"); for (int i = 0; i < 10; i++) { XBT_INFO("Fafard: %.0fGflops, Jupiter: % 3.0fGflops, Link1: (%.2fMB/s %.0fms), Link2: (%.2fMB/s %.0fms)", diff --git a/examples/s4u/platform-properties/s4u-platform-properties.cpp b/examples/s4u/platform-properties/s4u-platform-properties.cpp index 12e793d020..71677225f5 100644 --- a/examples/s4u/platform-properties/s4u-platform-properties.cpp +++ b/examples/s4u/platform-properties/s4u-platform-properties.cpp @@ -84,7 +84,7 @@ static void david(std::vector /*args*/) static void bob(std::vector /*args*/) { /* this host also tests the properties of the AS*/ - simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root(); + const simgrid::s4u::NetZone* root = simgrid::s4u::Engine::get_instance()->get_netzone_root(); XBT_INFO("== Print the properties of the root zone"); XBT_INFO(" Zone property: filename -> %s", root->get_property("filename")); XBT_INFO(" Zone property: date -> %s", root->get_property("date"));