From ee004ae503ecdf8ddbf1e0cf080aab5702fc66d1 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 28 Feb 2022 15:38:28 +0100 Subject: [PATCH] Minor sonar smells, and other cosmetics. --- examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp | 4 ++-- src/kernel/activity/ActivityImpl.hpp | 2 +- src/kernel/actor/SynchroObserver.cpp | 2 +- src/mc/mc_record.cpp | 4 ++-- src/mc/mc_record.hpp | 2 +- src/mc/remote/AppSide.cpp | 1 - src/mc/transition/TransitionSynchro.cpp | 2 -- src/simix/popping.cpp | 1 - teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp | 5 ++--- 9 files changed, 9 insertions(+), 14 deletions(-) diff --git a/examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp b/examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp index 9c7d4f6754..31765267c8 100644 --- a/examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp +++ b/examples/cpp/synchro-mutex/s4u-synchro-mutex.cpp @@ -5,10 +5,10 @@ #include "simgrid/s4u.hpp" /* All of S4U */ #include "xbt/config.hpp" -namespace sg4 = simgrid::s4u; - #include /* std::mutex and std::lock_guard */ +namespace sg4 = simgrid::s4u; + static simgrid::config::Flag cfg_actor_count("actors", "How many pairs of actors should be started?", 6); XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_test, "a sample log category"); diff --git a/src/kernel/activity/ActivityImpl.hpp b/src/kernel/activity/ActivityImpl.hpp index 6da6349793..d2bb0015e8 100644 --- a/src/kernel/activity/ActivityImpl.hpp +++ b/src/kernel/activity/ActivityImpl.hpp @@ -90,7 +90,7 @@ public: // Support for the boost::intrusive_ptr datatype friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity); friend XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity); - int get_refcount() { return refcount_; } // For debugging purpose + int get_refcount() const { return refcount_; } // For debugging purpose static xbt::signal on_suspended; static xbt::signal on_resumed; diff --git a/src/kernel/actor/SynchroObserver.cpp b/src/kernel/actor/SynchroObserver.cpp index a1c0be4bfb..a0bc2c406d 100644 --- a/src/kernel/actor/SynchroObserver.cpp +++ b/src/kernel/actor/SynchroObserver.cpp @@ -25,7 +25,7 @@ MutexObserver::MutexObserver(ActorImpl* actor, mc::Transition::Type type, activi void MutexObserver::serialize(std::stringstream& stream) const { - auto* owner = get_mutex()->get_owner(); + const auto* owner = get_mutex()->get_owner(); stream << (short)type_ << ' ' << get_mutex()->get_id() << ' ' << (owner != nullptr ? owner->get_pid() : -1); } diff --git a/src/mc/mc_record.cpp b/src/mc/mc_record.cpp index dbc8e7cbba..71729c7d89 100644 --- a/src/mc/mc_record.cpp +++ b/src/mc/mc_record.cpp @@ -21,11 +21,11 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_record, mc, "Logging specific to MC record/re namespace simgrid { namespace mc { -void RecordTrace::replay() +void RecordTrace::replay() const { simgrid::mc::execute_actors(); - for (simgrid::mc::Transition* const transition : transitions_) { + for (const simgrid::mc::Transition* transition : transitions_) { XBT_DEBUG("Executing %ld$%i", transition->aid_, transition->times_considered_); // Choose a request: diff --git a/src/mc/mc_record.hpp b/src/mc/mc_record.hpp index 5b162d6e56..e63da6106a 100644 --- a/src/mc/mc_record.hpp +++ b/src/mc/mc_record.hpp @@ -39,7 +39,7 @@ public: void push_back(Transition* t) { transitions_.push_back(t); } /** Replay all transitions of a trace */ - void replay(); + void replay() const; /** Parse and replay a string representation */ static void replay(const std::string& trace); diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index ae14cf9b14..afca0e3cb8 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -121,7 +121,6 @@ void AppSide::handle_simcall_execute(const s_mc_message_simcall_execute_t* messa XBT_DEBUG("send SIMCALL_EXECUTE_ANSWER(%s) ~> '%s'", actor->get_cname(), str.c_str()); xbt_assert(channel_.send(answer) == 0, "Could not send response"); - } void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const diff --git a/src/mc/transition/TransitionSynchro.cpp b/src/mc/transition/TransitionSynchro.cpp index 88c27ce083..363db946b1 100644 --- a/src/mc/transition/TransitionSynchro.cpp +++ b/src/mc/transition/TransitionSynchro.cpp @@ -27,14 +27,12 @@ MutexTransition::MutexTransition(aid_t issuer, int times_considered, Type type, bool MutexTransition::depends(const Transition* o) const { - if (o->type_ < type_) return o->depends(this); // type_ <= other->type_ in MUTEX_LOCK, MUTEX_TEST, MUTEX_TRYLOCK, MUTEX_UNLOCK, MUTEX_WAIT, if (auto* other = dynamic_cast(o)) { - // Theorem 4.4.7: Any pair of synchronization actions of distinct actors concerning distinct mutexes are independent if (mutex_ != other->mutex_) return false; diff --git a/src/simix/popping.cpp b/src/simix/popping.cpp index 93544f8a93..74bf611581 100644 --- a/src/simix/popping.cpp +++ b/src/simix/popping.cpp @@ -42,7 +42,6 @@ void simgrid::kernel::actor::ActorImpl::simcall_handle(int times_considered) const char* SIMIX_simcall_name(const s_smx_simcall& simcall) { if (simcall.observer_ != nullptr) { - static std::string name; name = boost::core::demangle(typeid(*simcall.observer_).name()); const char* cname = name.c_str(); diff --git a/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp b/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp index c680bb0af3..50c1f4c064 100644 --- a/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp +++ b/teshsuite/s4u/monkey-masterworkers/monkey-masterworkers.cpp @@ -36,7 +36,7 @@ static simgrid::config::Flag cfg_task_count{"task-count", "Amount of tasks int todo; // remaining amount of tasks to execute, a global variable sg4::Mailbox* mailbox; // as a global to reduce the amount of simcalls during actor reboot -static void master() +XBT_ATTRIB_NORETURN static void master() { double comp_size = 1e6; long comm_size = 1e6; @@ -90,7 +90,6 @@ static void worker(int id) todo--; } catch (const simgrid::TimeoutException&) { XBT_INFO("Timeouted while getting a task."); - } catch (const simgrid::NetworkFailureException&) { XBT_INFO("Got a NetworkFailureException. Wait a second before starting again."); sg4::this_actor::sleep_for(1); @@ -122,7 +121,7 @@ int main(int argc, char* argv[]) } } rootzone->seal(); - sg4::Engine::get_instance()->on_platform_created(); // FIXME this should not be necessary + sg4::Engine::on_platform_created(); // FIXME this should not be necessary sg4::Actor::create("master", main, master)->set_auto_restart(true); int id = 0; -- 2.20.1