From adf57f4dce0dbf0e10bb5baf8458272c0ee26771 Mon Sep 17 00:00:00 2001 From: Evgen Servetnik Date: Wed, 23 Aug 2017 12:52:10 +0300 Subject: [PATCH] TizenRefApp-9197 Fix sonar issues Change-Id: Ib368c4deaf36d84dad3078cc15ce45a3f82c7b61 Signed-off-by: Evgen Servetnik --- src/wallpaper-ui-service-main.c | 56 ++++++++++++++++++----------------------- src/wallpaper-ui-service.c | 6 ++--- 2 files changed, 26 insertions(+), 36 deletions(-) diff --git a/src/wallpaper-ui-service-main.c b/src/wallpaper-ui-service-main.c index 778e175..6366408 100644 --- a/src/wallpaper-ui-service-main.c +++ b/src/wallpaper-ui-service-main.c @@ -125,10 +125,9 @@ static void _main_done_button_cb(void *data, Evas_Object *obj, void *event_info) if (state_data.flag_changed) { Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid); - Thumbnail *s_item = NULL; while (object_item) { - s_item = (Thumbnail *)elm_object_item_data_get(object_item); + Thumbnail *s_item = (Thumbnail *)elm_object_item_data_get(object_item); if (s_item && s_item->path && s_item->bSelected) { WALLPAPERUI_DBG("Done button Selected path=%s %d", s_item->path, s_item->index); strncpy(ad->saved_img_path, s_item->path, MAX_LENGTH_LINE - 1); @@ -168,11 +167,8 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r WALLPAPERUI_TRACE_BEGIN; char **path_array = NULL; - int array_length = 0; - Elm_Object_Item *object_item = NULL; - int i = 0; - Thumbnail *item = NULL; + int array_length = 0; if (app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &path_array, &array_length) == APP_CONTROL_ERROR_NONE) { WALLPAPERUI_DBG("array_length = %d", array_length); @@ -181,7 +177,7 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r return; } else { char file_ext[MAX_LENGTH_LINE] = {0, }; - for (; i < array_length; i++) { + for (int i = 0; i < array_length; i++) { _get_filename_extension_in_uppercase(path_array[i], file_ext, MAX_LENGTH_LINE); if (*file_ext == 0) { WALLPAPERUI_DBG("invalid image path: path_array[%d] = %d", i, path_array[i]); @@ -203,7 +199,7 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r memset(ad->saved_img_path, 0, sizeof(ad->saved_img_path)); strncpy(ad->saved_img_path, path_array[0], MAX_LENGTH_LINE - 1); WALLPAPERUI_DBG("saved_img_path is %s", ad->saved_img_path); - for (i = 0; i < array_length; i++) + for (int i = 0; i < array_length; i++) free(path_array[i]); free(path_array); @@ -212,9 +208,9 @@ static void _service_gallery_ug_result_cb(app_control_h request, app_control_h r elm_image_file_set(ad->preview_image, ad->saved_img_path, NULL); evas_object_show(ad->preview_image); - object_item = elm_gengrid_first_item_get(ad->gengrid); + Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid); - item = (Thumbnail *)elm_object_item_data_get(object_item); + Thumbnail *item = (Thumbnail *)elm_object_item_data_get(object_item); if (item) { item->bSelected = EINA_TRUE; item->path = strdup(ad->saved_img_path); @@ -271,9 +267,8 @@ static bool _wallpaper_db_create_filter(filter_h *filter) { WALLPAPERUI_TRACE_BEGIN; - int ret = MEDIA_CONTENT_ERROR_NONE; + int ret = media_filter_create(filter); - ret = media_filter_create(filter); if (ret != MEDIA_CONTENT_ERROR_NONE) { WALLPAPERUI_ERR("media_filter_create is failed, err"); return false; @@ -287,9 +282,8 @@ static bool _wallpaper_db_destroy_filter(filter_h filter) { WALLPAPERUI_TRACE_BEGIN; - int ret = MEDIA_CONTENT_ERROR_NONE; + int ret = media_filter_destroy(filter); - ret = media_filter_destroy(filter); if (ret != MEDIA_CONTENT_ERROR_NONE) { WALLPAPERUI_ERR("media_filter_destroy is failed, err"); return false; @@ -426,21 +420,19 @@ static void _done_to_set_wallpaper() { WALLPAPERUI_TRACE_BEGIN; - char *p = NULL; - char filepath[MAX_LENGTH_LINE] = { 0 }; - char filename[MAX_LENGTH_LINE] = { 0 }; - char *q = NULL; - char *temp_path = NULL; /*copy lock wallpaper */ if (strlen(ad->saved_img_path) > 1) { WALLPAPERUI_DBG("saved_img_path = %s", ad->saved_img_path); - p = strrchr(ad->saved_img_path, '/'); + char *p = strrchr(ad->saved_img_path, '/'); if (p) { + char filepath[MAX_LENGTH_LINE] = { 0 }; + if (ad->preview_image_type != WALLPAPER_TYPE_GALLERY) { - q = strrchr(p, '.'); + char *q = strrchr(p, '.'); const char *wallpapers_path = wallpaper_ui_service_get_settings_wallpapers_path(); if (q && ((strcmp(q, ".gif") == 0) || (strcmp(q, ".wbmp") == 0) || (strcmp(q, ".bmp") == 0))) { + char filename[MAX_LENGTH_LINE] = { 0 }; WALLPAPERUI_DBG(".gif||.wbmp||.bmp image"); strncpy(filename, p, MAX_LENGTH_LINE - 1); q = strrchr(filename, '.'); @@ -475,6 +467,7 @@ static void _done_to_set_wallpaper() free(state_data.to); state_data.to = NULL; } + char *temp_path = NULL; state_data.to = strdup(filepath); if (ad->preview_image_type == WALLPAPER_TYPE_GALLERY) { @@ -487,11 +480,13 @@ static void _done_to_set_wallpaper() _set_wallpaper(temp_path); strncpy(ad->current_preview_img_path, temp_path, MAX_LENGTH_LINE - 1); + + free(temp_path); WALLPAPERUI_DBG("current_preview_img_path %s", ad->current_preview_img_path); } } - free(temp_path); + if (state_data.flag_image_from_gallery) { vconf_set_int(VCONFKEY_LOCKSCREEN_WALLPAPER_TYPE, WALLPAPER_TYPE_GALLERY); @@ -602,12 +597,11 @@ static void _wallpaper_db_update_cb(media_content_error_e error, int pid, if ((last_image == NULL && strstr(ad->last_preview_img_path, "no_gallery_bg.png") == NULL) || (last_image != NULL && strcmp(last_image, ad->last_preview_img_path) != 0)) { /* if last image was changed */ - Thumbnail *item = NULL; Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid); while (object_item) { - item = (Thumbnail *)elm_object_item_data_get(object_item); + Thumbnail *item = (Thumbnail *)elm_object_item_data_get(object_item); if (item && item->type == WALLPAPER_TYPE_GALLERY) { free(item->path); @@ -876,12 +870,10 @@ static void _wallpaper_show_focus_highlight(int selected_index) { WALLPAPERUI_TRACE_BEGIN; - Thumbnail *item = NULL; - Elm_Object_Item *object_item = elm_gengrid_first_item_get(ad->gengrid); while (object_item) { - item = (Thumbnail *)elm_object_item_data_get(object_item); + Thumbnail *item = (Thumbnail *)elm_object_item_data_get(object_item); if (item && item->path && item->bSelected) { if (item->index != selected_index) { @@ -939,7 +931,7 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent) char *setting_value = NULL; int setting_type = 0; Eina_List *file_list = NULL; - char *temp = NULL; + int count = 0; Thumbnail *temp_item = NULL; @@ -972,8 +964,6 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent) gic_for_main->func.state_get = NULL; gic_for_main->func.del = _preview_grid_content_del; - int i = 0; - /* Gallery icon */ s_item = (Thumbnail *)calloc(1, sizeof(Thumbnail)); if (s_item != NULL) { @@ -1007,10 +997,12 @@ static Evas_Object *main_gengrid_add(Evas_Object *parent) count = eina_list_count(file_list); WALLPAPERUI_DBG("count = %d", count); - char picturePath[MAX_LENGTH_LINE] = { 0 }; + /* default directory */ if (count > 0) { - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { + char *temp = NULL; + char picturePath[MAX_LENGTH_LINE] = { 0 }; temp = (char *)eina_list_nth(file_list, i); WALLPAPERUI_DBG("temp = %s", temp); diff --git a/src/wallpaper-ui-service.c b/src/wallpaper-ui-service.c index 066ba09..30b65a7 100644 --- a/src/wallpaper-ui-service.c +++ b/src/wallpaper-ui-service.c @@ -122,9 +122,8 @@ static bool _wallpaper_db_create(void) { WALLPAPERUI_TRACE_BEGIN; - int ret = MEDIA_CONTENT_ERROR_NONE; + int ret = media_content_connect(); - ret = media_content_connect(); if (ret != MEDIA_CONTENT_ERROR_NONE) { WALLPAPERUI_ERR("media_content_connect is failed, err:%s", _str_error_db(ret)); return false; @@ -137,9 +136,8 @@ static bool _wallpaper_db_destroy(void) { WALLPAPERUI_TRACE_BEGIN; - int ret = MEDIA_CONTENT_ERROR_NONE; + int ret = media_content_disconnect(); - ret = media_content_disconnect(); if (ret != MEDIA_CONTENT_ERROR_NONE) { WALLPAPERUI_ERR("media_content_disconnect is failed, err:%s", _str_error_db(ret)); return false; -- 2.7.4