Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Polymorphic base class destructor should be either public virtual or protected non...
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Mar 2022 20:37:55 +0000 (21:37 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 16 Mar 2022 20:52:06 +0000 (21:52 +0100)
This is Sonar rule S1235
https://sonarcloud.io/organizations/simgrid/rules?open=cpp%3AS1235&rule_key=cpp%3AS1235

Some of the classes are simply marked "final" so that they can never become a
polymorphic base class.

include/simgrid/kernel/resource/NetworkModelIntf.hpp
src/kernel/actor/CommObserver.hpp
src/kernel/actor/SimcallObserver.hpp
src/kernel/actor/SynchroObserver.hpp

index b1dd2cf..ee1c446 100644 (file)
@@ -19,6 +19,9 @@ namespace resource {
  * @brief Network Model interface class
  */
 class XBT_PUBLIC NetworkModelIntf {
+protected:
+  ~NetworkModelIntf() = default;
+
 public:
   /**
    * @brief Callback to set the bandwidth and latency factors used in a communication
@@ -47,4 +50,4 @@ public:
 } // namespace kernel
 } // namespace simgrid
 
-#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */
\ No newline at end of file
+#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */
index 2d86bc6..2358e5a 100644 (file)
@@ -17,7 +17,7 @@ namespace simgrid {
 namespace kernel {
 namespace actor {
 
-class ActivityTestSimcall : public ResultingSimcall<bool> {
+class ActivityTestSimcall final : public ResultingSimcall<bool> {
   activity::ActivityImpl* const activity_;
 
 public:
@@ -30,7 +30,7 @@ public:
   void serialize(std::stringstream& stream) const override;
 };
 
-class ActivityTestanySimcall : public ResultingSimcall<ssize_t> {
+class ActivityTestanySimcall final : public ResultingSimcall<ssize_t> {
   const std::vector<activity::ActivityImpl*>& activities_;
   std::vector<int> indexes_; // indexes in activities_ pointing to ready activities (=whose test() is positive)
   int next_value_ = 0;
@@ -46,7 +46,7 @@ public:
   int get_value() const { return next_value_; }
 };
 
-class ActivityWaitSimcall : public ResultingSimcall<bool> {
+class ActivityWaitSimcall final : public ResultingSimcall<bool> {
   activity::ActivityImpl* activity_;
   const double timeout_;
 
@@ -63,7 +63,7 @@ public:
   double get_timeout() const { return timeout_; }
 };
 
-class ActivityWaitanySimcall : public ResultingSimcall<ssize_t> {
+class ActivityWaitanySimcall final : public ResultingSimcall<ssize_t> {
   const std::vector<activity::ActivityImpl*>& activities_;
   std::vector<int> indexes_; // indexes in activities_ pointing to ready activities (=whose test() is positive)
   const double timeout_;
@@ -81,7 +81,7 @@ public:
   int get_value() const { return next_value_; }
 };
 
-class CommIsendSimcall : public SimcallObserver {
+class CommIsendSimcall final : public SimcallObserver {
   activity::MailboxImpl* mbox_;
   double payload_size_;
   double rate_;
@@ -134,7 +134,7 @@ public:
   auto const& get_copy_data_fun() const { return copy_data_fun_; }
 };
 
-class CommIrecvSimcall : public SimcallObserver {
+class CommIrecvSimcall final : public SimcallObserver {
   activity::MailboxImpl* mbox_;
   unsigned char* dst_buff_;
   size_t* dst_buff_size_;
index 7be562c..56adb66 100644 (file)
@@ -19,6 +19,9 @@ namespace actor {
 class SimcallObserver {
   ActorImpl* const issuer_;
 
+protected:
+  ~SimcallObserver() = default;
+
 public:
   explicit SimcallObserver(ActorImpl* issuer) : issuer_(issuer) {}
   ActorImpl* get_issuer() const { return issuer_; }
@@ -62,6 +65,9 @@ public:
 template <class T> class ResultingSimcall : public SimcallObserver {
   T result_;
 
+protected:
+  ~ResultingSimcall() = default;
+
 public:
   ResultingSimcall() = default;
   ResultingSimcall(ActorImpl* actor, T default_result) : SimcallObserver(actor), result_(default_result) {}
@@ -69,7 +75,7 @@ public:
   T get_result() const { return result_; }
 };
 
-class RandomSimcall : public SimcallObserver {
+class RandomSimcall final : public SimcallObserver {
   const int min_;
   const int max_;
   int next_value_ = 0;
@@ -85,7 +91,7 @@ public:
   int get_value() const { return next_value_; }
 };
 
-class ConditionWaitSimcall : public ResultingSimcall<bool> {
+class ConditionWaitSimcall final : public ResultingSimcall<bool> {
   activity::ConditionVariableImpl* const cond_;
   activity::MutexImpl* const mutex_;
   const double timeout_;
index de283d1..15549bd 100644 (file)
@@ -18,7 +18,7 @@ namespace kernel {
 namespace actor {
 
 /* All the observers of Mutex transitions are very similar, so implement them all together in this class */
-class MutexObserver : public SimcallObserver {
+class MutexObserver final : public SimcallObserver {
   mc::Transition::Type type_;
   activity::MutexImpl* const mutex_;
 
@@ -32,7 +32,7 @@ public:
 };
 
 /* This observer is used for SEM_LOCK and SEM_UNLOCK (only) */
-class SemaphoreObserver : public SimcallObserver {
+class SemaphoreObserver final : public SimcallObserver {
   mc::Transition::Type type_;
   activity::SemaphoreImpl* const sem_;
 
@@ -45,7 +45,7 @@ public:
 };
 
 /* This observer is ued for SEM_WAIT, that is returning and needs the acquisition (in MC mode) */
-class SemaphoreAcquisitionObserver : public ResultingSimcall<bool> {
+class SemaphoreAcquisitionObserver final : public ResultingSimcall<bool> {
   mc::Transition::Type type_;
   activity::SemAcquisitionImpl* const acquisition_;
   const double timeout_;
@@ -61,7 +61,7 @@ public:
 };
 
 /* This observer is ued for BARRIER_LOCK and BARRIER_WAIT. WAIT is returning and needs the acquisition */
-class BarrierObserver : public ResultingSimcall<bool> {
+class BarrierObserver final : public ResultingSimcall<bool> {
   mc::Transition::Type type_;
   activity::BarrierImpl* const barrier_                = nullptr;
   activity::BarrierAcquisitionImpl* const acquisition_ = nullptr;