Skip to content

Commit

Permalink
[coverity] fix coverity issues
Browse files Browse the repository at this point in the history
 - Added const auto & to avoid copy of an object
 - Added missing lock

Signed-off-by: hyeonseok lee <hs89.lee@samsung.com>
  • Loading branch information
lhs8928 committed Mar 26, 2024
1 parent c625cdc commit f924faa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions nntrainer/dataset/iteration_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ IterationQueue::MarkableIteration::MarkableIteration(
iq(iq) {}

IterationQueue::MarkableIteration::MarkableIteration(MarkableIteration &&rhs) :
num_observed(rhs.num_observed),
iteration(std::move(rhs.iteration)),
iq(rhs.iq) {}
iq(rhs.iq) {
std::lock_guard notify_lock_guard(notify_mutex);
num_observed = rhs.num_observed;
}

void IterationQueue::MarkableIteration::reset() {
std::lock_guard notify_lock_guard(notify_mutex);
Expand Down
7 changes: 5 additions & 2 deletions test/unittest/models/models_test_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ class IterationForGolden {
auto to_tensors = [](sharedConstTensors &sts) {
std::vector<Tensor> ts;
ts.reserve(sts.size());
std::transform(sts.begin(), sts.end(), std::back_inserter(ts),
[](const auto &ts) { return *ts; });
std::transform(
sts.begin(), sts.end(),
std::back_inserter(ts), [](const auto &ts) -> const auto & {
return *ts;
});
return ts;
};

Expand Down

0 comments on commit f924faa

Please sign in to comment.