From d526da44deb3b25b45b7efe0c27b56b8ab3375cc Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Wed, 4 May 2016 14:34:19 +0900 Subject: [PATCH] fixed the problems detected by static analyzer Change-Id: Ib343b6b39c6d9c98c8d4cea7a76ab40ff015d75e --- src/bin/e_actions.c | 2 +- src/bin/e_client.c | 34 ++++++++++++++++++++++++++-------- src/bin/e_comp.h | 2 -- src/bin/e_comp_hwc.c | 3 ++- src/bin/e_comp_wl.c | 3 +-- src/bin/e_hints.c | 24 ++++++++++++------------ 6 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index 2881328129..42a2ed1727 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -2426,7 +2426,7 @@ e_action_predef_name_del(const char *act_grp, const char *act_name) EINA_LIST_FOREACH(actg->acts, l, actd) { - if (!strcmp(actd->act_name, act_name)) + if ((actd->act_name) && (!strcmp(actd->act_name, act_name))) { actg->acts = eina_list_remove(actg->acts, actd); diff --git a/src/bin/e_client.c b/src/bin/e_client.c index 2f8d9b42fb..0a4bf0bf96 100644 --- a/src/bin/e_client.c +++ b/src/bin/e_client.c @@ -29,7 +29,7 @@ E_API int E_EVENT_CLIENT_VISIBILITY_CHANGE = -1; E_API int E_EVENT_CLIENT_BUFFER_CHANGE = -1; #endif -static Eina_Hash *clients_hash[2] = {NULL}; // pixmap->client +static Eina_Hash *clients_hash[E_PIXMAP_TYPE_MAX] = {NULL}; // pixmap->client static unsigned int focus_track_frozen = 0; @@ -826,6 +826,7 @@ static void _e_client_del(E_Client *ec) { E_Client *child; + E_Pixmap_Type type; ec->changed = 0; focus_stack = eina_list_remove(focus_stack, ec); @@ -894,7 +895,9 @@ _e_client_del(E_Client *ec) EINA_LIST_FREE(ec->group, child) child->leader = NULL; - eina_hash_del_by_key(clients_hash[e_pixmap_type_get(ec->pixmap)], &ec->pixmap); + type = e_pixmap_type_get(ec->pixmap); + if (type < E_PIXMAP_TYPE_MAX) + eina_hash_del_by_key(clients_hash[type], &ec->pixmap); e_comp->clients = eina_list_remove(e_comp->clients, ec); e_comp_object_render_update_del(ec->frame); e_comp_post_update_purge(ec); @@ -3049,8 +3052,18 @@ e_client_idler_before(void) { const Eina_List *l; E_Client *ec; + Eina_Bool exist_clients_hash = EINA_FALSE; + int pix_id; - if ((!eina_hash_population(clients_hash[0])) && (!eina_hash_population(clients_hash[1]))) return; + for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++) + { + if (eina_hash_population(clients_hash[pix_id])) + { + exist_clients_hash = EINA_TRUE; + break; + } + } + if (!exist_clients_hash) return; TRACE_DS_BEGIN(CLIENT:IDLE BEFORE); @@ -3156,8 +3169,9 @@ e_client_idler_before(void) EINTERN Eina_Bool e_client_init(void) { - clients_hash[0] = eina_hash_pointer_new(NULL); - clients_hash[1] = eina_hash_pointer_new(NULL); + int pix_id; + for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++) + clients_hash[pix_id] = eina_hash_pointer_new(NULL); E_LIST_HANDLER_APPEND(handlers, E_EVENT_POINTER_WARP, _e_client_cb_pointer_warp, NULL); E_LIST_HANDLER_APPEND(handlers, E_EVENT_CONFIG_MODE_CHANGED, _e_client_cb_config_mode, NULL); @@ -3195,8 +3209,9 @@ e_client_init(void) EINTERN void e_client_shutdown(void) { - E_FREE_FUNC(clients_hash[0], eina_hash_free); - E_FREE_FUNC(clients_hash[1], eina_hash_free); + int pix_id; + for (pix_id = 0; pix_id < E_PIXMAP_TYPE_MAX; pix_id++) + E_FREE_FUNC(clients_hash[pix_id], eina_hash_free); E_FREE_LIST(handlers, ecore_event_handler_del); @@ -3226,8 +3241,11 @@ E_API E_Client * e_client_new(E_Pixmap *cp, int first_map, int internal) { E_Client *ec; + E_Pixmap_Type type; - if (eina_hash_find(clients_hash[e_pixmap_type_get(cp)], &cp)) return NULL; + type = e_pixmap_type_get(cp); + if (type >= E_PIXMAP_TYPE_MAX) return NULL; + if (eina_hash_find(clients_hash[type], &cp)) return NULL; ec = E_OBJECT_ALLOC(E_Client, E_CLIENT_TYPE, _e_client_free); if (!ec) return NULL; diff --git a/src/bin/e_comp.h b/src/bin/e_comp.h index 076c65f9d9..207999ccfb 100644 --- a/src/bin/e_comp.h +++ b/src/bin/e_comp.h @@ -133,9 +133,7 @@ struct _E_Comp Eina_Stringshare *name; struct { - Ecore_Window win; Evas_Object *obj; - //Eina_Inlist *objs; /* E_Comp_Object; NOT to be exposed; seems pointless? */ Eina_Inlist *clients; /* E_Client, bottom to top */ unsigned int clients_count; } layers[E_LAYER_COUNT]; diff --git a/src/bin/e_comp_hwc.c b/src/bin/e_comp_hwc.c index 59a31f0fba..74b0b74477 100755 --- a/src/bin/e_comp_hwc.c +++ b/src/bin/e_comp_hwc.c @@ -1110,7 +1110,8 @@ _e_comp_hwc_output_commit(E_Comp_Hwc_Output *hwc_output, E_Comp_Hwc_Layer *hwc_l hwc_layer->info.dst_pos.w, hwc_layer->info.dst_pos.h, data); else ELOGF("HWC", "Commit Layer(%p) wl_buffer(%p) tsurface(%p) (%dx%d,[%d,%d,%d,%d]=>[%d,%d,%d,%d]) data(%p) wl_buffer_ref(%p)", - ec->pixmap, ec, hwc_layer, _get_wl_buffer(ec), tsurface, + ec ? ec->pixmap : NULL, ec, + hwc_layer, _get_wl_buffer(ec), tsurface, hwc_layer->info.src_config.size.h, hwc_layer->info.src_config.size.h, hwc_layer->info.src_config.pos.x, hwc_layer->info.src_config.pos.y, hwc_layer->info.src_config.pos.w, hwc_layer->info.src_config.pos.h, diff --git a/src/bin/e_comp_wl.c b/src/bin/e_comp_wl.c index 4398f51edc..03545a6544 100644 --- a/src/bin/e_comp_wl.c +++ b/src/bin/e_comp_wl.c @@ -2238,7 +2238,7 @@ _e_comp_wl_surface_state_commit(E_Client *ec, E_Comp_Wl_Surface_State *state) EINA_LIST_FREE(state->damages, dmg) { Eina_Rectangle temp = {0,}; - if (ec->comp_data && ec->comp_data->sub.data && + if (ec->comp_data->sub.data && (ec->comp_data->scaler.buffer_viewport.surface.width != -1 || ec->comp_data->scaler.buffer_viewport.buffer.src_width != wl_fixed_from_int(-1))) { @@ -3991,7 +3991,6 @@ _e_comp_wl_gl_init(void *data EINA_UNUSED) e_comp_wl->wl.glapi = glapi; e_comp_wl->wl.glsfc = sfc; e_comp_wl->wl.glctx = ctx; - e_comp_wl->wl.glcfg = cfg; /* for native surface */ e_comp->gl = 1; diff --git a/src/bin/e_hints.c b/src/bin/e_hints.c index 94f6ac6621..b55c7966e0 100644 --- a/src/bin/e_hints.c +++ b/src/bin/e_hints.c @@ -296,19 +296,19 @@ e_hints_aux_hint_add_with_pixmap(E_Pixmap *cp, int32_t id, const char *name, con if (!found) { hint = E_NEW(E_Comp_Wl_Aux_Hint, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(hint, EINA_FALSE); + memset(hint, 0, sizeof(E_Comp_Wl_Aux_Hint)); - if (hint) - { - hint->id = id; - hint->hint = eina_stringshare_add(name); - hint->val = eina_stringshare_add(val); - hint->changed = EINA_TRUE; - hint->deleted = EINA_FALSE; - cdata->aux_hint.hints = eina_list_append(cdata->aux_hint.hints, hint); - cdata->aux_hint.changed = 1; - ELOGF("COMP", "AUX_HINT |Add [%d:%s:%s]", cp, e_pixmap_client_get(cp), - id, hint->hint, hint->val); - } + + hint->id = id; + hint->hint = eina_stringshare_add(name); + hint->val = eina_stringshare_add(val); + hint->changed = EINA_TRUE; + hint->deleted = EINA_FALSE; + cdata->aux_hint.hints = eina_list_append(cdata->aux_hint.hints, hint); + cdata->aux_hint.changed = 1; + ELOGF("COMP", "AUX_HINT |Add [%d:%s:%s]", cp, e_pixmap_client_get(cp), + id, hint->hint, hint->val); } if (!found) -- 2.34.1