Fix static analysis issues 15/299315/2
authorInkyun Kil <inkyun.kil@samsung.com>
Tue, 26 Sep 2023 01:08:38 +0000 (10:08 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Tue, 26 Sep 2023 01:30:30 +0000 (10:30 +0900)
Change-Id: Ib203e23a8be1d9ef9777ea434e5f83f818e272b4
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
ambient-viewer/src/util.cc
tests/unit_tests/src/test_ambient_viewer.cc
tests/unit_tests/src/test_watch_holder.cc

index 742ed529502aa4dffef0b1e0cf227337e03f31ca..e8b51a14303b4dd0ea79248e959ada43db0f36f4 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <dlog.h>
 #include <system_info.h>
 
 #include "util.hh"
@@ -38,7 +39,8 @@ float GetOpr(void* source_data, int width, int height) {
   float max_opr;
   bool shape_circle = false;
 
-  system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle);;
+  if (system_info_get_platform_bool(KEY_SCREEN_SHAPE_CIRCLE, &shape_circle))
+    LOGE("Failed to get system info");
 
   source = static_cast<int*>(source_data);
   pos = width / 2;
index 31a9286fbced2c166d742f1ee651cc919b1f1de9..61d2576620c8bff709a6755c3745a12ca59a68ce 100644 (file)
@@ -227,7 +227,7 @@ class Mocks : public ::testing::NiceMock<AulMock>,
 class AmbientViewerTest : public TestFixture {
  public:
   AmbientViewerTest() : TestFixture(std::make_unique<Mocks>()) {}
-  AmbientViewerStub* stub;
+  AmbientViewerStub* stub = nullptr;
 
   virtual void SetUp() {
     EXPECT_CALL(GetMock<VconfMock>(), vconf_get_str(_))
@@ -268,19 +268,19 @@ TEST_F(AmbientViewerTest, create) {
 TEST_F(AmbientViewerTest, NotifyAmbientEvent) {
   Bundle b;
   EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
-    AmbientViewer::DIRECTION_ALL, b), 0);
+    AmbientViewer::DIRECTION_ALL, std::move(b)), 0);
 }
 
 TEST_F(AmbientViewerTest, NotifyAmbientEvent2) {
   Bundle b;
   EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
-    AmbientViewer::DIRECTION_VIEWER_AND_WATCH, b), 0);
+    AmbientViewer::DIRECTION_VIEWER_AND_WATCH, std::move(b)), 0);
 }
 
 TEST_F(AmbientViewerTest, NotifyAmbientEvent3) {
   Bundle b;
   EXPECT_EQ(AmbientViewerTest::stub->NotifyAmbientEvent(AmbientViewer::AMBIENT_ENTER,
-    AmbientViewer::DIRECTION_VIEWER_AND_TOP_APP, b), 0);
+    AmbientViewer::DIRECTION_VIEWER_AND_TOP_APP, std::move(b)), 0);
 }
 
 TEST_F(AmbientViewerTest, BlockUpdate) {
index 58417979b32f8ba2d6e5cc8eb496a4dfb0e217da..3389d4581c9812c7f9088087878451d2d2bd16d4 100644 (file)
@@ -47,7 +47,7 @@ class WatchHolderStub : public WatchHolder {
   }
   void InvokeAmbientEvent(EventType ev, string sender,
       Bundle extra) {
-    OnAmbientEvent(ev, sender, extra);
+    OnAmbientEvent(ev, std::move(sender), std::move(extra));
   }
   void OnAdded(const WatchBase& watch) override {}
   void OnUpdated(const WatchBase& watch) override {}
@@ -58,12 +58,13 @@ class WatchHolderStub : public WatchHolder {
 
   std::shared_ptr<WatchBase> CreateWatch(int rid, std::string id,
       std::string appid, bool mock) override {
-    return WatchHolder::CreateWatch(rid, id, appid, true);
+    return WatchHolder::CreateWatch(rid, std::move(id), std::move(appid), true);
   }
 
   std::shared_ptr<WatchBase> CreateWatch(int rid, std::string id,
       std::string appid, tizen_base::Bundle extra, bool mock) override {
-    return WatchHolder::CreateWatch(rid, id, appid, extra, true);
+    return WatchHolder::CreateWatch(rid, std::move(id), std::move(appid),
+        std::move(extra), true);
   }
 };
 
@@ -118,7 +119,7 @@ class WatchHolderTest : public TestFixture {
  public:
   WatchHolderTest() : TestFixture(std::make_unique<Mocks>()) {}
   virtual ~WatchHolderTest() {}
-  WatchHolderStub* stub;
+  WatchHolderStub* stub = nullptr;
 
   virtual void SetUp() {
     EXPECT_CALL(GetMock<AulMock>(), aul_app_com_create(_, _, _, _, _))