[coverity] fix coverity issue
authorEunju Yang <ej.yang@samsung.com>
Thu, 21 Mar 2024 07:51:00 +0000 (16:51 +0900)
committerjijoong.moon <jijoong.moon@samsung.com>
Thu, 28 Mar 2024 23:45:13 +0000 (08:45 +0900)
- This commit fixes the coverity issues
- AUTO_CAUSES_COPY
- MSSING_LOCK

Self-evaluation:

1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Eunju Yang <ej.yang@samsung.com>
nntrainer/dataset/iteration_queue.cpp
test/unittest/layers/layers_common_tests.h

index b7ff26234a08100505fd6a9ea8d872e07d377a9d..b5fbc6c02a4776ce8bed659567877b16b3b3c7c4 100644 (file)
@@ -76,17 +76,17 @@ ScopedView<Sample> IterationQueue::requestEmptySlot() {
     current_iterator++;
   }
 
-  auto view =
-    ScopedView<Sample>(&(*current_iterator),
-                       [current_being_filed = this->being_filled] {
-                         current_being_filed->markSampleFilled();
-                       },
-                       [this, current_being_filled = this->being_filled] {
-                         std::unique_lock lg(empty_mutex);
-                         this->markEmpty(current_being_filled);
-                         num_being_filled--;
-                         notify_emptied_cv.notify_all();
-                       });
+  auto view = ScopedView<Sample>(
+    &(*current_iterator),
+    [current_being_filed = this->being_filled] {
+      current_being_filed->markSampleFilled();
+    },
+    [this, current_being_filled = this->being_filled] {
+      std::unique_lock lg(empty_mutex);
+      this->markEmpty(current_being_filled);
+      num_being_filled--;
+      notify_emptied_cv.notify_all();
+    });
   return view;
 }
 
@@ -111,7 +111,6 @@ ScopedView<Iteration> IterationQueue::requestFilledSlot() {
       << "the queue has either already stopped or running, but trying stopping "
          "without requesting stop, queue size: "
       << iterations.size() << " num currently empty: " << empty_q.size()
-      << " num being filled: " << num_being_filled
       << " filled_q.size(): " << filled_q.size();
 
     return ScopedView<Iteration>(nullptr);
@@ -168,9 +167,7 @@ void IterationQueue::markEmpty(MarkableIteration *iteration) {
 IterationQueue::MarkableIteration::MarkableIteration(
   const std::vector<ml::train::TensorDim> &input_dims,
   const std::vector<ml::train::TensorDim> &label_dims, IterationQueue *iq) :
-  num_observed(0),
-  iteration(input_dims, label_dims),
-  iq(iq) {}
+  num_observed(0), iteration(input_dims, label_dims), iq(iq) {}
 
 IterationQueue::MarkableIteration::MarkableIteration(MarkableIteration &&rhs) :
   num_observed(rhs.num_observed),
@@ -183,8 +180,8 @@ void IterationQueue::MarkableIteration::reset() {
   iteration.setEndSample();
 }
 
-IterationQueue::MarkableIteration &IterationQueue::MarkableIteration::
-operator=(MarkableIteration &&rhs) {
+IterationQueue::MarkableIteration &
+IterationQueue::MarkableIteration::operator=(MarkableIteration &&rhs) {
   if (this == &rhs) {
     return *this;
   }
index 19e62cdf7c3d472f8ce2b5f10ae022e20daac1ed..57f693c0a2ca9f8ec94ad973429b67922b0d5059 100644 (file)
@@ -61,7 +61,7 @@ public:
    *
    */
   virtual void SetUp() {
-    auto f = std::get<0>(GetParam());
+    auto &f = std::get<0>(GetParam());
     layer = std::move(f({}));
     std::tie(std::ignore, expected_type, valid_properties, options, must_fail,
              num_inputs) = GetParam();