Skip to content

Commit

Permalink
[Coverity] Fix coverity issues
Browse files Browse the repository at this point in the history
This PR resolves coverity issues of use of auto that causes a copy and missing lock.

**Self-evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test:   [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Donghyeon Jeong <dhyeon.jeong@samsung.com>
  • Loading branch information
djeong20 committed Mar 28, 2024
1 parent 7e7934e commit 4a480b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions api/capi/src/nntrainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static int ml_train_dataset_create(ml_train_dataset_h *dataset,
template <typename... Args>
static int ml_train_dataset_add_(ml_train_dataset_h dataset,
ml_train_dataset_mode_e mode,
ml::train::DatasetType type, Args &&... args) {
ml::train::DatasetType type, Args &&...args) {
check_feature_state();
std::shared_ptr<ml::train::Dataset> underlying_dataset;

Expand Down Expand Up @@ -412,7 +412,6 @@ int ml_train_model_destroy(ml_train_model_h model) {
ML_TRAIN_RESET_VALIDATED_HANDLE(x.second);
delete (x.second);
}
nnmodel->layers_map.clear();

delete nnmodel;

Expand Down Expand Up @@ -785,12 +784,12 @@ int ml_train_optimizer_destroy(ml_train_optimizer_h optimizer) {
{
ML_TRAIN_GET_VALID_OPT_LOCKED_RESET(nnopt, optimizer);
ML_TRAIN_ADOPT_LOCK(nnopt, optimizer_lock);
}

if (nnopt->in_use) {
ml_loge("Cannot delete optimizer already set to a model."
"Delete model will delete this optimizer.");
return ML_ERROR_INVALID_PARAMETER;
if (nnopt->in_use) {
ml_loge("Cannot delete optimizer already set to a model."
"Delete model will delete this optimizer.");
return ML_ERROR_INVALID_PARAMETER;
}
}

if (nnopt->lr_scheduler) {
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/utils/node_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void Exporter::saveTflResult(const std::tuple<props::TargetShape> &props,
createIfNull(tf_node);

tf_node->setOpType(tflite::BuiltinOperator_RESHAPE);
auto targetShape = std::get<props::TargetShape>(props).get();
const auto &targetShape = std::get<props::TargetShape>(props).get();
std::vector<int32_t> new_shape_vec = {
static_cast<int32_t>(targetShape.batch()),
static_cast<int32_t>(targetShape.height()),
Expand Down

0 comments on commit 4a480b8

Please sign in to comment.