From a6924a7a3d99b6c4cd07e13dae75a33fbb634cf2 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 27 Dec 2019 23:19:09 +0100 Subject: [PATCH] [sonar] Constify pointer and reference parameters in src/instr/. --- include/simgrid/jedule/jedule_events.hpp | 2 +- src/instr/instr_interface.cpp | 16 ++++++++-------- src/instr/instr_platform.cpp | 4 ++-- src/instr/instr_private.hpp | 2 +- src/instr/jedule/jedule_events.cpp | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/simgrid/jedule/jedule_events.hpp b/include/simgrid/jedule/jedule_events.hpp index 5af7f4e576..10a817a2a0 100644 --- a/include/simgrid/jedule/jedule_events.hpp +++ b/include/simgrid/jedule/jedule_events.hpp @@ -23,7 +23,7 @@ public: : name_(name), start_time_(start_time), end_time_(end_time), type_(type) { } - void add_characteristic(char* characteristic); + void add_characteristic(const char* characteristic); void add_resources(const std::vector& host_selection); void add_info(char* key, char* value); void print(FILE* file) const; diff --git a/src/instr/instr_interface.cpp b/src/instr/instr_interface.cpp index ba355e2458..be98a043d6 100644 --- a/src/instr/instr_interface.cpp +++ b/src/instr/instr_interface.cpp @@ -25,13 +25,13 @@ std::set user_link_variables; extern std::set trivaNodeTypes; extern std::set trivaEdgeTypes; -static xbt_dynar_t instr_set_to_dynar(std::set* filter) +static xbt_dynar_t instr_set_to_dynar(const std::set& filter) { if (not TRACE_is_enabled() || not TRACE_needs_platform()) return nullptr; xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref); - for (auto const& name : *filter) + for (auto const& name : filter) xbt_dynar_push_as(ret, char*, xbt_strdup(name.c_str())); return ret; @@ -123,7 +123,7 @@ xbt_dynar_t TRACE_get_categories () { if (not TRACE_is_enabled() || not TRACE_categorized()) return nullptr; - return instr_set_to_dynar(&created_categories); + return instr_set_to_dynar(created_categories); } /** @ingroup TRACE_mark @@ -258,7 +258,7 @@ xbt_dynar_t TRACE_get_marks () if (not TRACE_is_enabled()) return nullptr; - return instr_set_to_dynar(&declared_marks); + return instr_set_to_dynar(declared_marks); } static void instr_user_variable(double time, const char* resource, const char* variable_name, const char* father_type, @@ -620,7 +620,7 @@ void TRACE_host_variable_sub_with_time (double time, const char *host, const cha */ xbt_dynar_t TRACE_get_host_variables () { - return instr_set_to_dynar(&user_host_variables); + return instr_set_to_dynar(user_host_variables); } /* for link variables */ @@ -891,7 +891,7 @@ void TRACE_link_srcdst_variable_sub_with_time (double time, const char *src, con */ xbt_dynar_t TRACE_get_link_variables () { - return instr_set_to_dynar(&user_link_variables); + return instr_set_to_dynar(user_link_variables); } /** @ingroup TRACE_user_variables @@ -985,7 +985,7 @@ void TRACE_host_pop_state(const char* host, const char* state_name) */ xbt_dynar_t TRACE_get_node_types () { - return instr_set_to_dynar(&trivaNodeTypes); + return instr_set_to_dynar(trivaNodeTypes); } /** @ingroup TRACE_API @@ -998,5 +998,5 @@ xbt_dynar_t TRACE_get_node_types () */ xbt_dynar_t TRACE_get_edge_types () { - return instr_set_to_dynar(&trivaEdgeTypes); + return instr_set_to_dynar(trivaEdgeTypes); } diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index dc634259c5..98bdf5c36c 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -29,7 +29,7 @@ static const char* instr_node_name(xbt_node_t node) return static_cast(xbt_graph_node_get_data(node)); } -static container_t lowestCommonAncestor(container_t a1, container_t a2) +static container_t lowestCommonAncestor(const simgrid::instr::Container* a1, const simgrid::instr::Container* a2) { // this is only an optimization (since most of a1 and a2 share the same parent) if (a1->father_ == a2->father_) @@ -517,7 +517,7 @@ xbt_graph_t instr_routing_platform_graph() return ret; } -void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename) +void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename) { unsigned int cursor = 0; xbt_node_t node = nullptr; diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index 228d6fa770..ff39b1a543 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -291,6 +291,6 @@ XBT_PRIVATE std::string TRACE_get_filename(); /* instr_platform */ xbt_graph_t instr_routing_platform_graph(); -void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename); +void instr_routing_platform_graph_export_graphviz(const s_xbt_graph_t* g, const char* filename); #endif diff --git a/src/instr/jedule/jedule_events.cpp b/src/instr/jedule/jedule_events.cpp index 2744fcd87e..e1640583b5 100644 --- a/src/instr/jedule/jedule_events.cpp +++ b/src/instr/jedule/jedule_events.cpp @@ -17,7 +17,7 @@ void Event::add_resources(const std::vector& host_selection) get_resource_selection_by_hosts(this->resource_subsets_, host_selection); } -void Event::add_characteristic(char* characteristic) +void Event::add_characteristic(const char* characteristic) { xbt_assert( characteristic != nullptr ); this->characteristics_list_.push_back(characteristic); -- 2.20.1