From 2e4cffc344832c48d7115363d574472551078e1d Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Wed, 19 Aug 2020 17:20:25 +0900 Subject: [PATCH] subsurface: use eina_safety to be loud on invalid parameters. it should use eina_safety_checks when it comes to the variable that must not be null. this will make noise and let us know about the misuse. Change-Id: Ia3eb72eb249e4757e1ef651f0bb5c9acf6b1727f --- src/bin/e_comp_wl_subsurface.c | 43 +++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/bin/e_comp_wl_subsurface.c b/src/bin/e_comp_wl_subsurface.c index c7e644ee8f..81825efd3a 100644 --- a/src/bin/e_comp_wl_subsurface.c +++ b/src/bin/e_comp_wl_subsurface.c @@ -366,7 +366,7 @@ _e_comp_wl_subsurface_commit_to_cache(E_Client *ec) if (!(cdata = ec->comp_data)) return; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); DBG("Subsurface Commit to Cache"); @@ -439,7 +439,7 @@ _e_comp_wl_subsurface_commit_from_cache(E_Client *ec) E_Comp_Wl_Subsurf_Data *sdata; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); DBG("Subsurface Commit from Cache"); @@ -472,6 +472,7 @@ _e_comp_wl_subsurface_synchronized_commit(E_Client *ec) Eina_List *l; sdata = _e_comp_wl_subsurface_data_get(ec); + EINA_SAFETY_ON_NULL_RETURN(sdata); if (sdata->cached.has_data) _e_comp_wl_subsurface_commit_from_cache(ec); @@ -497,7 +498,8 @@ _e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized) if (!ec || e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); + if (!(parent = sdata->parent)) return; if (sdata->position.set) @@ -530,7 +532,7 @@ _e_comp_wl_subsurface_cb_position_set(struct wl_client *client EINA_UNUSED, stru if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); sdata->position.x = x; sdata->position.y = y; @@ -610,7 +612,7 @@ _e_comp_wl_subsurface_cb_sync_set(struct wl_client *client EINA_UNUSED, struct w if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); sdata->synchronized = EINA_TRUE; } @@ -628,7 +630,7 @@ _e_comp_wl_subsurface_cb_desync_set(struct wl_client *client EINA_UNUSED, struct if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return; sdata = _e_comp_wl_subsurface_data_get(ec); - if (!sdata) return; + EINA_SAFETY_ON_NULL_RETURN(sdata); if (sdata->synchronized) { @@ -852,6 +854,9 @@ _e_comp_wl_subsurface_circular_reference_check(E_Client *ec, E_Client *parent) EINTERN Eina_Bool e_comp_wl_subsurfaces_init(E_Comp_Wl_Data *wl_comp) { + EINA_SAFETY_ON_NULL_RETURN_VAL(wl_comp, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(wl_comp->wl.disp, EINA_FALSE); + global = wl_global_create(wl_comp->wl.disp, &wl_subcompositor_interface, 1, NULL, @@ -885,6 +890,7 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ E_Client *offscreen_parent = NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface_resource, EINA_FALSE); /* try to get the wayland client from the surface resource */ if (!(client = wl_resource_get_client(surface_resource))) @@ -1013,12 +1019,16 @@ e_comp_wl_subsurface_create(E_Client *ec, E_Client *epc, uint32_t id, struct wl_ EINTERN void e_comp_wl_subsurface_parent_commit(E_Client *ec, Eina_Bool parent_synchronized) { + EINA_SAFETY_ON_NULL_RETURN(ec); + _e_comp_wl_subsurface_parent_commit(ec, parent_synchronized); } EINTERN Eina_Bool e_comp_wl_subsurface_order_commit(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + return _e_comp_wl_subsurface_order_commit(ec); } @@ -1027,6 +1037,8 @@ e_comp_wl_subsurface_commit(E_Client *ec) { E_Comp_Wl_Subsurf_Data *sdata; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + /* check for valid subcompositor data */ if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return EINA_FALSE; @@ -1081,6 +1093,8 @@ e_comp_wl_subsurface_can_show(E_Client *ec) E_Client *invisible_parent; E_Client *topmost; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + /* if it's not subsurface */ sdata = _e_comp_wl_subsurface_data_get(ec); if (!sdata) return EINA_FALSE; @@ -1100,24 +1114,32 @@ e_comp_wl_subsurface_can_show(E_Client *ec) EINTERN void e_comp_wl_subsurface_show(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN(ec); + _e_comp_wl_subsurface_show(ec); } EINTERN void e_comp_wl_subsurface_hide(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN(ec); + _e_comp_wl_subsurface_hide(ec); } EINTERN void e_comp_wl_subsurface_restack_bg_rectangle(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN(ec); + _e_comp_wl_subsurface_restack_bg_rectangle(ec); } EINTERN void e_comp_wl_subsurface_restack(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN(ec); + _e_comp_wl_subsurface_restack(ec); } @@ -1126,7 +1148,9 @@ e_comp_wl_subsurface_stack_update(E_Client *ec) { E_Client *topmost; - if (!(ec) || !ec->comp_data) return; + EINA_SAFETY_ON_NULL_RETURN(ec); + + if (!ec->comp_data) return; if (e_object_is_del(E_OBJECT(ec))) return; if (ec->comp_data->sub.restacking) return; @@ -1172,6 +1196,8 @@ e_comp_wl_subsurface_stack_update(E_Client *ec) EINTERN Eina_Bool e_comp_wl_video_subsurface_has(E_Client *ec) { + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + return _e_comp_wl_subsurface_video_has(ec); } @@ -1181,7 +1207,8 @@ e_comp_wl_normal_subsurface_has(E_Client *ec) E_Client *subc; Eina_List *l; - if (!ec) return EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE); + if (e_object_is_del(E_OBJECT(ec))) return EINA_FALSE; if (!ec->comp_data) return EINA_FALSE; -- 2.34.1