From: SUTER Frederic Date: Mon, 3 Jan 2022 09:15:43 +0000 (+0100) Subject: [sonar] fix smells X-Git-Tag: v3.30~140 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/17de27f983314402e5bd16ca1ce8d0d3866d929b [sonar] fix smells --- diff --git a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp index 6dfad8e0ce..bdced0001c 100644 --- a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp +++ b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp @@ -43,7 +43,7 @@ static void sg_host_set_last_scheduled_task(simgrid::s4u::Host* host, simgrid::s host->set_data(attr); } -static bool dependency_exists(simgrid::s4u::Exec* src, simgrid::s4u::Exec* dst) +static bool dependency_exists(const simgrid::s4u::Exec* src, simgrid::s4u::Exec* dst) { const auto& dependencies = src->get_dependencies(); const auto& successors = src->get_successors(); @@ -51,7 +51,7 @@ static bool dependency_exists(simgrid::s4u::Exec* src, simgrid::s4u::Exec* dst) dependencies.find(dst) != dependencies.end()); } -static std::vector get_ready_tasks(const std::vector dax) +static std::vector get_ready_tasks(const std::vector& dax) { std::vector ready_tasks; std::map candidate_execs; @@ -65,7 +65,7 @@ static std::vector get_ready_tasks(const std::vector(a.get()); + const auto* comm = dynamic_cast(a.get()); if (comm != nullptr) { auto* next_exec = static_cast(comm->get_successors().front().get()); candidate_execs[next_exec]++; @@ -91,7 +91,7 @@ static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u: last_data_available = -1.0; for (const auto& parent : parents) { /* normal case */ - auto* comm = dynamic_cast(parent.get()); + const auto* comm = dynamic_cast(parent.get()); if (comm != nullptr) { auto source = comm->get_source(); XBT_DEBUG("transfer from %s to %s", source->get_cname(), host->get_cname()); @@ -108,7 +108,7 @@ static double finish_on_at(const simgrid::s4u::ExecPtr task, const simgrid::s4u: data_available = *(static_cast(comm->get_data())) + redist_time; } - auto* exec = dynamic_cast(parent.get()); + const auto* exec = dynamic_cast(parent.get()); /* no transfer, control dependency */ if (exec != nullptr) { data_available = exec->get_finish_time(); @@ -161,7 +161,7 @@ int main(int argc, char** argv) for (const auto& succ : exec->get_successors()) { auto* comm = dynamic_cast(succ.get()); if (comm != nullptr) { - double* finish_time = new double(exec->get_finish_time()); + auto* finish_time = new double(exec->get_finish_time()); // We use the user data field to store the finish time of the predecessor of the comm, i.e., its potential start // time comm->set_data(finish_time); @@ -172,10 +172,10 @@ int main(int argc, char** argv) e.load_platform(argv[1]); /* Allocating the host attribute */ - unsigned int total_nhosts = e.get_host_count(); + unsigned long total_nhosts = e.get_host_count(); const auto hosts = e.get_all_hosts(); - for (unsigned int i = 0; i < total_nhosts; i++) + for (unsigned long i = 0; i < total_nhosts; i++) hosts[i]->set_data(xbt_new0(struct _HostAttribute, 1)); /* load the DAX file */ diff --git a/src/dag/loaders.cpp b/src/dag/loaders.cpp index 48d833a19a..2b9eaa2721 100644 --- a/src/dag/loaders.cpp +++ b/src/dag/loaders.cpp @@ -19,12 +19,12 @@ #include "dax_dtd.h" #include "dax_dtd.c" -XBT_LOG_NEW_DEFAULT_CATEGORY(dag_parsing, "Generation DAGs from files"); - #if HAVE_GRAPHVIZ #include #endif +XBT_LOG_NEW_DEFAULT_CATEGORY(dag_parsing, "Generation DAGs from files"); + /* Ensure that transfer tasks have unique names even though a file is used several times */ static void uniq_transfer_task_name(simgrid::s4u::Comm* comm) {