From: Martin Quinson Date: Sat, 5 Jan 2019 02:29:33 +0000 (+0100) Subject: Please sonar X-Git-Tag: v3_22~679 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bd681bde4c1fcad799c5c7c7ee5b58ad345157ef?ds=sidebyside Please sonar - Add 'explicit' where needed - Don't specify the return type of lambdas - Verify that this != that before everything in the operator= - Remove ';' in the comments to not fool the commented code detection mechanism --- diff --git a/examples/msg/maestro-set/maestro-set.cpp b/examples/msg/maestro-set/maestro-set.cpp index 3dd472d5d8..a9c7fd7b22 100644 --- a/examples/msg/maestro-set/maestro-set.cpp +++ b/examples/msg/maestro-set/maestro-set.cpp @@ -15,10 +15,10 @@ #include "simgrid/msg.h" -XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); - #include +XBT_LOG_NEW_DEFAULT_CATEGORY(msg_test, "Messages specific for this msg example"); + std::thread::id root_id; static void ensure_root_tid() { diff --git a/examples/s4u/actor-create/s4u-actor-create.cpp b/examples/s4u/actor-create/s4u-actor-create.cpp index ff7cf6d596..123464fddd 100644 --- a/examples/s4u/actor-create/s4u-actor-create.cpp +++ b/examples/s4u/actor-create/s4u-actor-create.cpp @@ -8,7 +8,7 @@ * The first step is to declare the code of your actors (what they do exactly does not matter to this example) and then * you ask SimGrid to start your actors. There is three ways of doing so: * - Directly, by instantiating your actor as parameter to Actor::create() - * - By first registering your actors before instantiating it; + * - By first registering your actors before instantiating it * - Through the deployment file. * * This example shows all these solutions, even if you obviously should use only one of these solutions to start your diff --git a/include/simgrid/simdag.h b/include/simgrid/simdag.h index ebf6810bac..f689d0d70b 100644 --- a/include/simgrid/simdag.h +++ b/include/simgrid/simdag.h @@ -115,7 +115,7 @@ XBT_PUBLIC void SD_task_schedulel(SD_task_t task, int count, ...); * * For example, create a pure computation task (i.e., with no communication) like this: * - * SD_task_schedule(task, my_host_count, my_host_list, my_flops_amount, SD_SCHED_NO_COST, my_rate); + * SD_task_schedule(task, my_host_count, my_host_list, my_flops_amount, SD_SCHED_NO_COST, my_rate) */ #define SD_SCHED_NO_COST NULL diff --git a/include/simgrid/simix/blocking_simcall.hpp b/include/simgrid/simix/blocking_simcall.hpp index d2c87daeec..d99984abe9 100644 --- a/include/simgrid/simix/blocking_simcall.hpp +++ b/include/simgrid/simix/blocking_simcall.hpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2016-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -33,7 +32,7 @@ XBT_PUBLIC void unblock(smx_actor_t process); * returns a `simgrid::kernel::Future`. The kernel blocks the actor * until the Future is ready and: * - * - either returns the value wrapped in the future to the actor; + * - either returns the value wrapped in the future to the actor * * - or raises the exception stored in the future in the actor. * diff --git a/include/xbt/string.hpp b/include/xbt/string.hpp index cd51303a28..5a393ec4b7 100644 --- a/include/xbt/string.hpp +++ b/include/xbt/string.hpp @@ -121,7 +121,8 @@ public: } string& operator=(string const& s) { - assign(s.c_str(), s.size()); + if (this != &s) + assign(s.c_str(), s.size()); return *this; } string& operator=(std::string const& s) diff --git a/src/mc/sosp/ChunkedData.hpp b/src/mc/sosp/ChunkedData.hpp index c904a29f97..2cad04e3e6 100644 --- a/src/mc/sosp/ChunkedData.hpp +++ b/src/mc/sosp/ChunkedData.hpp @@ -56,11 +56,13 @@ public: } ChunkedData& operator=(ChunkedData const& that) { - this->clear(); - store_ = that.store_; - pagenos_ = that.pagenos_; - for (std::size_t const& pageno : pagenos_) - store_->ref_page(pageno); + if (this != &that) { + this->clear(); + store_ = that.store_; + pagenos_ = that.pagenos_; + for (std::size_t const& pageno : pagenos_) + store_->ref_page(pageno); + } return *this; } ChunkedData& operator=(ChunkedData&& that) diff --git a/src/xbt/OsSemaphore.hpp b/src/xbt/OsSemaphore.hpp index 64598509d8..f6e7083946 100644 --- a/src/xbt/OsSemaphore.hpp +++ b/src/xbt/OsSemaphore.hpp @@ -10,12 +10,12 @@ namespace simgrid { namespace xbt { class XBT_PUBLIC OsSemaphore { public: - inline OsSemaphore(unsigned int uiCount) : capa_(uiCount) {} + explicit inline OsSemaphore(unsigned int capa) : capa_(capa) {} inline void acquire() { std::unique_lock lock(mutex_); - condition_.wait(lock, [&]() -> bool { return capa_ > 0; }); + condition_.wait(lock, [this]() { return capa_ > 0; }); --capa_; }