From: Martin Quinson Date: Thu, 29 Aug 2019 00:01:45 +0000 (+0200) Subject: further very small steps to modernize our code. thanks clang-tidy X-Git-Tag: v3.24~120 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/92931e4254055b5e99a1d45425a58741862ecf0a further very small steps to modernize our code. thanks clang-tidy --- diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 5b640475ec..7aa840b985 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -55,5 +55,5 @@ void HostCLM03Model::update_actions_state(double /*now*/, double /*delta*/) /* I've no action to update */ } -} -} +} // namespace surf +} // namespace simgrid diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index c480d74ac5..8ef06807b3 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -104,7 +104,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/) { while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_surf_precision)) { - NetworkCm02Action* action = static_cast(get_action_heap().pop()); + auto* action = static_cast(get_action_heap().pop()); XBT_DEBUG("Something happened to action %p", action); // if I am wearing a latency hat @@ -184,7 +184,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz std::any_of(back_route.begin(), back_route.end(), [](const LinkImpl* link) { return not link->is_on(); }); } - NetworkCm02Action *action = new NetworkCm02Action(this, size, failed); + auto* action = new NetworkCm02Action(this, size, failed); action->sharing_penalty_ = latency; action->latency_ = latency; action->rate_ = rate; @@ -340,7 +340,7 @@ void NetworkCm02Link::set_bandwidth(double value) const kernel::lmm::Element* nextelem = nullptr; int numelem = 0; while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { - NetworkCm02Action* action = static_cast(var->get_id()); + auto* action = static_cast(var->get_id()); action->sharing_penalty_ += delta; if (not action->is_suspended()) get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_); @@ -359,7 +359,7 @@ void NetworkCm02Link::set_latency(double value) latency_.peak = value; while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) { - NetworkCm02Action* action = static_cast(var->get_id()); + auto* action = static_cast(var->get_id()); action->lat_current_ += delta; action->sharing_penalty_ += delta; if (action->rate_ < 0) @@ -450,6 +450,6 @@ void NetworkCm02Action::update_remains_lazy(double now) set_last_value(get_variable()->get_value()); } -} -} +} // namespace resource +} // namespace kernel } // namespace simgrid diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index a8be9a9c25..01a34f9bdd 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -47,7 +47,7 @@ class NetworkCm02Link : public LinkImpl { public: NetworkCm02Link(NetworkCm02Model* model, const std::string& name, double bandwidth, double latency, s4u::Link::SharingPolicy policy, lmm::System* system); - virtual ~NetworkCm02Link() = default; + ~NetworkCm02Link() override = default; void apply_event(kernel::profile::Event* event, double value) override; void set_bandwidth(double value) override; void set_latency(double value) override; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 9227e572a6..849b015b06 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -41,7 +41,7 @@ double NetworkConstantModel::next_occuring_event(double /*now*/) { double min = -1.0; for (kernel::resource::Action const& action : *get_started_action_set()) { - const NetworkConstantAction& net_action = static_cast(action); + const auto& net_action = static_cast(action); if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) min = net_action.latency_; } @@ -51,7 +51,7 @@ double NetworkConstantModel::next_occuring_event(double /*now*/) void NetworkConstantModel::update_actions_state(double /*now*/, double delta) { for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { - NetworkConstantAction& action = static_cast(*it); + auto& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it if (action.latency_ > 0) { if (action.latency_ > delta) { @@ -72,7 +72,7 @@ void NetworkConstantModel::update_actions_state(double /*now*/, double delta) Action* NetworkConstantModel::communicate(s4u::Host* src, s4u::Host* dst, double size, double) { - NetworkConstantAction* action = new NetworkConstantAction(this, size, sg_latency_factor); + auto* action = new NetworkConstantAction(this, size, sg_latency_factor); s4u::Link::on_communicate(*action, src, dst); return action; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index ecf55444eb..668366d7f4 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -54,10 +54,10 @@ StorageImpl* StorageN11Model::createStorage(const std::string& id, const std::st { StorageType* storage_type = storage_types.at(type_id); - double Bread = surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), - "property Bread, storage", type_id.c_str()); + double Bread = + surf_parse_get_bandwidth(storage_type->model_properties->at("Bread").c_str(), "property Bread, storage", type_id); double Bwrite = surf_parse_get_bandwidth(storage_type->model_properties->at("Bwrite").c_str(), - "property Bwrite, storage", type_id.c_str()); + "property Bwrite, storage", type_id); XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id.c_str(), type_id.c_str(), Bread); @@ -74,7 +74,7 @@ double StorageN11Model::next_occuring_event(double now) void StorageN11Model::update_actions_state(double /*now*/, double delta) { for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { - StorageAction& action = static_cast(*it); + auto& action = *it; ++it; // increment iterator here since the following calls to action.finish() may invalidate it action.update_remains(lrint(action.get_variable()->get_value() * delta)); action.update_max_duration(delta);