Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Unsigned cannot be < 0.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 17 Jan 2023 16:07:10 +0000 (17:07 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 24 Jan 2023 13:02:22 +0000 (14:02 +0100)
src/kernel/activity/SemaphoreImpl.cpp
src/kernel/routing/ClusterZone.cpp

index 3d67f8b..5e8016c 100644 (file)
@@ -87,12 +87,12 @@ SemAcquisitionImplPtr SemaphoreImpl::acquire_async(actor::ActorImpl* issuer)
 {
   auto res = SemAcquisitionImplPtr(new kernel::activity::SemAcquisitionImpl(issuer, this), true);
 
-  if (value_ <= 0) {
-    /* No free token in the semaphore; register the acquisition */
-    ongoing_acquisitions_.push_back(res);
-  } else {
+  if (value_ > 0) {
     value_--;
     res->granted_ = true;
+  } else {
+    /* No free token in the semaphore; register the acquisition */
+    ongoing_acquisitions_.push_back(res);
   }
   return res;
 }
index 0ac2f80..cce4063 100644 (file)
@@ -69,10 +69,7 @@ void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<un
   // auxiliary function to get dims from index
   auto index_to_dims = [&dimensions](unsigned long index) {
     std::vector<unsigned long> dims_array(dimensions.size());
-    for (auto i = static_cast<int>(dimensions.size() - 1); i >= 0; --i) {
-      if (index <= 0) {
-        break;
-      }
+    for (auto i = static_cast<int>(dimensions.size() - 1); i >= 0 && index > 0; --i) {
       unsigned long value = index % dimensions[i];
       dims_array[i]      = value;
       index              = (index / dimensions[i]);