Unverified Commit 79415315 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Klocwork issues. (#2847)

* Klocwork issues.

* Revert to dynamic_pointer_cast
parent 6562c902
...@@ -73,7 +73,7 @@ protected: ...@@ -73,7 +73,7 @@ protected:
private: private:
PassPropertyMask m_property; PassPropertyMask m_property;
ManagerState* m_state; ManagerState* m_state{0};
}; };
class ngraph::pass::ModulePass : public PassBase class ngraph::pass::ModulePass : public PassBase
......
...@@ -89,7 +89,7 @@ namespace ngraph ...@@ -89,7 +89,7 @@ namespace ngraph
std::mutex m_mutex; std::mutex m_mutex;
std::condition_variable m_cv; std::condition_variable m_cv;
size_t m_num_ctx_available = 0; volatile size_t m_num_ctx_available = 0;
size_t m_prev_ctx = 0; size_t m_prev_ctx = 0;
size_t m_num_ctx = 1; size_t m_num_ctx = 1;
std::unordered_map<size_t, bool> m_id_pool; std::unordered_map<size_t, bool> m_id_pool;
......
...@@ -1867,7 +1867,8 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_deconvolution_affine_foldi ...@@ -1867,7 +1867,8 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_deconvolution_affine_foldi
<< m.get_match_root()->get_name(); << m.get_match_root()->get_name();
auto pattern_map = m.get_pattern_map(); auto pattern_map = m.get_pattern_map();
auto m_bn = std::dynamic_pointer_cast<op::BatchNormInference>(m.get_match_root()); // Matcher guarantees this is the right type
auto m_bn = std::static_pointer_cast<op::BatchNormInference>(m.get_match_root());
auto conv_m = auto conv_m =
std::static_pointer_cast<op::ConvolutionBackpropData>(pattern_map[conv_label]); std::static_pointer_cast<op::ConvolutionBackpropData>(pattern_map[conv_label]);
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
// limitations under the License. // limitations under the License.
//***************************************************************************** //*****************************************************************************
#include <memory>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "ngraph/cpio.hpp" #include "ngraph/cpio.hpp"
...@@ -40,25 +42,25 @@ TEST(cpio, read) ...@@ -40,25 +42,25 @@ TEST(cpio, read)
{ {
int index = 0; int index = 0;
char* data = static_cast<char*>(malloc(file_info[index].get_size())); auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
reader.read(file_info[index].get_name(), data, file_info[index].get_size()); reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
string content = string(data, file_info[index].get_size()); string content = string(data.get(), file_info[index].get_size());
EXPECT_STREQ(content.c_str(), "12345"); EXPECT_STREQ(content.c_str(), "12345");
} }
{ {
int index = 1; int index = 1;
char* data = static_cast<char*>(malloc(file_info[index].get_size())); auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
reader.read(file_info[index].get_name(), data, file_info[index].get_size()); reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
string content = string(data, file_info[index].get_size()); string content = string(data.get(), file_info[index].get_size());
EXPECT_STREQ(content.c_str(), "this is a test"); EXPECT_STREQ(content.c_str(), "this is a test");
} }
{ {
int index = 2; int index = 2;
char* data = static_cast<char*>(malloc(file_info[index].get_size())); auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
reader.read(file_info[index].get_name(), data, file_info[index].get_size()); reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
string content = string(data, file_info[index].get_size()); string content = string(data.get(), file_info[index].get_size());
EXPECT_STREQ(content.c_str(), "the quick brown fox jumped over the lazy dog"); EXPECT_STREQ(content.c_str(), "the quick brown fox jumped over the lazy dog");
} }
} }
...@@ -90,17 +92,17 @@ TEST(cpio, write) ...@@ -90,17 +92,17 @@ TEST(cpio, write)
{ {
int index = 0; int index = 0;
char* data = static_cast<char*>(malloc(file_info[index].get_size())); auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
reader.read(file_info[index].get_name(), data, file_info[index].get_size()); reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
string content = string(data, file_info[index].get_size()); string content = string(data.get(), file_info[index].get_size());
EXPECT_STREQ(content.c_str(), s1.c_str()); EXPECT_STREQ(content.c_str(), s1.c_str());
} }
{ {
int index = 1; int index = 1;
char* data = static_cast<char*>(malloc(file_info[index].get_size())); auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
reader.read(file_info[index].get_name(), data, file_info[index].get_size()); reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
string content = string(data, file_info[index].get_size()); string content = string(data.get(), file_info[index].get_size());
EXPECT_STREQ(content.c_str(), s2.c_str()); EXPECT_STREQ(content.c_str(), s2.c_str());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment