Fixed defects detected by static analysis tool 40/141640/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Tue, 1 Aug 2017 07:53:12 +0000 (16:53 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Tue, 1 Aug 2017 07:53:12 +0000 (16:53 +0900)
Change-Id: Ib54848a266730facd3859023b45108665c0f1b18

scl/gwes/efl/sclevents-efl.cpp
scl/sclcontext.cpp
scl/scluibuilder.cpp

index 0c0beeb..42e859c 100644 (file)
@@ -209,6 +209,10 @@ static void gesture_cb(void *data, const Eldbus_Message *msg)
             window_context->geometry.width, window_context->geometry.height);
 
     Gesture_Info *info = (Gesture_Info *)calloc(sizeof(Gesture_Info), 1);
+    if (!info) {
+        LOGD("Memory alloc failed for Gesture_Info");
+        return;
+    }
     if (!eldbus_message_arguments_get(msg, "iii", &g_type, &info->x,
                                       &info->y)) {
         LOGD("Getting message arguments failed");
index 7ba84c8..d488b17 100644 (file)
@@ -561,7 +561,7 @@ CSCLContext::get_multi_touch_event(sclint order, SclUIEventDesc *desc)
 
                     if (coordinate) {
                         SCLShiftState shift_index = get_shift_state();
-                        if (shift_index < 0 || shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
+                        if (shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
                         desc->key_event = coordinate->key_event[shift_index][0];
                         desc->key_value = coordinate->key_value[shift_index][0];
                         desc->key_type = coordinate->key_type;
@@ -665,7 +665,7 @@ CSCLContext::get_custom_magnifier_label(scltouchdevice touch_id, sclint index)
 SCLShiftState CSCLContext::get_shift_state() const
 {
     SCLShiftState ret = SCL_SHIFT_STATE_OFF;
-    if (m_shift_state >= 0 && m_shift_state < SCL_SHIFT_STATE_MAX) {
+    if (m_shift_state < SCL_SHIFT_STATE_MAX) {
         ret = m_shift_state;
     }
     return ret;
@@ -673,7 +673,7 @@ SCLShiftState CSCLContext::get_shift_state() const
 
 void CSCLContext::set_shift_state(SCLShiftState val)
 {
-    if (val >= 0 && val < SCL_SHIFT_STATE_MAX) {
+    if (val < SCL_SHIFT_STATE_MAX) {
         m_shift_state = val;
         if (val == SCL_SHIFT_STATE_OFF) {
             m_shift_multi_touch_state = SCL_SHIFT_MULTITOUCH_OFF;
@@ -698,7 +698,7 @@ void CSCLContext::set_caps_lock_mode(sclboolean val)
 SCLShiftMultitouchState CSCLContext::get_shift_multi_touch_state() const
 {
     SCLShiftMultitouchState ret = SCL_SHIFT_MULTITOUCH_OFF;
-    if (m_shift_multi_touch_state >= 0 && m_shift_multi_touch_state < SCL_SHIFT_MULTITOUCH_MAX) {
+    if (m_shift_multi_touch_state < SCL_SHIFT_MULTITOUCH_MAX) {
         ret = m_shift_multi_touch_state;
     }
     return ret;
@@ -706,7 +706,7 @@ SCLShiftMultitouchState CSCLContext::get_shift_multi_touch_state() const
 
 void CSCLContext::set_shift_multi_touch_state(SCLShiftMultitouchState val)
 {
-    if (val >= 0 && val < SCL_SHIFT_MULTITOUCH_MAX) {
+    if (val < SCL_SHIFT_MULTITOUCH_MAX) {
         m_shift_multi_touch_state = val;
     }
 }
index e859241..daa6367 100644 (file)
@@ -398,7 +398,7 @@ CSCLUIBuilder::draw_button(const sclwindow window, scldrawctx draw_ctx, const sc
             /* FIXME : There is a case that begin_pain fails. Inspection on the root cause is needed */
             if (draw_ctx) {
                 SCLShiftState shift_index = context->get_shift_state();
-                if (shift_index < 0 || shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
+                if (shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
 
                 const SclLayout* layout = cache->get_cur_layout(window);
                 const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
@@ -1008,7 +1008,7 @@ CSCLUIBuilder::show_magnifier(const sclwindow window, scldrawctx draw_ctx)
     SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(pressed_window, pressed_key);
     SclButtonContext* button_context = cache->get_cur_button_context(pressed_window, pressed_key);
     SCLShiftState shift_index = context->get_shift_state();
-    if (shift_index < 0 || shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
+    if (shift_index >= SCL_SHIFT_STATE_MAX) shift_index = SCL_SHIFT_STATE_OFF;
     if (context->get_caps_lock_mode()) {
         shift_index = (shift_index == SCL_SHIFT_STATE_OFF) ? SCL_SHIFT_STATE_ON : SCL_SHIFT_STATE_OFF;
     }