From 7e2f1b12f4459f77318e5d664317473e35aeb473 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 3 May 2019 11:12:49 +0200 Subject: [PATCH] [sonar] Don't name unused exceptions. --- examples/s4u/app-bittorrent/s4u-peer.cpp | 8 ++++---- examples/s4u/app-bittorrent/s4u-tracker.cpp | 2 +- examples/s4u/dht-chord/s4u-dht-chord-node.cpp | 16 ++++++++-------- examples/s4u/exec-ptask/s4u-exec-ptask.cpp | 2 +- .../platform-failures/s4u-platform-failures.cpp | 4 ++-- src/kernel/routing/DragonflyZone.cpp | 14 +++++++------- src/kernel/routing/FatTreeZone.cpp | 8 ++++---- src/mc/checker/simgrid_mc.cpp | 6 +++--- src/msg/msg_comm.cpp | 8 ++++---- src/msg/msg_legacy.cpp | 2 +- src/msg/msg_task.cpp | 16 ++++++++-------- src/plugins/host_energy.cpp | 2 +- src/plugins/link_energy.cpp | 4 ++-- src/plugins/vm/VmLiveMigration.cpp | 8 ++++---- src/simdag/sd_daxloader.cpp | 6 +++--- src/simix/smx_deployment.cpp | 3 +-- src/smpi/internals/smpi_utils.cpp | 4 ++-- src/smpi/mpi/smpi_request.cpp | 10 +++++----- src/surf/xml/surfxml_sax_cb.cpp | 4 ++-- src/xbt/exception.cpp | 2 +- .../mc/dwarf-expression/dwarf-expression.cpp | 11 ++++------- teshsuite/xbt/mmalloc/mmalloc_test.cpp | 4 ++-- 22 files changed, 70 insertions(+), 74 deletions(-) diff --git a/examples/s4u/app-bittorrent/s4u-peer.cpp b/examples/s4u/app-bittorrent/s4u-peer.cpp index 1f28b3ee41..53317ba98f 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.cpp +++ b/examples/s4u/app-bittorrent/s4u-peer.cpp @@ -33,13 +33,13 @@ Peer::Peer(std::vector args) try { id = std::stoi(args[1]); mailbox_ = simgrid::s4u::Mailbox::by_name(std::to_string(id)); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid ID:") + args[1].c_str()); } try { deadline = std::stod(args[2]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid deadline:") + args[2].c_str()); } xbt_assert(deadline > 0, "Wrong deadline supplied"); @@ -84,7 +84,7 @@ bool Peer::getPeersFromTracker() try { XBT_DEBUG("Sending a peer request to the tracker."); tracker_mailbox->put(peer_request, TRACKER_COMM_SIZE, GET_PEERS_TIMEOUT); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Timeout expired when requesting peers to tracker"); delete peer_request; return false; @@ -97,7 +97,7 @@ bool Peer::getPeersFromTracker() if (id != peer_id) connected_peers.emplace(peer_id, Connection(peer_id)); delete answer; - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Timeout expired when requesting peers to tracker"); return false; } diff --git a/examples/s4u/app-bittorrent/s4u-tracker.cpp b/examples/s4u/app-bittorrent/s4u-tracker.cpp index f51e55d415..b7bd4cd05f 100644 --- a/examples/s4u/app-bittorrent/s4u-tracker.cpp +++ b/examples/s4u/app-bittorrent/s4u-tracker.cpp @@ -17,7 +17,7 @@ Tracker::Tracker(std::vector args) // Retrieving end time try { deadline = std::stod(args[1]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid deadline:") + args[1].c_str()); } xbt_assert(deadline > 0, "Wrong deadline supplied"); diff --git a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp index 833f3eb790..e1d3c23103 100644 --- a/examples/s4u/dht-chord/s4u-dht-chord-node.cpp +++ b/examples/s4u/dht-chord/s4u-dht-chord-node.cpp @@ -110,7 +110,7 @@ void Node::notifyAndQuit() XBT_DEBUG("Sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]); try { simgrid::s4u::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Timeout expired when sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]); delete pred_msg; } @@ -124,7 +124,7 @@ void Node::notifyAndQuit() try { simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_))->put(succ_msg, 10, timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Timeout expired when sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_); delete succ_msg; } @@ -214,7 +214,7 @@ void Node::checkPredecessor() XBT_DEBUG("Sending a 'Predecessor Alive' request to my predecessor %d", pred_id_); try { mailbox->put(message, 10, timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to send the 'Predecessor Alive' request to %d", pred_id_); delete message; return; @@ -229,7 +229,7 @@ void Node::checkPredecessor() comm->wait_for(timeout); XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_); delete static_cast(data); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to receive the answer to my 'Predecessor Alive' request"); pred_id_ = -1; } @@ -255,7 +255,7 @@ int Node::remoteGetPredecessor(int ask_to) XBT_DEBUG("Sending a 'Get Predecessor' request to %d", ask_to); try { mailbox->put(message, 10, timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to send the 'Get Predecessor' request to %d", ask_to); delete message; return predecessor_id; @@ -273,7 +273,7 @@ int Node::remoteGetPredecessor(int ask_to) answer->answer_id); predecessor_id = answer->answer_id; delete answer; - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to receive the answer to my 'Get Predecessor' request"); delete static_cast(data); } @@ -327,7 +327,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) XBT_DEBUG("Sending a 'Find Successor' request to %d for id %d", ask_to, id); try { mailbox->put(message, 10, timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to send the 'Find Successor' request to %d for id %d", ask_to, id_); delete message; return successor; @@ -343,7 +343,7 @@ int Node::remoteFindSuccessor(int ask_to, int id) answer->request_id, id_, answer->answer_id); successor = answer->answer_id; delete answer; - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request"); delete static_cast(data); } diff --git a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp index c3f804bea1..9759607a31 100644 --- a/examples/s4u/exec-ptask/s4u-exec-ptask.cpp +++ b/examples/s4u/exec-ptask/s4u-exec-ptask.cpp @@ -55,7 +55,7 @@ static void runner() simgrid::s4u::this_actor::parallel_execute(hosts, computation_amounts, communication_amounts, 10.0 /* timeout (in seconds)*/); xbt_die("Woops, this did not timeout as expected... Please report that bug."); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { XBT_INFO("Caught the expected timeout exception."); } diff --git a/examples/s4u/platform-failures/s4u-platform-failures.cpp b/examples/s4u/platform-failures/s4u-platform-failures.cpp index dea2f30316..ceea3140f7 100644 --- a/examples/s4u/platform-failures/s4u-platform-failures.cpp +++ b/examples/s4u/platform-failures/s4u-platform-failures.cpp @@ -40,7 +40,7 @@ static int master(int argc, char* argv[]) XBT_INFO("Send a message to %s", mailbox->get_cname()); mailbox->put(payload, comm_size, 10.0); XBT_INFO("Send to %s completed", mailbox->get_cname()); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { delete payload; XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname()); } catch (xbt_ex& e) { @@ -58,7 +58,7 @@ static int master(int argc, char* argv[]) double* payload = new double(-1.0); try { mailbox->put(payload, 0, 1.0); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { delete payload; XBT_INFO("Mmh. Got timeouted while speaking to '%s'. Nevermind. Let's keep going!", mailbox->get_cname()); } catch (xbt_ex& e) { diff --git a/src/kernel/routing/DragonflyZone.cpp b/src/kernel/routing/DragonflyZone.cpp index 911f9506d6..fd526d16b1 100644 --- a/src/kernel/routing/DragonflyZone.cpp +++ b/src/kernel/routing/DragonflyZone.cpp @@ -53,13 +53,13 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster) try { this->num_groups_ = std::stoi(tmp[0]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of groups:") + tmp[0]); } try { this->num_links_blue_ = std::stoi(tmp[1]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of links for the blue level:") + tmp[1]); } // Black network : number of chassis/group, number of links between each router on the black network @@ -70,13 +70,13 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster) try { this->num_chassis_per_group_ = std::stoi(tmp[0]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of groups:") + tmp[0]); } try { this->num_links_black_ = std::stoi(tmp[1]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of links for the black level:") + tmp[1]); } @@ -88,20 +88,20 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster) try { this->num_blades_per_chassis_ = std::stoi(tmp[0]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of groups:") + tmp[0]); } try { this->num_links_green_ = std::stoi(tmp[1]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid number of links for the green level:") + tmp[1]); } // The last part of topo_parameters should be the number of nodes per blade try { this->num_nodes_per_blade_ = std::stoi(parameters[3]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Last parameter is not the amount of nodes per blade:") + parameters[3]); } diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index ae1556c658..d8b6e507da 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -373,7 +373,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster) // The first parts of topo_parameters should be the levels number try { this->levels_ = std::stoi(parameters[0]); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("First parameter is not the amount of levels:") + parameters[0]); } @@ -385,7 +385,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster) for (size_t i = 0; i < tmp.size(); i++) { try { this->num_children_per_node_.push_back(std::stoi(tmp[i])); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid lower level node number:") + tmp[i]); } } @@ -398,7 +398,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster) for (size_t i = 0; i < tmp.size(); i++) { try { this->num_parents_per_node_.push_back(std::stoi(tmp[i])); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid upper level node number:") + tmp[i]); } } @@ -411,7 +411,7 @@ void FatTreeZone::parse_specific_arguments(ClusterCreationArgs* cluster) for (size_t i = 0; i < tmp.size(); i++) { try { this->num_port_lower_level_.push_back(std::stoi(tmp[i])); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid lower level port number:") + tmp[i]); } } diff --git a/src/mc/checker/simgrid_mc.cpp b/src/mc/checker/simgrid_mc.cpp index e8c0ca82b2..d4916270a3 100644 --- a/src/mc/checker/simgrid_mc.cpp +++ b/src/mc/checker/simgrid_mc.cpp @@ -59,11 +59,11 @@ int main(int argc, char** argv) int res = SIMGRID_MC_EXIT_SUCCESS; try { checker->run(); - } catch (simgrid::mc::DeadlockError& de) { + } catch (const simgrid::mc::DeadlockError&) { res = SIMGRID_MC_EXIT_DEADLOCK; - } catch (simgrid::mc::TerminationError& te) { + } catch (const simgrid::mc::TerminationError&) { res = SIMGRID_MC_EXIT_NON_TERMINATION; - } catch (simgrid::mc::LivenessError& le) { + } catch (const simgrid::mc::LivenessError&) { res = SIMGRID_MC_EXIT_LIVENESS; } checker = nullptr; diff --git a/src/msg/msg_comm.cpp b/src/msg/msg_comm.cpp index 28db1e5402..d9bdac3f36 100644 --- a/src/msg/msg_comm.cpp +++ b/src/msg/msg_comm.cpp @@ -28,10 +28,10 @@ bool Comm::test() /* I am the receiver */ (*task_received)->set_not_used(); } - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { status_ = MSG_TIMEOUT; finished = true; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { status_ = MSG_TASK_CANCELED; finished = true; } catch (xbt_ex& e) { @@ -56,9 +56,9 @@ msg_error_t Comm::wait_for(double timeout) } /* FIXME: these functions are not traceable */ - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { status_ = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { status_ = MSG_TASK_CANCELED; } catch (xbt_ex& e) { if (e.category == network_error) diff --git a/src/msg/msg_legacy.cpp b/src/msg/msg_legacy.cpp index fd4562c206..9cedca552d 100644 --- a/src/msg/msg_legacy.cpp +++ b/src/msg/msg_legacy.cpp @@ -130,7 +130,7 @@ msg_error_t MSG_process_sleep(double duration) try { sg_actor_sleep_for(duration); return MSG_OK; - } catch (simgrid::HostFailureException& e) { + } catch (const simgrid::HostFailureException&) { return MSG_HOST_FAILURE; } } diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 08aeb1fa54..9094468620 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -81,11 +81,11 @@ msg_error_t Task::execute() set_not_used(); XBT_DEBUG("Execution task '%s' finished", get_cname()); - } catch (HostFailureException& e) { + } catch (const HostFailureException&) { status = MSG_HOST_FAILURE; - } catch (TimeoutError& e) { + } catch (const TimeoutError&) { status = MSG_TIMEOUT; - } catch (CancelException& e) { + } catch (const CancelException&) { status = MSG_TASK_CANCELED; } @@ -133,9 +133,9 @@ msg_error_t Task::send(const std::string& alias, double timeout) s4u::CommPtr s4u_comm = send_async(alias, nullptr, false); comm = s4u_comm; comm->wait_for(timeout); - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { ret = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { ret = MSG_HOST_FAILURE; } catch (xbt_ex& e) { if (e.category == network_error) @@ -625,11 +625,11 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t* task, const char* alias, do *task = static_cast(payload); XBT_DEBUG("Got task %s from %s", (*task)->get_cname(), alias); (*task)->set_not_used(); - } catch (simgrid::HostFailureException& e) { + } catch (const simgrid::HostFailureException&) { ret = MSG_HOST_FAILURE; - } catch (simgrid::TimeoutError& e) { + } catch (const simgrid::TimeoutError&) { ret = MSG_TIMEOUT; - } catch (simgrid::CancelException& e) { + } catch (const simgrid::CancelException&) { ret = MSG_TASK_CANCELED; } catch (xbt_ex& e) { if (e.category == network_error) diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index f380c167de..125a8c8df0 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -203,7 +203,7 @@ HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host_(ptr), last_updated_(surf if (off_power_str != nullptr) { try { this->watts_off_ = std::stod(std::string(off_power_str)); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid value for property watt_off of host ") + host_->get_cname() + ": " + off_power_str); } diff --git a/src/plugins/link_energy.cpp b/src/plugins/link_energy.cpp index ea5cf2d8ce..d6ff7970f4 100644 --- a/src/plugins/link_energy.cpp +++ b/src/plugins/link_energy.cpp @@ -107,13 +107,13 @@ void LinkEnergy::init_watts_range_list() /* max_power is the power consumed at 100% link load */ try { idle_ = std::stod(current_power_values.front()); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname()); } try { busy_ = std::stod(current_power_values.back()); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid busy power value for link ") + this->link_->get_cname()); } } diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index 3ef63edfb7..460e9f441f 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -107,7 +107,7 @@ sg_size_t MigrationTx::sendMigrationData(sg_size_t size, int stage, int stage2_r comm = mbox->put_init(msg, size)->set_rate(mig_speed)->wait_for(timeout); else comm = mbox->put_async(msg, size)->wait_for(timeout); - } catch (xbt_ex& e) { + } catch (const xbt_ex&) { if (comm) { sg_size_t remaining = static_cast(comm->get_remaining()); XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size); @@ -182,7 +182,7 @@ void MigrationTx::operator()() } else if (sent > ramsize) XBT_CRITICAL("bug"); - } catch (xbt_ex& e) { + } catch (const xbt_ex&) { // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code) // Stop the dirty page tracking an return (there is no memory space to release) sg_vm_stop_dirty_page_tracking(vm_); @@ -222,7 +222,7 @@ void MigrationTx::operator()() try { XBT_DEBUG("Stage 2, gonna send %llu", updated_size); sent = sendMigrationData(updated_size, 2, stage2_round, mig_speed, mig_timeout); - } catch (xbt_ex& e) { + } catch (const xbt_ex&) { // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data // code) // Stop the dirty page tracking an return (there is no memory space to release) @@ -266,7 +266,7 @@ void MigrationTx::operator()() try { XBT_DEBUG("Stage 3: Gonna send %zu bytes", remaining_size); sendMigrationData(remaining_size, 3, 0, mig_speed, -1); - } catch (xbt_ex& e) { + } catch (const xbt_ex&) { // hostfailure (if you want to know whether this is the SRC or the DST check directly in send_migration_data code) // Stop the dirty page tracking an return (there is no memory space to release) vm_->resume(); diff --git a/src/simdag/sd_daxloader.cpp b/src/simdag/sd_daxloader.cpp index 82f8d0dbaf..0c59e70c76 100644 --- a/src/simdag/sd_daxloader.cpp +++ b/src/simdag/sd_daxloader.cpp @@ -237,7 +237,7 @@ void STag_dax__adag() try { double version = std::stod(std::string(A_dax__adag_version)); xbt_assert(version == 2.1, "Expected version 2.1 in tag, got %f. Fix the parser or your file", version); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Parse error: ") + A_dax__adag_version + " is not a double"); } } @@ -253,7 +253,7 @@ void STag_dax__job() current_job = SD_task_create_comp_seq(name.c_str(), nullptr, runtime); jobs.insert({A_dax__job_id, current_job}); xbt_dynar_push(result, ¤t_job); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Parse error: ") + A_dax__job_runtime + " is not a double"); } } @@ -263,7 +263,7 @@ void STag_dax__uses() double size; try { size = std::stod(std::string(A_dax__uses_size)); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Parse error: ") + A_dax__uses_size + " is not a double"); } bool is_input = (A_dax__uses_link == A_dax__uses_link_input); diff --git a/src/simix/smx_deployment.cpp b/src/simix/smx_deployment.cpp index f79f6c3653..2f2ff22f17 100644 --- a/src/simix/smx_deployment.cpp +++ b/src/simix/smx_deployment.cpp @@ -48,8 +48,7 @@ void SIMIX_launch_application(const std::string& file) parse_status = surf_parse(); surf_parse_close(); xbt_assert(not parse_status, "Parse error at %s:%d", file.c_str(), surf_parse_lineno); - } - catch (xbt_ex& e) { + } catch (const xbt_ex&) { XBT_ERROR( "Unrecoverable error at %s:%d. The full exception stack follows, in case it helps you to diagnose the problem.", file.c_str(), surf_parse_lineno); diff --git a/src/smpi/internals/smpi_utils.cpp b/src/smpi/internals/smpi_utils.cpp index ae8df4423a..7e029ad36c 100644 --- a/src/smpi/internals/smpi_utils.cpp +++ b/src/smpi/internals/smpi_utils.cpp @@ -43,14 +43,14 @@ std::vector parse_factor(const std::string& smpi_coef_string) if (factor_iter == factor_values.begin()) { /* first element */ try { fact.factor = std::stoi(*factor_iter); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid factor in chunk ") + std::to_string(smpi_factor.size() + 1) + ": " + *factor_iter); } } else { try { fact.values.push_back(surf_parse_get_time((*factor_iter).c_str(), "smpi factor", "")); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { throw std::invalid_argument(std::string("Invalid factor value ") + std::to_string(iteration) + " in chunk " + std::to_string(smpi_factor.size() + 1) + ": " + *factor_iter); } diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 4a54f6a6cf..85a9497570 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -548,7 +548,7 @@ int Request::test(MPI_Request * request, MPI_Status * status, int* flag) { if ((*request)->action_ != nullptr){ try{ *flag = simcall_comm_test((*request)->action_); - }catch (xbt_ex& e) { + } catch (const xbt_ex&) { *flag = 0; return ret; } @@ -639,7 +639,7 @@ int Request::testany(int count, MPI_Request requests[], int *index, int* flag, M simcall_process_sleep(nsleeps*smpi_test_sleep); try{ i = simcall_comm_testany(comms.data(), comms.size()); // The i-th element in comms matches! - }catch (xbt_ex& e) { + } catch (const xbt_ex&) { return 0; } @@ -901,7 +901,7 @@ int Request::wait(MPI_Request * request, MPI_Status * status) try{ // this is not a detached send simcall_comm_wait((*request)->action_, -1.0); - }catch (xbt_ex& e) { + } catch (const xbt_ex&) { XBT_VERB("Request cancelled"); } } @@ -964,8 +964,8 @@ int Request::waitany(int count, MPI_Request requests[], MPI_Status * status) try{ // this is not a detached send i = simcall_comm_waitany(comms.data(), comms.size(), -1); - }catch (xbt_ex& e) { - XBT_INFO("request %d cancelled ",i); + } catch (const xbt_ex&) { + XBT_INFO("request %d cancelled ", i); return i; } diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index ef5aa096f3..811474ea1b 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -86,7 +86,7 @@ double surf_parse_get_double(const std::string& s) { try { return std::stod(s); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { surf_parse_error(s + " is not a double"); } } @@ -95,7 +95,7 @@ int surf_parse_get_int(const std::string& s) { try { return std::stoi(s); - } catch (std::invalid_argument& ia) { + } catch (const std::invalid_argument&) { surf_parse_error(s + " is not a double"); } } diff --git a/src/xbt/exception.cpp b/src/xbt/exception.cpp index 82b64eeabf..beec1e40fd 100644 --- a/src/xbt/exception.cpp +++ b/src/xbt/exception.cpp @@ -145,7 +145,7 @@ static void handler() std::abort(); } - catch (simgrid::ForcefulKillException const& e) { + catch (const simgrid::ForcefulKillException&) { XBT_ERROR("Received a ForcefulKillException at the top-level exception handler. Maybe a Java->C++ call that is not " "protected " "in a try/catch?"); diff --git a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp index a3c143ffe3..2dce6b2b37 100644 --- a/teshsuite/mc/dwarf-expression/dwarf-expression.cpp +++ b/teshsuite/mc/dwarf-expression/dwarf-expression.cpp @@ -39,8 +39,7 @@ uintptr_t eval_binary_operation( try { simgrid::dwarf::execute(ops, 3, state, stack); - } - catch(std::runtime_error& e) { + } catch (const std::runtime_error&) { fprintf(stderr,"Expression evaluation error"); } @@ -63,7 +62,7 @@ void basic_test(simgrid::dwarf::ExpressionContext const& state) { try { ops[0].atom = DW_OP_drop; simgrid::dwarf::execute(ops, 1, state, stack); - } catch (simgrid::dwarf::evaluation_error& e) { + } catch (const simgrid::dwarf::evaluation_error&) { caught_ex = true; } if (not caught_ex) @@ -125,8 +124,7 @@ void basic_test(simgrid::dwarf::ExpressionContext const& state) { assert(stack.top() == a); assert(stack.top(1) == b); - } - catch(std::runtime_error& e) { + } catch (const std::runtime_error&) { fprintf(stderr,"Expression evaluation error"); } } @@ -148,8 +146,7 @@ void test_deref(simgrid::dwarf::ExpressionContext const& state) { assert(stack.size() == 1); assert(stack.top() == foo); - } - catch(std::runtime_error& e) { + } catch (const std::runtime_error&) { fprintf(stderr,"Expression evaluation error"); } } diff --git a/teshsuite/xbt/mmalloc/mmalloc_test.cpp b/teshsuite/xbt/mmalloc/mmalloc_test.cpp index 847ff6cee3..1220c584fd 100644 --- a/teshsuite/xbt/mmalloc/mmalloc_test.cpp +++ b/teshsuite/xbt/mmalloc/mmalloc_test.cpp @@ -77,7 +77,7 @@ int main(int argc, char**argv) mfree(heapA, pointers[i]); try { mfree(heapA, pointers[i]); - } catch(xbt_ex& e) { + } catch (const xbt_ex&) { gotit = true; } if (not gotit) @@ -89,7 +89,7 @@ int main(int argc, char**argv) bool gotit = false; try { mfree(heapA, pointers[i]); - } catch(xbt_ex& e) { + } catch (const xbt_ex&) { gotit = true; } if (not gotit) -- 2.20.1