Skip to content

Commit

Permalink
[coverity] fix coverity issue
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
EunjuYang committed Mar 21, 2024
1 parent 7fb71e2 commit e6e907f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
31 changes: 15 additions & 16 deletions nntrainer/dataset/iteration_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -107,6 +107,7 @@ ScopedView<Iteration> IterationQueue::requestFilledSlot() {
auto stop_request_state = FlowState::FLOW_STATE_STOP_REQUESTED;
bool exchange_result = flow_state.compare_exchange_strong(
stop_request_state, FlowState::FLOW_STATE_STOPPED);
std::scoped_lock lg(empty_mutex);
NNTR_THROW_IF(!exchange_result, std::runtime_error)
<< "the queue has either already stopped or running, but trying stopping "
"without requesting stop, queue size: "
Expand Down Expand Up @@ -168,9 +169,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),
Expand All @@ -183,8 +182,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;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/layers/layers_common_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class LayerSemantics
*
*/
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();
Expand Down

0 comments on commit e6e907f

Please sign in to comment.