Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
More Sonar issues.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 23 Feb 2023 14:53:26 +0000 (15:53 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 23 Feb 2023 15:19:00 +0000 (16:19 +0100)
examples/sthread/pthread-producer-consumer.c
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/s4u/s4u_Actor.cpp
src/sthread/sthread_impl.cpp

index bc07550..78deb2b 100644 (file)
@@ -58,7 +58,8 @@ int main(int argc, char** argv)
 {
   if (argc == 2 && strcmp(argv[1], "-q") == 0)
     do_output = 0;
-  pthread_t pro[2], con[2];
+  pthread_t pro[2];
+  pthread_t con[2];
   pthread_mutex_init(&mutex, NULL);
   sem_init(&empty, 0, BufferSize);
   sem_init(&full, 0, 0);
@@ -66,9 +67,9 @@ int main(int argc, char** argv)
   int ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // The identity of each thread (for debug messages)
 
   for (int i = 0; i < ProducerCount; i++)
-    pthread_create(&pro[i], NULL, (void*)producer, (void*)&ids[i]);
+    pthread_create(&pro[i], NULL, (void*)&producer, (void*)&ids[i]);
   for (int i = 0; i < ConsumerCount; i++)
-    pthread_create(&con[i], NULL, (void*)consumer, (void*)&ids[i]);
+    pthread_create(&con[i], NULL, (void*)&consumer, (void*)&ids[i]);
 
   for (int i = 0; i < ProducerCount; i++)
     pthread_join(pro[i], NULL);
@@ -80,4 +81,4 @@ int main(int argc, char** argv)
   sem_destroy(&full);
 
   return 0;
-}
\ No newline at end of file
+}
index 6b2da71..d493956 100644 (file)
@@ -178,8 +178,7 @@ void EngineImpl::initialize(int* argc, char** argv)
   simgrid::mc::AppSide::initialize();
 #endif
 
-  static bool inited = false;
-  if (not inited) {
+  if (static bool inited = false; not inited) {
     inited = true;
     xbt_log_init(argc, argv);
 
index ab1ea07..6862409 100644 (file)
@@ -58,6 +58,7 @@ class EngineImpl {
   friend s4u::Engine;
 
   std::vector<std::string> cmdline_; // Copy of the argv we got (including argv[0])
+
 public:
   EngineImpl() = default;
 
index 1e022aa..3e84903 100644 (file)
@@ -413,7 +413,7 @@ ExecPtr exec_async(double flops)
 
 aid_t get_pid()
 {
-  auto* self = simgrid::kernel::actor::ActorImpl::self();
+  const auto* self = simgrid::kernel::actor::ActorImpl::self();
   return self ? self->get_pid() : 0;
 }
 
@@ -429,7 +429,7 @@ std::string get_name()
 
 const char* get_cname()
 {
-  auto* self = simgrid::kernel::actor::ActorImpl::self();
+  const auto* self = simgrid::kernel::actor::ActorImpl::self();
   return self ? self->get_cname() : nullptr;
 }
 
index 2e2af7e..8076231 100644 (file)
@@ -152,7 +152,7 @@ int sthread_mutex_destroy(sthread_mutex_t* mutex)
   intrusive_ptr_release(static_cast<sg4::Mutex*>(mutex->mutex));
   return 0;
 }
-int sthread_sem_init(sthread_sem_t* sem, int pshared, unsigned int value)
+int sthread_sem_init(sthread_sem_t* sem, int /*pshared*/, unsigned int value)
 {
   auto s = sg4::Semaphore::create(value);
   intrusive_ptr_add_ref(s.get());
@@ -187,7 +187,7 @@ int sthread_sem_trywait(sthread_sem_t* sem)
 }
 int sthread_sem_timedwait(sthread_sem_t* sem, const struct timespec* abs_timeout)
 {
-  if (static_cast<sg4::Semaphore*>(sem->sem)->acquire_timeout(abs_timeout->tv_sec +
+  if (static_cast<sg4::Semaphore*>(sem->sem)->acquire_timeout(static_cast<double>(abs_timeout->tv_sec) +
                                                               static_cast<double>(abs_timeout->tv_nsec) / 1E9)) {
     errno = ETIMEDOUT;
     return -1;