Fix static analysis issues 71/240971/3
authorSangyoon Jang <jeremy.jang@samsung.com>
Thu, 13 Aug 2020 08:33:25 +0000 (17:33 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 14 Aug 2020 07:27:52 +0000 (07:27 +0000)
Change-Id: I54da333cc4fcf38b94e39dfb3dace49890a24076
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
test/unit_tests/test_request_broker.cc
test/unit_tests/test_request_handlers.cc
test/unit_tests/test_theme.cc
test/unit_tests/test_theme_info_proxy.cc
test/unit_tests/test_theme_loader.cc

index dc33ee6..5e58780 100644 (file)
@@ -129,7 +129,7 @@ TEST_F(RequestBrokerTest, Listen) {
   info->ref_count = 10;
   info->path = NULL;
   info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
-      malloc(sizeof(GDBusInterfaceInfo)));
+      malloc(sizeof(GDBusInterfaceInfo*)));
   info->nodes = NULL;
   info->annotations = NULL;
   EXPECT_CALL(GetMock<GioMock>(),
@@ -156,7 +156,7 @@ TEST_F(RequestBrokerTest, Listen_N2) {
   info->ref_count = 10;
   info->path = NULL;
   info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
-      malloc(sizeof(GDBusInterfaceInfo)));
+      malloc(sizeof(GDBusInterfaceInfo*)));
   info->nodes = NULL;
   info->annotations = NULL;
   EXPECT_CALL(GetMock<GioMock>(),
@@ -173,7 +173,7 @@ TEST_F(RequestBrokerTest, Listen_N3) {
   info->ref_count = 10;
   info->path = NULL;
   info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
-      malloc(sizeof(GDBusInterfaceInfo)));
+      malloc(sizeof(GDBusInterfaceInfo*)));
   info->nodes = NULL;
   info->annotations = NULL;
   EXPECT_CALL(GetMock<GioMock>(),
index 78871cb..49e50f2 100644 (file)
@@ -106,7 +106,8 @@ class RequestHandlersTest : public TestFixture {
   }
 
   virtual void TearDown() {
-    std::remove(kTestDb);
+    if (std::remove(kTestDb))
+      std::cerr << "Removing test db failed" << std::endl;
   }
 
   std::shared_ptr<ThemeInfoProxy> proxy_;
index 7139e96..b027cdd 100644 (file)
@@ -481,4 +481,5 @@ TEST_F(ThemeTest, Theme_GetPathArray) {
   for (int i = 0; i < count; i++)
     if (strarr[i])
       free(strarr[i]);
-}
\ No newline at end of file
+  free(strarr);
+}
index 671a85d..cb6173d 100644 (file)
@@ -61,7 +61,8 @@ class ThemeInfoProxyTest : public testing::Test {
   }
 
   virtual void TearDown() {
-    std::remove(kTestDb);
+    if (std::remove(kTestDb))
+      std::cerr << "Removing test db failed" << std::endl;
   }
 
   tizen_base::Bundle b_;
index afe8ead..bc494ff 100644 (file)
@@ -219,7 +219,7 @@ TEST_F(ThemeLoaderTest, QueryID) {
       g_dbus_message_get_message_type(_)).
           WillOnce(Return(G_DBUS_MESSAGE_TYPE_METHOD_RETURN));
   tizen_base::Bundle b;
-  std::vector<std::string> ids_vec;
+  std::vector<std::string> ids_vec = { "testid1", "testid2" };
   b.Add(ttm::dbus::kCmdResultKey, "ok");
   b.Add(ttm::dbus::kCmdDataKey, ids_vec);
   auto br = b.ToRaw();
@@ -234,7 +234,10 @@ TEST_F(ThemeLoaderTest, QueryID) {
 
   ret = theme_loader_query_id(loader_handle_, &ids, &count);
   EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
-  EXPECT_EQ(count, 0);
+  EXPECT_EQ(count, 2);
+  for (int i = 0; i < count; i++)
+    free(ids[i]);
+  free(ids);
 }
 
 TEST_F(ThemeLoaderTest, QueryID_N) {
@@ -278,7 +281,7 @@ TEST_F(ThemeLoaderTest, RemoveEvent_N) {
 TEST_F(ThemeLoaderTest, Destroy) {
   theme_loader_h handle;
   int ret = theme_loader_create(&handle);
-  ASSERT_EQ(ret, THEME_MANAGER_ERROR_NONE);
+  EXPECT_EQ(ret, THEME_MANAGER_ERROR_NONE);
   ASSERT_NE(handle, nullptr);
 
   ret = theme_loader_destroy(handle);