From: Maxwell Pirtle Date: Mon, 27 Feb 2023 08:20:49 +0000 (+0100) Subject: Fix most of the remaining code warnings X-Git-Tag: v3.34~422^2~11 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/b54403a768353ed64e0b4f4b5afcc89933f585f4 Fix most of the remaining code warnings This commit fixes the majority of the code warnings pointed out by SonarSource. There are some others that will disappear with other phases once e.g. the functions in UdporChecker are actually implemented --- diff --git a/src/mc/explo/UdporChecker.cpp b/src/mc/explo/UdporChecker.cpp index c5d596d1f1..cb6f522fa3 100644 --- a/src/mc/explo/UdporChecker.cpp +++ b/src/mc/explo/UdporChecker.cpp @@ -57,8 +57,7 @@ void UdporChecker::explore(const Configuration& C, EventSet D, EventSet A, std:: if (enC.is_subset_of(D)) { if (not C.get_events().empty()) { - - // g_var::nb_traces++; + // Report information... } // When `en(C)` is empty, intuitively this means that there diff --git a/src/mc/explo/UdporChecker.hpp b/src/mc/explo/UdporChecker.hpp index f19c8c61de..30407c4217 100644 --- a/src/mc/explo/UdporChecker.hpp +++ b/src/mc/explo/UdporChecker.hpp @@ -42,14 +42,6 @@ public: inline std::unique_ptr get_current_state() { return std::make_unique(get_remote_app()); } private: - /** - * The total number of events created whilst exploring the unfolding - */ - /* FIXME: private fields are not used - uint32_t nb_events = 0; - uint32_t nb_traces = 0; - */ - /** * @brief The "relevant" portions of the unfolding that must be kept around to ensure that * UDPOR properly searches the state space @@ -88,7 +80,6 @@ private: std::unordered_map incremental_extension_functions = std::unordered_map(); -private: /** * @brief Explores the unfolding of the concurrent system * represented by the ModelChecker instance "mcmodel_checker" diff --git a/src/mc/explo/udpor/Configuration.cpp b/src/mc/explo/udpor/Configuration.cpp index c4bdd79ee2..1923345630 100644 --- a/src/mc/explo/udpor/Configuration.cpp +++ b/src/mc/explo/udpor/Configuration.cpp @@ -54,7 +54,9 @@ std::vector Configuration::get_topologically_sorted_events() co std::stack event_stack; std::vector topological_ordering; - EventSet unknown_events = events_, temporarily_marked_events, permanently_marked_events; + EventSet unknown_events = events_; + EventSet temporarily_marked_events; + EventSet permanently_marked_events; while (not unknown_events.empty()) { EventSet discovered_events; diff --git a/src/mc/explo/udpor/Configuration_test.cpp b/src/mc/explo/udpor/Configuration_test.cpp index 5232a0542d..9a5a756b08 100644 --- a/src/mc/explo/udpor/Configuration_test.cpp +++ b/src/mc/explo/udpor/Configuration_test.cpp @@ -24,7 +24,8 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Constructing Configurations") UnfoldingEvent e1; UnfoldingEvent e2{&e1}; UnfoldingEvent e3{&e2}; - UnfoldingEvent e4{&e3}, e5{&e3}; + UnfoldingEvent e4{&e3}; + UnfoldingEvent e5{&e3}; SECTION("Creating a configuration without events") { @@ -191,8 +192,9 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order More Compli UnfoldingEvent e1; UnfoldingEvent e2{&e1}; UnfoldingEvent e3{&e2}; - UnfoldingEvent e4{&e3}, e6{&e3}; + UnfoldingEvent e4{&e3}; UnfoldingEvent e5{&e4}; + UnfoldingEvent e6{&e3}; SECTION("Topological ordering for subsets") { @@ -293,12 +295,16 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli // / / / // [ e12 ] UnfoldingEvent e1; - UnfoldingEvent e2{&e1}, e8{&e1}; + UnfoldingEvent e2{&e1}; + UnfoldingEvent e8{&e1}; UnfoldingEvent e3{&e2}; UnfoldingEvent e4{&e3}; - UnfoldingEvent e5{&e4}, e6{&e4}; - UnfoldingEvent e7{&e2, &e8}, e11{&e8}; - UnfoldingEvent e10{&e7}, e9{&e6, &e7}; + UnfoldingEvent e5{&e4}; + UnfoldingEvent e6{&e4}; + UnfoldingEvent e7{&e2, &e8}; + UnfoldingEvent e9{&e6, &e7}; + UnfoldingEvent e10{&e7}; + UnfoldingEvent e11{&e8}; UnfoldingEvent e12{&e5, &e9, &e10}; Configuration C{&e1, &e2, &e3, &e4, &e5, &e6, &e7, &e8, &e9, &e10, &e11, &e12}; @@ -307,12 +313,10 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli // To test this, we ensure that for the `i`th event // in `ordered_events`, each event in `ordered_events[0...&& raw_events) : events_(std::move(raw_events)) {} + explicit EventSet(std::unordered_set&& raw_events) : events_(raw_events) {} explicit EventSet(std::initializer_list event_list) : events_(std::move(event_list)) {} auto begin() const { return this->events_.begin(); } @@ -56,7 +56,6 @@ public: bool operator==(const EventSet& other) const { return this->events_ == other.events_; } bool operator!=(const EventSet& other) const { return this->events_ != other.events_; } -public: /** * @brief Whether or not this set of events could * represent a configuration diff --git a/src/mc/explo/udpor/EventSet_test.cpp b/src/mc/explo/udpor/EventSet_test.cpp index 14fb1627fb..d7342b39a6 100644 --- a/src/mc/explo/udpor/EventSet_test.cpp +++ b/src/mc/explo/udpor/EventSet_test.cpp @@ -109,7 +109,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Insertions") TEST_CASE("simgrid::mc::udpor::EventSet: Deletions") { - UnfoldingEvent e1, e2, e3, e4; + UnfoldingEvent e1; + UnfoldingEvent e2; + UnfoldingEvent e3; + UnfoldingEvent e4; EventSet event_set({&e1, &e2, &e3}); SECTION("Remove an element already present") @@ -181,7 +184,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions") TEST_CASE("simgrid::mc::udpor::EventSet: Set Equality") { - UnfoldingEvent e1, e2, e3, e4; + UnfoldingEvent e1; + UnfoldingEvent e2; + UnfoldingEvent e3; + UnfoldingEvent e4; EventSet A{&e1, &e2, &e3}, B{&e1, &e2, &e3}, C{&e1, &e2, &e3}; SECTION("Equality implies containment") @@ -515,8 +521,10 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Testing Configurations") // in the structure and test whether those subsets are // maximal and/or valid configurations UnfoldingEvent e1; - UnfoldingEvent e2{&e1}, e5{&e1}; - UnfoldingEvent e3{&e2}, e4{&e2}; + UnfoldingEvent e2{&e1}; + UnfoldingEvent e3{&e2}; + UnfoldingEvent e4{&e2}; + UnfoldingEvent e5{&e1}; UnfoldingEvent e6{&e5}; SECTION("Valid Configurations") diff --git a/src/mc/explo/udpor/History.cpp b/src/mc/explo/udpor/History.cpp index bb24494273..e6a6405f9e 100644 --- a/src/mc/explo/udpor/History.cpp +++ b/src/mc/explo/udpor/History.cpp @@ -80,7 +80,7 @@ bool History::contains(const UnfoldingEvent* e) const EventSet History::get_event_diff_with(const Configuration& config) const { auto wrapped_config = std::optional>{config}; - auto first = Iterator(events_, std::move(wrapped_config)); + auto first = Iterator(events_, wrapped_config); const auto last = this->end(); for (; first != last; ++first) diff --git a/src/mc/explo/udpor/History_test.cpp b/src/mc/explo/udpor/History_test.cpp index 0cbe87881a..55065a3e91 100644 --- a/src/mc/explo/udpor/History_test.cpp +++ b/src/mc/explo/udpor/History_test.cpp @@ -18,9 +18,12 @@ TEST_CASE("simgrid::mc::udpor::History: History generation") // | \ \ / / // e3 e4 e5 e7 UnfoldingEvent e1; - UnfoldingEvent e2{&e1}, e6{&e1}; - UnfoldingEvent e3{&e2}, e4{&e2}; - UnfoldingEvent e5{&e2, &e6}, e7{&e6}; + UnfoldingEvent e2{&e1}; + UnfoldingEvent e6{&e1}; + UnfoldingEvent e3{&e2}; + UnfoldingEvent e4{&e2}; + UnfoldingEvent e5{&e2, &e6}; + UnfoldingEvent e7{&e6}; SECTION("History with no events") {