Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 7941531

Browse files
authored
Klocwork issues. (#2847)
* Klocwork issues. * Revert to dynamic_pointer_cast
1 parent 6562c90 commit 7941531

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

src/ngraph/pass/pass.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ngraph::pass::PassBase
7373

7474
private:
7575
PassPropertyMask m_property;
76-
ManagerState* m_state;
76+
ManagerState* m_state{0};
7777
};
7878

7979
class ngraph::pass::ModulePass : public PassBase

src/ngraph/runtime/cpu/cpu_call_frame.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace ngraph
8989

9090
std::mutex m_mutex;
9191
std::condition_variable m_cv;
92-
size_t m_num_ctx_available = 0;
92+
volatile size_t m_num_ctx_available = 0;
9393
size_t m_prev_ctx = 0;
9494
size_t m_num_ctx = 1;
9595
std::unordered_map<size_t, bool> m_id_pool;

src/ngraph/runtime/cpu/pass/cpu_fusion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,8 @@ void ngraph::runtime::cpu::pass::CPUFusion::construct_deconvolution_affine_foldi
18671867
<< m.get_match_root()->get_name();
18681868
auto pattern_map = m.get_pattern_map();
18691869

1870-
auto m_bn = std::dynamic_pointer_cast<op::BatchNormInference>(m.get_match_root());
1870+
// Matcher guarantees this is the right type
1871+
auto m_bn = std::static_pointer_cast<op::BatchNormInference>(m.get_match_root());
18711872
auto conv_m =
18721873
std::static_pointer_cast<op::ConvolutionBackpropData>(pattern_map[conv_label]);
18731874

test/cpio.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// limitations under the License.
1515
//*****************************************************************************
1616

17+
#include <memory>
18+
1719
#include <gtest/gtest.h>
1820

1921
#include "ngraph/cpio.hpp"
@@ -40,25 +42,25 @@ TEST(cpio, read)
4042

4143
{
4244
int index = 0;
43-
char* data = static_cast<char*>(malloc(file_info[index].get_size()));
44-
reader.read(file_info[index].get_name(), data, file_info[index].get_size());
45-
string content = string(data, file_info[index].get_size());
45+
auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
46+
reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
47+
string content = string(data.get(), file_info[index].get_size());
4648
EXPECT_STREQ(content.c_str(), "12345");
4749
}
4850

4951
{
5052
int index = 1;
51-
char* data = static_cast<char*>(malloc(file_info[index].get_size()));
52-
reader.read(file_info[index].get_name(), data, file_info[index].get_size());
53-
string content = string(data, file_info[index].get_size());
53+
auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
54+
reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
55+
string content = string(data.get(), file_info[index].get_size());
5456
EXPECT_STREQ(content.c_str(), "this is a test");
5557
}
5658

5759
{
5860
int index = 2;
59-
char* data = static_cast<char*>(malloc(file_info[index].get_size()));
60-
reader.read(file_info[index].get_name(), data, file_info[index].get_size());
61-
string content = string(data, file_info[index].get_size());
61+
auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
62+
reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
63+
string content = string(data.get(), file_info[index].get_size());
6264
EXPECT_STREQ(content.c_str(), "the quick brown fox jumped over the lazy dog");
6365
}
6466
}
@@ -90,17 +92,17 @@ TEST(cpio, write)
9092

9193
{
9294
int index = 0;
93-
char* data = static_cast<char*>(malloc(file_info[index].get_size()));
94-
reader.read(file_info[index].get_name(), data, file_info[index].get_size());
95-
string content = string(data, file_info[index].get_size());
95+
auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
96+
reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
97+
string content = string(data.get(), file_info[index].get_size());
9698
EXPECT_STREQ(content.c_str(), s1.c_str());
9799
}
98100

99101
{
100102
int index = 1;
101-
char* data = static_cast<char*>(malloc(file_info[index].get_size()));
102-
reader.read(file_info[index].get_name(), data, file_info[index].get_size());
103-
string content = string(data, file_info[index].get_size());
103+
auto data = unique_ptr<char>(new char[file_info[index].get_size()]);
104+
reader.read(file_info[index].get_name(), data.get(), file_info[index].get_size());
105+
string content = string(data.get(), file_info[index].get_size());
104106
EXPECT_STREQ(content.c_str(), s2.c_str());
105107
}
106108
}

0 commit comments

Comments
 (0)