From 52b5d4fb3c307a34756d8a95aadf79d01af14cdd Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 27 Dec 2019 23:45:30 +0100 Subject: [PATCH] [sonar] Constify pointer and reference parameters in src/kernel/. --- include/simgrid/kernel/routing/FatTreeZone.hpp | 4 ++-- include/simgrid/kernel/routing/RoutedZone.hpp | 2 +- src/kernel/actor/ActorImpl.cpp | 2 +- src/kernel/actor/ActorImpl.hpp | 2 +- src/kernel/context/ContextSwapped.cpp | 2 +- src/kernel/lmm/maxmin.cpp | 4 ++-- src/kernel/lmm/maxmin.hpp | 6 +++--- src/kernel/routing/FatTreeZone.cpp | 4 ++-- src/kernel/routing/RoutedZone.cpp | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/simgrid/kernel/routing/FatTreeZone.hpp b/include/simgrid/kernel/routing/FatTreeZone.hpp index 0e69e0dc14..a176471b40 100644 --- a/include/simgrid/kernel/routing/FatTreeZone.hpp +++ b/include/simgrid/kernel/routing/FatTreeZone.hpp @@ -51,7 +51,7 @@ public: * instead of passing by an upper level switch. */ resource::LinkImpl* loopback; - FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position); + FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position); }; /** @brief Link in a fat tree (@ref FatTreeZone). @@ -61,7 +61,7 @@ public: */ class FatTreeLink { public: - FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination); + FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* source, FatTreeNode* destination); /** Link going up in the tree */ resource::LinkImpl* up_link_; /** Link going down in the tree */ diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index 55995aafc6..0d8a73e665 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -61,7 +61,7 @@ protected: bool symmetrical, bool change_order); void get_route_check_params(NetPoint* src, NetPoint* dst); void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool symmetrical); + const std::vector& link_list, bool symmetrical); }; } // namespace routing } // namespace kernel diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index f9b38a5d55..fdf73a3b89 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -392,7 +392,7 @@ void ActorImpl::resume() XBT_OUT(); } -activity::ActivityImplPtr ActorImpl::join(ActorImpl* actor, double timeout) +activity::ActivityImplPtr ActorImpl::join(const ActorImpl* actor, double timeout) { activity::ActivityImplPtr sleep = this->sleep(timeout); actor->on_exit->emplace_back([sleep](bool) { diff --git a/src/kernel/actor/ActorImpl.hpp b/src/kernel/actor/ActorImpl.hpp index e7ea0d9d7d..47225f3fc5 100644 --- a/src/kernel/actor/ActorImpl.hpp +++ b/src/kernel/actor/ActorImpl.hpp @@ -133,7 +133,7 @@ public: s4u::Actor* restart(); void suspend(); void resume(); - activity::ActivityImplPtr join(ActorImpl* actor, double timeout); + activity::ActivityImplPtr join(const ActorImpl* actor, double timeout); activity::ActivityImplPtr sleep(double duration); /** Ask the actor to throw an exception right away */ void throw_exception(std::exception_ptr e); diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index e2ca4165ff..862ef938f5 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -162,7 +162,7 @@ void SwappedContextFactory::run_all() // It only yields back to worker_context when the work array is exhausted. // - So, resume() is only launched from the parmap for the first job of each minion. parmap_->apply( - [](smx_actor_t process) { + [](const actor::ActorImpl* process) { SwappedContext* context = static_cast(process->context_.get()); context->resume(); }, diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index aeceb03484..bf8777530c 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -396,7 +396,7 @@ static inline void saturated_constraints_update(double usage, int cnst_light_num } } -static inline void saturated_variable_set_update(ConstraintLight* cnst_light_tab, +static inline void saturated_variable_set_update(const ConstraintLight* cnst_light_tab, const dyn_light_t& saturated_constraints, System* sys) { /* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate @@ -872,7 +872,7 @@ void System::update_constraint_bound(Constraint* cnst, double bound) * A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each * constraint change is propagated to the list of constraints for each variable. */ -void System::update_modified_set_rec(Constraint* cnst) +void System::update_modified_set_rec(const Constraint* cnst) { for (Element const& elem : cnst->enabled_element_set_) { Variable* var = elem.variable; diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index 3f7dd3878a..468aee3cf3 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -439,7 +439,7 @@ public: /** @brief Update a constraint bound */ void update_constraint_bound(Constraint * cnst, double bound); - int constraint_used(Constraint* cnst) { return cnst->active_constraint_set_hook_.is_linked(); } + int constraint_used(const Constraint* cnst) const { return cnst->active_constraint_set_hook_.is_linked(); } /** @brief Print the lmm system */ void print() const; @@ -505,8 +505,8 @@ private: */ void update(Constraint * cnst, Variable * var, double value); - void update_modified_set(Constraint * cnst); - void update_modified_set_rec(Constraint * cnst); + void update_modified_set(Constraint* cnst); + void update_modified_set_rec(const Constraint* cnst); /** @brief Remove all constraints of the modified_constraint_set. */ void remove_all_modified_set(); diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index 475e034431..9e7d2cc55a 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -438,7 +438,7 @@ void FatTreeZone::generate_dot_file(const std::string& filename) const file.close(); } -FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int position) +FatTreeNode::FatTreeNode(const ClusterCreationArgs* cluster, int id, int level, int position) : id(id), level(level), position(position) { LinkCreationArgs linkTemplate; @@ -460,7 +460,7 @@ FatTreeNode::FatTreeNode(ClusterCreationArgs* cluster, int id, int level, int po } } -FatTreeLink::FatTreeLink(ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode) +FatTreeLink::FatTreeLink(const ClusterCreationArgs* cluster, FatTreeNode* downNode, FatTreeNode* upNode) : up_node_(upNode), down_node_(downNode) { static int uniqueId = 0; diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 135b6246d3..04eaf947d0 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -166,7 +166,7 @@ void RoutedZone::get_route_check_params(NetPoint* src, NetPoint* dst) src->get_cname(), dst->get_cname(), src_as->get_cname(), dst_as->get_cname(), get_cname()); } void RoutedZone::add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool symmetrical) + const std::vector& link_list, bool symmetrical) { const char* srcName = src->get_cname(); const char* dstName = dst->get_cname(); -- 2.20.1