[PATCH 2/4] Resolve Coverity Issue. 34/174434/3
authorNilesh Trimbake <t.shripati@samsung.com>
Tue, 27 Mar 2018 12:48:59 +0000 (18:18 +0530)
committerNilesh Trimbake <t.shripati@samsung.com>
Mon, 2 Apr 2018 10:53:42 +0000 (16:23 +0530)
This patch resolve following issues:
108564 106287 109510 108808 107493 107155
110526 108971 107768 107336 106169 106068

Change-Id: I4f27f2f5e97b92def88ebb91bc30b268a635d667

src/edit.c
src/layout.c
src/moments/moments_control_view.c
src/notification/noti_detail_view.c
src/notification/noti_panel_stack_view.c
src/notification/noti_popup_full_view.c
src/notification/noti_popup_small_view.c

index 8853e02b51e5b2102b5bd923657619a8af317ad9..d99447eebdcd4bd6ef1c3a00af9ac54bffbf9c41 100755 (executable)
@@ -1765,12 +1765,17 @@ static Eina_Bool _enlarge_widget_anim_cb(void *data)
                evas_object_data_set(effect_page,
                                PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *)divide_factor - 1);
        }
-
-       vec_x = (end_x - cur_x) / divide_factor;
-       vec_y = (end_y - cur_y) / divide_factor;
-       vec_w = (end_w - cur_w) / divide_factor;
-       vec_h = (end_h - cur_h) / divide_factor;
-
+       if (!divide_factor) {
+               vec_x = (end_x - cur_x);
+               vec_y = (end_y - cur_y);
+               vec_w = (end_w - cur_w);
+               vec_h = (end_h - cur_h);
+       } else {
+               vec_x = (end_x - cur_x) / divide_factor;
+               vec_y = (end_y - cur_y) / divide_factor;
+               vec_w = (end_w - cur_w) / divide_factor;
+               vec_h = (end_h - cur_h) / divide_factor;
+       }
        if (!vec_x) vec_x = -1;
        if (!vec_y) vec_y = -1;
        if (!vec_w) vec_w = 1;
@@ -2160,6 +2165,11 @@ Evas_Object *_create_plus_page(Evas_Object *edit)
        scroller_info_s *scroller_info = NULL;
        scroller_info_s *edit_scroller_info = NULL;
        Eina_Bool ret;
+       access_info_t *access_info = NULL;
+       Evas_Object *target = NULL;
+       char *name = _("IDS_HS_BODY_ADD_WIDGET");
+       char *role = _("IDS_HS_BODY_BUTTON_T_TTS");
+       Evas_Object *item_ao = NULL;
 
        retv_if(!edit, NULL);
 
@@ -2202,11 +2212,7 @@ Evas_Object *_create_plus_page(Evas_Object *edit)
        goto_if(!page_info->page_inner, ERROR);
 
        /* Edit Plus Access Object */
-       access_info_t *access_info = NULL;
-       Evas_Object *target = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(plus_item), "mask");
-       char *name = _("IDS_HS_BODY_ADD_WIDGET");
-       char *role = _("IDS_HS_BODY_BUTTON_T_TTS");
-       Evas_Object *item_ao = NULL;
+       target = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(plus_item), "mask");
 
        access_info = screen_reader_create_access_info(target, page_info->item, name, role, ELM_ACCESSIBLE_READING_INFO_TYPE_NAME | ELM_ACCESSIBLE_READING_INFO_TYPE_DESCRIPTION);
        if (!access_info) {
@@ -3179,11 +3185,18 @@ static Eina_Bool _minify_page_anim_cb(void *data)
                evas_object_data_set(effect_page,
                                PRIVATE_DATA_KEY_DIVIDE_FACTOR, (void *)divide_factor - 1);
        }
+       if (!divide_factor) {
+               vec_x = (end_x - cur_x);
+               vec_y = (end_y - cur_y);
+               vec_w = (end_w - cur_w);
+               vec_h = (end_h - cur_h);
+       } else {
+               vec_x = (end_x - cur_x) / divide_factor;
+               vec_y = (end_y - cur_y) / divide_factor;
+               vec_w = (end_w - cur_w) / divide_factor;
+               vec_h = (end_h - cur_h) / divide_factor;
 
-       vec_x = (end_x - cur_x) / divide_factor;
-       vec_y = (end_y - cur_y) / divide_factor;
-       vec_w = (end_w - cur_w) / divide_factor;
-       vec_h = (end_h - cur_h) / divide_factor;
+       }
 
        if (!vec_x) vec_x = 1;
        if (!vec_y) vec_y = 1;
index ad628cfa9b1a2c570fc62596a1a99f8944fbe6e9..8a90ede5f00b4d2ccd19ee7eb5f271ec1e5e76ac 100755 (executable)
@@ -234,61 +234,65 @@ static Eina_Bool _longpress_timer_cb(void *data)
        }
 
        switch (page_info->direction) {
-       case PAGE_DIRECTION_LEFT:
-               _D("There is already a pressed item");
-               evas_object_data_set(layout_info->pressed_page, DATA_KEY_PAGE_ONHOLD_COUNT, (void*)1);
-               retv_if(!edit_create_layout(layout, EDIT_MODE_LEFT), ECORE_CALLBACK_CANCEL);
-
-               edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
-               retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
-
-               proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
-               retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
-
-               effect_page = edit_create_minify_effect_page(proxy_page);
-               retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
-
-               scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
-               break;
-       case PAGE_DIRECTION_CENTER:
-               if (util_feature_enabled_get(FEATURE_CLOCK_SELECTOR) != 1)
-                       no_effect = 1;
-
-               app_control_h app_control_handle = NULL;
-               app_control_create(&app_control_handle);
-               app_control_set_app_id(app_control_handle, "org.tizen.watch-setting");
-               app_control_add_extra_data(app_control_handle, "launch-type", "watchface");
-               app_control_send_launch_request(app_control_handle, NULL, NULL);
-               app_control_destroy(app_control_handle);
-               break;
-       case PAGE_DIRECTION_RIGHT:
-               if (layout_info->pressed_item) {
+               case PAGE_DIRECTION_LEFT: {
                        _D("There is already a pressed item");
-                       widget_viewer_evas_feed_mouse_up_event(layout_info->pressed_item);
+                       evas_object_data_set(layout_info->pressed_page, DATA_KEY_PAGE_ONHOLD_COUNT, (void*)1);
+                       retv_if(!edit_create_layout(layout, EDIT_MODE_LEFT), ECORE_CALLBACK_CANCEL);
+
+                       edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
+                       retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
+
+                       proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
+                       retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
+
+                       effect_page = edit_create_minify_effect_page(proxy_page);
+                       retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
+
+                       scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
+                       break;
                }
-               retv_if(!edit_create_layout(layout, EDIT_MODE_RIGHT), ECORE_CALLBACK_CANCEL);
+               case PAGE_DIRECTION_CENTER: {
+                       if (util_feature_enabled_get(FEATURE_CLOCK_SELECTOR) != 1)
+                               no_effect = 1;
+
+                       app_control_h app_control_handle = NULL;
+                       app_control_create(&app_control_handle);
+                       app_control_set_app_id(app_control_handle, "org.tizen.watch-setting");
+                       app_control_add_extra_data(app_control_handle, "launch-type", "watchface");
+                       app_control_send_launch_request(app_control_handle, NULL, NULL);
+                       app_control_destroy(app_control_handle);
+                       break;
+               }
+               case PAGE_DIRECTION_RIGHT: {
+                       if (layout_info->pressed_item) {
+                               _D("There is already a pressed item");
+                               widget_viewer_evas_feed_mouse_up_event(layout_info->pressed_item);
+                       }
+                       retv_if(!edit_create_layout(layout, EDIT_MODE_RIGHT), ECORE_CALLBACK_CANCEL);
 
-               scroller_unregister_access_object(layout_info->scroller);
-               page_focus(layout_info->scroller, NULL);
+                       scroller_unregister_access_object(layout_info->scroller);
+                       page_focus(layout_info->scroller, NULL);
 
-               edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
-               retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
+                       edit_info = evas_object_data_get(layout_info->edit, DATA_KEY_EDIT_INFO);
+                       retv_if(!edit_info, ECORE_CALLBACK_CANCEL);
 
-               proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
-               retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
+                       proxy_page = evas_object_data_get(layout_info->pressed_page, DATA_KEY_PROXY_PAGE);
+                       retv_if(!proxy_page, ECORE_CALLBACK_CANCEL);
 
-               effect_page = edit_create_minify_effect_page(proxy_page);
-               retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
+                       effect_page = edit_create_minify_effect_page(proxy_page);
+                       retv_if(!effect_page, ECORE_CALLBACK_CANCEL);
 
-               scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
+                       scroller_region_show_center_of(edit_info->scroller, proxy_page, SCROLLER_FREEZE_OFF, NULL, NULL, edit_minify_effect_page, effect_page);
 
-               if (layout_info->pressed_page == scroller_info->plus_page)
-                       evas_object_data_set(layout_info->pressed_item, DATA_KEY_IS_LONGPRESS, (void *)1);
+                       if (layout_info->pressed_page == scroller_info->plus_page)
+                               evas_object_data_set(layout_info->pressed_item, DATA_KEY_IS_LONGPRESS, (void *)1);
 
-               break;
-       default:
-               _D("Cannot reach here");
-               break;
+                       break;
+               }
+               default: {
+                       _D("Cannot reach here");
+                       break;
+               }
        }
 
        if (no_effect == 0)
index 0459cad991ab01da1f19e4b6e8c25f666911a765..2175db47aed414e6f6a41f1fa5ea097edfbc5177 100755 (executable)
@@ -153,6 +153,9 @@ static void __control_button_up_cb(void *data, Evas *e, Evas_Object *obj, void *
 
 static Evas_Object *__create_control_button(Evas_Object * base_layout, control_info_t *btn_info)
 {
+       char full_path[MAX_FILE_PATH_LEN] = {0};
+       char *resource_path = NULL;
+       Evas_Object *icon = NULL;
        Evas_Object *button_layout = elm_layout_add(base_layout);
 
        if (!button_layout || !elm_layout_file_set(button_layout, util_get_res_file_path(CONTROL_BUTTON_LAYOUT_EDJE), controls_btn_group_name[btn_info->btn_type])) {
@@ -167,10 +170,7 @@ static Evas_Object *__create_control_button(Evas_Object * base_layout, control_i
 
        evas_object_show(button_layout);
 
-       Evas_Object *icon = elm_image_add(button_layout);
-
-       char full_path[MAX_FILE_PATH_LEN] = {0};
-       char *resource_path = NULL;
+       icon = elm_image_add(button_layout);
 
        resource_path = app_get_resource_path();
        if (!resource_path) {
index cceec986b6068e0ef0b018703646a00f275a00fd..90ca32598c80f6716d66844cf98d7b85b4d09845 100755 (executable)
@@ -297,26 +297,33 @@ static void _noti_detail_view_clear_all_clicked_cb(void *data, Evas_Object *obj,
 static void _noti_detail_view_open_app_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
        int ret;
+       app_control_h app_control_local;
 
        if (_noti_detail_view_data_s.app_control) {
                ret = app_control_send_launch_request(_noti_detail_view_data_s.app_control, NULL, NULL);
                ret_if(ret != APP_CONTROL_ERROR_NONE);
        } else {
-               app_control_h app_control_local;
-
                ret = app_control_create(&app_control_local);
                ret_if(ret != APP_CONTROL_ERROR_NONE);
 
                ret = app_control_set_app_id(app_control_local, data);
-               ret_if(ret != APP_CONTROL_ERROR_NONE);
-
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       _E("Failed to set app id");
+                       goto ERROR;
+               }
                ret = app_control_send_launch_request(app_control_local, NULL, NULL);
-               ret_if(ret != APP_CONTROL_ERROR_NONE);
-
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       _E("Failed to send launch request");
+                       goto ERROR;
+               }
                app_control_destroy(app_control_local);
        }
 
        return;
+ERROR:
+       if (app_control_local)
+               app_control_destroy(app_control_local);
+       return;
 }
 
 static Evas_Object * _noti_detail_view_set_label()
@@ -600,7 +607,12 @@ static void _noti_detail_view_set_contents(Eina_Bool is_popup)
 
        /* Horizontal separator */
        Evas_Object *line = _noti_create_detail_view_item_layout("detail_line");
-       ret_if(!line);
+       if (!line) {
+               _E("Failed to create detail view ");
+               if (text_time)
+                       free(text_time);
+               return;
+       }
        _noti_detail_view_data_s.item_list = eina_list_append(_noti_detail_view_data_s.item_list, line);
 
        if (content_text) {
@@ -666,6 +678,10 @@ static void _noti_detail_view_set_contents(Eina_Bool is_popup)
 
        _noti_detail_view_data_s.bottom_spacer = bottom_spacer;
        evas_object_data_set(bottom_spacer, DATA_KEY_APP_NAME, app_name);
+       if (text_time)
+               free(text_time);
+
+       return;
 }
 
 static Evas_Object* _noti_create_detail_view_circle_scroller(Evas_Object *scroller, Eext_Circle_Surface *surface)
index 028f3195648887e14f06cbc6978c6a3d66007042..80b53fa882fc1c80cb0fb127a201527fb0d8d651 100755 (executable)
@@ -215,7 +215,8 @@ static Eina_Bool _push_pages(void *data)
 
        noti = notification_list_get_data(cur_noti);
        layout = _stack_view_create_page(scroller, noti);
-       if (layout) access_object = elm_access_object_get(layout);
+       if (!layout)
+               _E("Failed to create page");
 
        next_noti = notification_list_get_next(cur_noti);
        if (!next_noti) {
@@ -328,6 +329,7 @@ static Evas_Object *_stack_view_create_scroller(Evas_Object *stack_view, char *p
        Evas_Object *circle_scroller = NULL;
        Evas_Object *scroller = NULL;
        Evas_Object *box = NULL;
+       bool is_valid_pkg_id = 0;
 
        retv_if(!stack_view, NULL);
        retv_if(!pkg_id, NULL);
@@ -363,7 +365,7 @@ static Evas_Object *_stack_view_create_scroller(Evas_Object *stack_view, char *p
        evas_object_data_set(stack_view, DATA_KEY_APP_ID, pkg_id);
 
        /* If given pkg id is not available id, set DATA_KEY_PKG_VALIDITY with validity for hiding buttons */
-       bool is_valid_pkg_id = _stack_view_is_valid_package_id(pkg_id);
+       is_valid_pkg_id = _stack_view_is_valid_package_id(pkg_id);
 
        evas_object_data_set(stack_view, DATA_KEY_PKG_VALIDITY, (const void*)is_valid_pkg_id);
 
index 1421e1e748015331acff635ee8c1efe6fa20340a..4d2b04ad52dbae2758031084ddde4a28f00e6ddd 100755 (executable)
@@ -46,6 +46,7 @@ static void _noti_full_popup_view_set_icon(Evas_Object *noti_layout, const char
        Evas_Object *icon = NULL;
        Eina_Bool err = EINA_FALSE;
        char unknown_icon_path[PATH_MAX] = { 0, };
+       char *resource_path = NULL;
 
        if (noti_layout == NULL) {
                _E("invalid parameter");
@@ -59,8 +60,6 @@ static void _noti_full_popup_view_set_icon(Evas_Object *noti_layout, const char
        }
        _D("icon_path [%s]", icon_path);
        if (icon_path == NULL) {
-               char *resource_path = NULL;
-
                resource_path = app_get_resource_path();
                if (!resource_path) {
                        _E("Failed to get resource path");
index ba123ff3273087b62d4f3b902c5e8bb51888c540..831d295105da0d9797db1fd7d4c3c2708db7a2a8 100755 (executable)
@@ -68,6 +68,7 @@ static void _noti_small_popup_view_set_icon(Evas_Object *noti_layout, const char
        Evas_Object *icon = NULL;
        Eina_Bool err = EINA_FALSE;
        char unknown_icon_path[PATH_MAX] = { 0, };
+       char *resource_path = NULL;
 
        if (noti_layout == NULL) {
                _E("invalid parameter");
@@ -81,8 +82,6 @@ static void _noti_small_popup_view_set_icon(Evas_Object *noti_layout, const char
        }
 
        if (icon_path == NULL) {
-               char *resource_path = NULL;
-
                resource_path = app_get_resource_path();
                if (!resource_path) {
                        _E("Failed to get resource path");