Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
A few more sonar smells.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Mar 2022 19:25:26 +0000 (20:25 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Mar 2022 19:51:50 +0000 (20:51 +0100)
include/xbt/automaton.hpp
include/xbt/functional.hpp
src/include/xbt/parmap.hpp
src/kernel/activity/ActivityImpl.hpp
src/kernel/activity/ExecImpl.hpp
src/kernel/actor/ActorImpl.hpp

index 49d55f5..8c4ac2e 100644 (file)
@@ -23,7 +23,7 @@ template <class F> xbt_automaton_propositional_symbol_t add_proposition(const_xb
 {
   auto* callback = new F(std::move(f));
   return xbt_automaton_propositional_symbol_new_callback(
-      a, id, [](void* cb) -> int { return (*(F*)cb)(); }, callback, [](void* cb) -> void { delete (F*)cb; });
+      a, id, [](auto* cb) -> int { return (*(F*)cb)(); }, callback, [](auto* cb) -> void { delete (F*)cb; });
 }
 
 }
index 1bb1e36..9509d49 100644 (file)
@@ -37,11 +37,10 @@ public:
   }
   void operator()() const
   {
-    const int argc                = args_->size();
     std::vector<std::string> args = *args_;
     std::vector<char*> argv(args.size() + 1); // argv[argc] is nullptr
     std::transform(begin(args), end(args), begin(argv), [](std::string& s) { return &s.front(); });
-    code_(argc, argv.data());
+    code_(static_cast<int>(args.size()), argv.data());
   }
 };
 
index 9cebe1d..48ce17e 100644 (file)
@@ -238,7 +238,7 @@ template <typename T> boost::optional<T> Parmap<T>::next()
  */
 template <typename T> void Parmap<T>::work()
 {
-  unsigned length = common_data->size();
+  unsigned length = static_cast<unsigned>(common_data->size());
   unsigned index  = common_index.fetch_add(1, std::memory_order_relaxed);
   while (index < length) {
     worker_fun((*common_data)[index]);
index 5edb48e..68126bc 100644 (file)
@@ -90,7 +90,7 @@ public:
   // Support for the boost::intrusive_ptr<ActivityImpl> datatype
   friend XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
   friend XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
-  int get_refcount() const { return refcount_; } // For debugging purpose
+  int get_refcount() const { return static_cast<int>(refcount_); } // For debugging purpose
 
   static xbt::signal<void(ActivityImpl const&)> on_suspended;
   static xbt::signal<void(ActivityImpl const&)> on_resumed;
index f69b6ee..7133154 100644 (file)
@@ -46,7 +46,7 @@ public:
   ExecImpl& set_thread_count(int thread_count);
   ExecImpl& set_hosts(const std::vector<s4u::Host*>& hosts);
 
-  unsigned int get_host_number() const { return hosts_.size(); }
+  unsigned int get_host_number() const { return static_cast<unsigned>(hosts_.size()); }
   double get_seq_remaining_ratio();
   double get_par_remaining_ratio();
   double get_remaining() const override;
index 9979c40..d822f6d 100644 (file)
@@ -114,7 +114,7 @@ private:
   std::atomic_int_fast32_t refcount_{0};
 
 public:
-  int get_refcount() const { return refcount_; }
+  int get_refcount() const { return static_cast<int>(refcount_); }
   friend void intrusive_ptr_add_ref(ActorImpl* actor)
   {
     // This whole memory consistency semantic drives me nuts.