Fixing static analysis failures 57/271457/1
authorDavid Steele <david.steele@samsung.com>
Mon, 21 Feb 2022 12:29:24 +0000 (12:29 +0000)
committerDavid Steele <david.steele@samsung.com>
Mon, 21 Feb 2022 12:29:24 +0000 (12:29 +0000)
Change-Id: I8239a1648da1c1b91dc366af8f1bb178e3f25bd7

dali/devel-api/adaptor-framework/drag-and-drop.h
dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp
dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.cpp
dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.h

index 076167a..32f4d89 100644 (file)
  */
 
 // EXTERNAL INCLUDES
-#include <functional>
+#include <dali/public-api/actors/actor.h>
 #include <dali/public-api/math/rect.h>
 #include <dali/public-api/object/base-handle.h>
-#include <dali/public-api/actors/actor.h>
+#include <functional>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/dali-adaptor-common.h>
@@ -53,8 +53,8 @@ public:
   {
     ENTER, ///< The drag object has entered the target object.
     LEAVE, ///< The drag object has left the target object.
-    MOVE, ///< The drag object moves in the target object.
-    DROP  ///< The drag object dropped in the target object.
+    MOVE,  ///< The drag object moves in the target object.
+    DROP   ///< The drag object dropped in the target object.
   };
 
   /**
@@ -62,28 +62,49 @@ public:
    */
   struct DragEvent
   {
-    DragEvent() { this->data = nullptr; }
+    DragEvent()
+    {
+      this->data = nullptr;
+    }
     DragEvent(DragType type, Dali::Vector2 position, char* data = nullptr)
     {
+      this->type     = type;
+      this->position = position;
+      this->data     = data;
+    }
+
+    void SetAction(DragType type)
+    {
       this->type = type;
+    }
+    DragType GetAction()
+    {
+      return type;
+    }
+    void SetPosition(Dali::Vector2 position)
+    {
       this->position = position;
+    }
+    Dali::Vector2 GetPosition()
+    {
+      return position;
+    }
+    void SetData(char* data)
+    {
       this->data = data;
     }
-
-    void SetAction(DragType type) { this->type = type; }
-    DragType GetAction() { return type; }
-    void SetPosition(Dali::Vector2 position) { this->position = position; }
-    Dali::Vector2 GetPosition() { return position; }
-    void SetData(char* data) { this->data = data; }
-    char* GetData() { return data; }
+    char* GetData()
+    {
+      return data;
+    }
 
   private:
-    DragType type; ///< The drag event type.
-    Dali::Vector2 position; ///< The position of drag object.
-    char* data; ///< The data of drag object.
+    DragType      type{DragType::DROP}; ///< The drag event type.
+    Dali::Vector2 position;             ///< The position of drag object.
+    char*         data{nullptr};        ///< The data of drag object.
   };
 
-  using DragAndDropFunction      = std::function<void(const DragEvent&)>;
+  using DragAndDropFunction = std::function<void(const DragEvent&)>;
 
   /**
    * @brief Create an uninitialized DragAndDrop.
index 3865ac6..e1ddf17 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -115,9 +115,9 @@ struct Clipboard::Impl
 
 #ifdef ECORE_WAYLAND2
     Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(ecore_wl2_connected_display_get(NULL));
-    mSerial = ecore_wl2_dnd_selection_set(input, types);
+    mSerial                = ecore_wl2_dnd_selection_set(input, types);
 #else
-    mSerial = ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
+    mSerial               = ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
 #endif
   }
 
@@ -272,7 +272,7 @@ struct Clipboard::Impl
   std::string mSendBuffer;
   bool        mVisible;
   bool        mIsFirstTimeHidden;
-  uint32_t    mSerial;
+  uint32_t    mSerial{0u};
 };
 
 Clipboard::Clipboard(Impl* impl)
index f9ffead..7d7166a 100644 (file)
@@ -19,9 +19,9 @@
 #include <dali/internal/drag-and-drop/tizen-wayland/drag-and-drop-impl-ecore-wl2.h>
 
 // EXTERNAL INCLUDES
-#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
 #include <dali/devel-api/common/singleton-service.h>
 #include <dali/integration-api/debug.h>
+#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
 #include <unistd.h>
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -34,7 +34,6 @@ namespace Internal
 {
 namespace Adaptor
 {
-
 static bool IsIntersection(int px, int py, int tx, int ty, int tw, int th)
 {
   if(px > tx && py > ty && px < (tx + tw) && py < (ty + th))
@@ -76,7 +75,6 @@ static Eina_Bool EcoreEventDataDrop(void* data, int type, void* event)
   return ECORE_CALLBACK_PASS_ON;
 }
 
-
 Dali::DragAndDrop GetDragAndDrop()
 {
   Dali::DragAndDrop dnd;
@@ -94,7 +92,7 @@ Dali::DragAndDrop GetDragAndDrop()
     else
     {
       // Create a singleon instance
-      DragAndDropEcoreWl *dndImpl = new DragAndDropEcoreWl();
+      DragAndDropEcoreWldndImpl = new DragAndDropEcoreWl();
 
       dnd = Dali::DragAndDrop(dndImpl);
       service.Register(typeid(Dali::DragAndDrop), dnd);
@@ -106,10 +104,10 @@ Dali::DragAndDrop GetDragAndDrop()
 
 DragAndDropEcoreWl::DragAndDropEcoreWl()
 {
-  mSendHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this);
+  mSendHandler    = ecore_event_handler_add(ECORE_WL2_EVENT_DATA_SOURCE_SEND, EcoreEventDataSend, this);
   mReceiveHandler = ecore_event_handler_add(ECORE_WL2_EVENT_OFFER_DATA_READY, EcoreEventOfferDataReady, this);
-  mMotionHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION, EcoreEventDataMotion, this);
-  mDropHandler = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP, EcoreEventDataDrop, this);
+  mMotionHandler  = ecore_event_handler_add(ECORE_WL2_EVENT_DND_MOTION, EcoreEventDataMotion, this);
+  mDropHandler    = ecore_event_handler_add(ECORE_WL2_EVENT_DND_DROP, EcoreEventDataDrop, this);
 }
 
 DragAndDropEcoreWl::~DragAndDropEcoreWl()
@@ -146,14 +144,14 @@ bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Actor shadow
   mDragWindow.Add(shadow);
 
   // Start Drag and Drop
-  Ecore_Wl2_Window* parentWindow = AnyCast<Ecore_Wl2_Window*>(parent.GetNativeHandle());
-  Ecore_Wl2_Window* dragWindow = AnyCast<Ecore_Wl2_Window*>(mDragWindow.GetNativeHandle());
-  Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
-  Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+  Ecore_Wl2_Window*  parentWindow = AnyCast<Ecore_Wl2_Window*>(parent.GetNativeHandle());
+  Ecore_Wl2_Window*  dragWindow   = AnyCast<Ecore_Wl2_Window*>(mDragWindow.GetNativeHandle());
+  Ecore_Wl2_Display* display      = ecore_wl2_connected_display_get(NULL);
+  Ecore_Wl2_Input*   input        = ecore_wl2_input_default_input_get(display);
 
   // TODO: Makes mime-type common
-  char *mimeTypes[2] = {"text/plain"};
-  mimeTypes[1] = NULL;
+  charmimeTypes[2] = {"text/plain"};
+  mimeTypes[1]       = NULL;
 
   // Set mimetype
   ecore_wl2_dnd_drag_types_set(input, (const char**)mimeTypes);
@@ -167,9 +165,9 @@ bool DragAndDropEcoreWl::StartDragAndDrop(Dali::Actor source, Dali::Actor shadow
 bool DragAndDropEcoreWl::AddListener(Dali::Actor target, Dali::DragAndDrop::DragAndDropFunction callback)
 {
   DropTarget targetData;
-  targetData.target = target;
+  targetData.target   = target;
   targetData.callback = callback;
-  targetData.inside = false;
+  targetData.inside   = false;
 
   mDropTargets.push_back(targetData);
 
@@ -184,13 +182,13 @@ void DragAndDropEcoreWl::SendData(void* event)
     return;
   }
 
-  int len = strlen(mData.c_str());
-  char *buf = new char[len + 1];
+  int   len = strlen(mData.c_str());
+  charbuf = new char[len + 1];
   strncpy(buf, mData.c_str(), len);
   buf[len] = '\0';
 
   // Write source object data to target object
-  write(ev->fd, buf, len+1);
+  write(ev->fd, buf, len + 1);
   close(ev->fd);
 
   if(mDragWindow)
@@ -200,7 +198,7 @@ void DragAndDropEcoreWl::SendData(void* event)
 
   if(buf)
   {
-    free(buf);
+    delete[] buf;
   }
 }
 
@@ -219,16 +217,16 @@ void DragAndDropEcoreWl::ReceiveData(void* event)
 
 bool DragAndDropEcoreWl::CalculateDragEvent(void* event)
 {
-  Ecore_Wl2_Event_Dnd_Motion *ev = reinterpret_cast<Ecore_Wl2_Event_Dnd_Motion*>(event);
+  Ecore_Wl2_Event_Dnd_Motionev = reinterpret_cast<Ecore_Wl2_Event_Dnd_Motion*>(event);
 
   Dali::DragAndDrop::DragEvent dragEvent;
-  Dali::Vector2 curPosition(ev->x, ev->y);
+  Dali::Vector2                curPosition(ev->x, ev->y);
 
   for(int i = 0; i < mDropTargets.size(); i++)
   {
-    Vector2 position = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::POSITION);
-    Vector2 size = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::SIZE);
-    bool currentInside = IsIntersection(ev->x, ev->y, position.x, position.y, size.width, size.height);
+    Vector2 position      = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::POSITION);
+    Vector2 size          = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::SIZE);
+    bool    currentInside = IsIntersection(ev->x, ev->y, position.x, position.y, size.width, size.height);
 
     // Calculate Drag Enter, Leave, Move Event
     if(currentInside && !mDropTargets[i].inside)
@@ -261,7 +259,7 @@ bool DragAndDropEcoreWl::CalculateDragEvent(void* event)
 
 bool DragAndDropEcoreWl::CalculateViewRegion(void* event)
 {
-  Ecore_Wl2_Event_Dnd_Drop *ev = reinterpret_cast<Ecore_Wl2_Event_Dnd_Drop*>(event);
+  Ecore_Wl2_Event_Dnd_Dropev = reinterpret_cast<Ecore_Wl2_Event_Dnd_Drop*>(event);
 
   // Check the target object region
   mTargetIndex = -1;
@@ -269,22 +267,22 @@ bool DragAndDropEcoreWl::CalculateViewRegion(void* event)
   for(int i = 0; i < mDropTargets.size(); i++)
   {
     Vector2 position = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::POSITION);
-    Vector2 size = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::SIZE);
+    Vector2 size     = mDropTargets[i].target.GetProperty<Vector2>(Dali::Actor::Property::SIZE);
     // If the drop position is in the target object region, request drop data to the source object
     if(IsIntersection(ev->x, ev->y, position.x, position.y, size.width, size.height))
     {
-      mTargetIndex = i;
-      mPosition = position;
+      mTargetIndex        = i;
+      mPosition           = position;
       Dali::Window window = Dali::DevelWindow::Get(mDropTargets[i].target);
 
-      char *mimetype = (char*)eina_array_data_get(ecore_wl2_offer_mimes_get(ev->offer), 0);
+      charmimetype = (char*)eina_array_data_get(ecore_wl2_offer_mimes_get(ev->offer), 0);
       if(mimetype)
       {
-         ecore_wl2_offer_accept(ev->offer, mimetype);
-         ecore_wl2_offer_receive(ev->offer, mimetype);
-         Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
-         Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
-         ecore_wl2_display_flush(ecore_wl2_input_display_get(input));
+        ecore_wl2_offer_accept(ev->offer, mimetype);
+        ecore_wl2_offer_receive(ev->offer, mimetype);
+        Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+        Ecore_Wl2_Input*   input   = ecore_wl2_input_default_input_get(display);
+        ecore_wl2_display_flush(ecore_wl2_input_display_get(input));
       }
       return true;
     }
index 9f1ecb6..5cd056b 100644 (file)
@@ -30,12 +30,11 @@ namespace Internal
 {
 namespace Adaptor
 {
-
 struct DropTarget
 {
-  Dali::Actor target;
+  Dali::Actor                            target;
   Dali::DragAndDrop::DragAndDropFunction callback;
-  bool inside;
+  bool                                   inside;
 };
 
 /**
@@ -92,22 +91,20 @@ public:
 private:
   DragAndDropEcoreWl(const DragAndDropEcoreWl&) = delete;
   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&) = delete;
-  DragAndDropEcoreWl(DragAndDropEcoreWl&&) = delete;
+  DragAndDropEcoreWl(DragAndDropEcoreWl&&)           = delete;
   DragAndDropEcoreWl& operator=(DragAndDropEcoreWl&&) = delete;
 
 private:
-  Dali::Window mDragWindow;
-  uint32_t mSerial;
-  Ecore_Event_Handler* mSendHandler;
-  Ecore_Event_Handler* mReceiveHandler;
-  Ecore_Event_Handler* mMotionHandler;
-  Ecore_Event_Handler* mDropHandler;
-  int mTargetIndex;
-  Dali::Vector2 mPosition;
-  std::string mData;
+  Dali::Window            mDragWindow;
+  uint32_t                mSerial{0u};
+  Ecore_Event_Handler*    mSendHandler{nullptr};
+  Ecore_Event_Handler*    mReceiveHandler{nullptr};
+  Ecore_Event_Handler*    mMotionHandler{nullptr};
+  Ecore_Event_Handler*    mDropHandler{nullptr};
+  int                     mTargetIndex{0};
+  Dali::Vector2           mPosition;
+  std::string             mData;
   std::vector<DropTarget> mDropTargets;
-
-public:
 }; // class DragAndDropEcoreWl
 
 } // namespace Adaptor