summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksei Grebenkin/AI Ecosystem Lab /SRR/Engineer/삼성전자 <a.grebenkin@samsung.com>2019-04-17 04:01:58 (GMT)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>2019-04-17 04:01:58 (GMT)
commitb3be82384c100a735e7a4231fe899ba663c8edd9 (patch)
tree1f9fa003cc0e0bc2428098fd8c859e6ace45c6d1
parent384c54ff4ac44933dfacce6e1839b7d9c7f2f673 (diff)
downloadnnfw-b3be82384c100a735e7a4231fe899ba663c8edd9.zip
nnfw-b3be82384c100a735e7a4231fe899ba663c8edd9.tar.gz
nnfw-b3be82384c100a735e7a4231fe899ba663c8edd9.tar.bz2
Fix a couple of noticeable clang static analyzer warnings (#4981)
* Fix a couple of noticeable clang static analyzer warnings Fixed passing vector by value, lack of default switch case, dead code Signed-off-by: Alexey Grebenkin <a.grebenkin@samsung.com> * Correcting for PR comments * Correcting for more PR comments
-rw-r--r--libs/cker/include/cker/Shape.h2
-rw-r--r--runtimes/neurun/backend/cpu/kernel/PermuteLayer.cc3
-rw-r--r--runtimes/neurun/frontend/nnapi/memory.cc7
3 files changed, 6 insertions, 6 deletions
diff --git a/libs/cker/include/cker/Shape.h b/libs/cker/include/cker/Shape.h
index 7390864..10f40f0 100644
--- a/libs/cker/include/cker/Shape.h
+++ b/libs/cker/include/cker/Shape.h
@@ -213,7 +213,7 @@ inline int MatchingDim(const Shape &shape1, int index1, const Shape &shape2, int
return shape1.Dims(index1);
}
-inline Shape GetShape(std::vector<int32_t> data) { return Shape(data.size(), data.data()); }
+inline Shape GetShape(const std::vector<int32_t> &data) { return Shape(data.size(), data.data()); }
inline int Offset(const Shape &shape, int i0, int i1, int i2, int i3)
{
diff --git a/runtimes/neurun/backend/cpu/kernel/PermuteLayer.cc b/runtimes/neurun/backend/cpu/kernel/PermuteLayer.cc
index 897c716..5674a5a 100644
--- a/runtimes/neurun/backend/cpu/kernel/PermuteLayer.cc
+++ b/runtimes/neurun/backend/cpu/kernel/PermuteLayer.cc
@@ -193,6 +193,9 @@ void PermuteLayer::run()
// If two different backends using same tensor layout, we need this.
throw "NYI";
break;
+ default:
+ throw "NYI";
+ break;
}
}
diff --git a/runtimes/neurun/frontend/nnapi/memory.cc b/runtimes/neurun/frontend/nnapi/memory.cc
index e28d1df..2afd5b5 100644
--- a/runtimes/neurun/frontend/nnapi/memory.cc
+++ b/runtimes/neurun/frontend/nnapi/memory.cc
@@ -30,14 +30,11 @@ int ANeuralNetworksMemory_createFromFd(size_t size, int protect, int fd, size_t
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- // Use unique pointer to avoid memory leak
- std::unique_ptr<ANeuralNetworksMemory> memory_ptr =
- nnfw::cpp14::make_unique<ANeuralNetworksMemory>(size, protect, fd, offset);
- if (memory_ptr == nullptr)
+ *memory = new (std::nothrow) ANeuralNetworksMemory{size, protect, fd, offset};
+ if (*memory == nullptr)
{
return ANEURALNETWORKS_OUT_OF_MEMORY;
}
- *memory = memory_ptr.release();
return ANEURALNETWORKS_NO_ERROR;
}