Use 'try' keyword for functions may return null 76/315676/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 31 Jul 2024 05:13:35 +0000 (14:13 +0900)
committerJunSeok Kim <juns.kim@samsung.com>
Tue, 6 Aug 2024 05:18:08 +0000 (05:18 +0000)
Change-Id: Ide7e58207b8d648d3dff512e0f04529b8ed313cf

src/bin/server/e_comp_wl_buffer.c
src/bin/server/e_comp_wl_buffer_intern.h
src/bin/server/e_comp_wl_viewport.c
src/bin/server/e_compositor.c
src/bin/server/e_compositor_intern.h
src/bin/server/e_video_shell.c

index cda9a05..a5a3e66 100644 (file)
@@ -56,7 +56,7 @@ e_comp_wl_buffer_reference(E_Comp_Wl_Buffer_Ref *ref, E_Comp_Wl_Buffer *buffer)
 }
 
 EINTERN E_Comp_Wl_Buffer *
-e_comp_wl_buffer_get(struct ds_buffer *ds_buffer)
+e_comp_wl_buffer_try_get(struct ds_buffer *ds_buffer)
 {
    E_Buffer *buffer;
 
index 0077b77..fa1b76a 100644 (file)
@@ -6,7 +6,7 @@
 #include <libds/types/ds_buffer.h>
 #include <tbm_surface.h>
 
-E_Comp_Wl_Buffer *e_comp_wl_buffer_get(struct ds_buffer *ds_buffer);
+E_Comp_Wl_Buffer *e_comp_wl_buffer_try_get(struct ds_buffer *ds_buffer);
 E_Comp_Wl_Buffer *e_comp_wl_buffer_create_with_tbm_surface(tbm_surface_h tbm_surface);
 void e_comp_wl_buffer_destroy(E_Comp_Wl_Buffer *comp_buffer);
 void *e_comp_wl_buffer_single_pixel_buffer_data_get(E_Comp_Wl_Buffer *buffer);
index 7b32959..9821041 100644 (file)
@@ -1415,7 +1415,7 @@ _e_comp_wl_viewport_apply_destination(E_Viewport *viewport, Eina_Rectangle *rrec
    _e_comp_wl_viewport_crop_by_parent(viewport, &prect, &dst);
 
    /* The values of below x, y, w, h are specified in the transform 0 and in the parent */
-   subsurface = e_subsurface_from_surface(viewport->surface);
+   subsurface = e_subsurface_try_from_surface(viewport->surface);
    if (subsurface)
      {
         changed = e_subsurface_position_set(subsurface, dst.x, dst.y);
index 4233d21..5959e8a 100644 (file)
@@ -112,9 +112,9 @@ static void _e_surface_cb_commit(struct wl_listener *listener, void *data);
 static void _e_surface_cb_new_subsurface(struct wl_listener *listener, void *data);
 
 static E_Subsurface *_e_subsurface_create(struct ds_subsurface *ds_subsurface, E_Surface *parent_surface);
-static E_Subsurface *_e_subsurface_from_surface(E_Surface *surface);
-static E_Subsurface *_e_subsurface_from_resource(struct wl_resource *resource);
-static E_Subsurface *_e_subsurface_from_ds_subsurface(struct ds_subsurface *ds_subsurface);
+static E_Subsurface *_e_subsurface_try_from_surface(E_Surface *surface);
+static E_Subsurface *_e_subsurface_try_from_resource(struct wl_resource *resource);
+static E_Subsurface *_e_subsurface_try_from_ds_subsurface(struct ds_subsurface *ds_subsurface);
 static void _e_subsurface_destroy(E_Subsurface *sub);
 static void _e_subsurface_commit(E_Subsurface *sub);
 static void _e_subsurface_place_below_parent(E_Subsurface *sub);
@@ -193,7 +193,7 @@ e_subsurface_create(struct wl_resource *factory_resource, uint32_t id, E_Surface
 {
    ds_subsurface_create(factory_resource, surface->ds_surface, parent->ds_surface, id);
 
-   return _e_subsurface_from_surface(surface);
+   return _e_subsurface_try_from_surface(surface);
 }
 
 EINTERN E_Subsurface *
@@ -255,7 +255,7 @@ e_comp_wl_subsurface_resource_stand_alone_mode_set(struct wl_resource *subsurfac
 {
    E_Subsurface *sub;
 
-   sub = _e_subsurface_from_resource(subsurface_resource);
+   sub = _e_subsurface_try_from_resource(subsurface_resource);
    if (!sub)
      {
         INF("The given subsurface resource(%p) seems inert.", subsurface_resource);
@@ -273,7 +273,7 @@ e_comp_wl_subsurface_resource_place_below_parent(struct wl_resource *subsurface_
    E_Subsurface *sub;
    E_Comp_Wl_Client_Data *epc_cdata;
 
-   sub = _e_subsurface_from_resource(subsurface_resource);
+   sub = _e_subsurface_try_from_resource(subsurface_resource);
    if (!sub)
      {
         INF("The given subsurface resource(%p) seems inert.", subsurface_resource);
@@ -309,7 +309,7 @@ e_comp_wl_subsurface_commit(E_Client *ec)
    if (e_object_is_del(E_OBJECT(ec)) || !ec->comp_data) return EINA_FALSE;
 
    surface = e_surface_from_ec(ec);
-   sub = _e_subsurface_from_surface(surface);
+   sub = _e_subsurface_try_from_surface(surface);
    if (!sub)
      return EINA_FALSE;
 
@@ -493,7 +493,7 @@ e_surface_buffer_transform_set(E_Surface *surface, enum wl_output_transform tran
 
    surface->base.pending.buffer_viewport = *vp;
 
-   sub = _e_subsurface_from_surface(surface);
+   sub = _e_subsurface_try_from_surface(surface);
    if (sub)
      sub->base.cached.buffer_viewport = *vp;
 
@@ -536,7 +536,7 @@ e_surface_viewport_source_box_set(E_Surface *surface, Eina_Rectangle *box)
 
    surface->base.pending.buffer_viewport = *vp;
 
-   sub = _e_subsurface_from_surface(surface);
+   sub = _e_subsurface_try_from_surface(surface);
    if (sub)
      sub->base.cached.buffer_viewport = *vp;
 
@@ -564,7 +564,7 @@ e_surface_viewport_destination_set(E_Surface *surface, int32_t width, int32_t he
 
    surface->base.pending.buffer_viewport = *vp;
 
-   sub = _e_subsurface_from_surface(surface);
+   sub = _e_subsurface_try_from_surface(surface);
    if (sub)
      sub->base.cached.buffer_viewport = *vp;
 
@@ -639,10 +639,10 @@ e_surface_has_buffer(E_Surface *surface)
 }
 
 EINTERN E_Subsurface *
-e_subsurface_from_surface(E_Surface *surface)
+e_subsurface_try_from_surface(E_Surface *surface)
 {
    EINA_SAFETY_ON_NULL_RETURN_VAL(surface, NULL);
-   return _e_subsurface_from_surface(surface);
+   return _e_subsurface_try_from_surface(surface);
 }
 
 EINTERN E_Subsurface *
@@ -1003,7 +1003,7 @@ _e_surface_root_surface_get(E_Surface *surface)
    E_Surface *iter = surface;
    E_Subsurface *sub;
 
-   while ((sub = _e_subsurface_from_surface(iter)))
+   while ((sub = _e_subsurface_try_from_surface(iter)))
      iter = _e_surface_from_ds_surface(sub->ds_subsurface->parent);
 
    return iter;
@@ -1035,7 +1035,7 @@ _e_surface_pending_buffer_update(E_Surface *surface)
 
    if (ds_surface->buffer)
      {
-        buffer = e_comp_wl_buffer_get(ds_surface->buffer);
+        buffer = e_comp_wl_buffer_try_get(ds_surface->buffer);
         if (buffer)
           _e_surface_buffer_video_content_type_check_and_set(surface, buffer);
      }
@@ -1304,7 +1304,7 @@ _e_surface_pending_subsurface_order_update(E_Surface *surface)
                     &ds_surface->pending.subsurfaces_above,
                     pending.link)
      {
-        sub = _e_subsurface_from_ds_subsurface(ds_subsurface);
+        sub = _e_subsurface_try_from_ds_subsurface(ds_subsurface);
         surface->base.sub.list_pending =
            eina_list_append(surface->base.sub.list_pending, sub->surface->ec);
 
@@ -1318,7 +1318,7 @@ _e_surface_pending_subsurface_order_update(E_Surface *surface)
                     &ds_surface->pending.subsurfaces_below,
                     pending.link)
      {
-        sub = _e_subsurface_from_ds_subsurface(ds_subsurface);
+        sub = _e_subsurface_try_from_ds_subsurface(ds_subsurface);
         surface->base.sub.below_list_pending =
            eina_list_append(surface->base.sub.below_list_pending, sub->surface->ec);
 
@@ -1459,7 +1459,7 @@ _e_surface_cb_precommit_to_cache(struct wl_listener *listener, void *data)
    E_Subsurface *subsurface;
 
    surface = wl_container_of(listener, surface, precommit_to_cache);
-   subsurface = _e_subsurface_from_surface(surface);
+   subsurface = _e_subsurface_try_from_surface(surface);
 
    wl_signal_emit(&surface->events.precommit_to_cache, surface);
 
@@ -1479,7 +1479,7 @@ _e_surface_cb_precommit_from_cache(struct wl_listener *listener, void *data)
    E_Subsurface *subsurface;
 
    surface = wl_container_of(listener, surface, precommit_from_cache);
-   subsurface = _e_subsurface_from_surface(surface);
+   subsurface = _e_subsurface_try_from_surface(surface);
 
    wl_signal_emit(&surface->events.precommit_from_cache, surface);
 
@@ -1646,7 +1646,7 @@ _e_subsurface_destroy(E_Subsurface *sub)
 }
 
 static E_Subsurface *
-_e_subsurface_from_ds_subsurface(struct ds_subsurface *ds_subsurface)
+_e_subsurface_try_from_ds_subsurface(struct ds_subsurface *ds_subsurface)
 {
    struct wl_listener *listener;
    E_Subsurface *sub = NULL;
@@ -1660,7 +1660,7 @@ _e_subsurface_from_ds_subsurface(struct ds_subsurface *ds_subsurface)
 }
 
 static E_Subsurface *
-_e_subsurface_from_surface(E_Surface *surface)
+_e_subsurface_try_from_surface(E_Surface *surface)
 {
    struct ds_subsurface *ds_subsurface;
 
@@ -1671,11 +1671,11 @@ _e_subsurface_from_surface(E_Surface *surface)
    if (!ds_subsurface)
      return NULL;
 
-   return _e_subsurface_from_ds_subsurface(ds_subsurface);
+   return _e_subsurface_try_from_ds_subsurface(ds_subsurface);
 }
 
 static E_Subsurface *
-_e_subsurface_from_resource(struct wl_resource *resource)
+_e_subsurface_try_from_resource(struct wl_resource *resource)
 {
    struct ds_subsurface *ds_subsurface;
 
@@ -1683,7 +1683,7 @@ _e_subsurface_from_resource(struct wl_resource *resource)
    if (!ds_subsurface)
      return NULL;
 
-   return _e_subsurface_from_ds_subsurface(ds_subsurface);
+   return _e_subsurface_try_from_ds_subsurface(ds_subsurface);
 }
 
 static Eina_Bool
@@ -1868,7 +1868,7 @@ e_subsurface_from_resource(struct wl_resource *resource)
 {
    E_Subsurface *subsurface;
 
-   subsurface = _e_subsurface_from_resource(resource);
+   subsurface = _e_subsurface_try_from_resource(resource);
    assert(subsurface);
 
    return subsurface;
@@ -1931,7 +1931,7 @@ e_subsurface_surface_get(E_Subsurface *subsurface)
 }
 
 EINTERN E_Surface *
-e_subsurface_parent_get(E_Subsurface *subsurface)
+e_subsurface_parent_try_get(E_Subsurface *subsurface)
 {
    return subsurface->parent;
 }
index 4808e71..7b28257 100644 (file)
@@ -45,7 +45,7 @@ Eina_Bool e_surface_is_mapped(E_Surface *surface);
 
 E_Subsurface *e_subsurface_create(struct wl_resource *factory_resource, uint32_t id, E_Surface *surface, E_Surface *parent);
 E_Subsurface *e_subsurface_from_resource(struct wl_resource *resource);
-E_Subsurface *e_subsurface_from_surface(E_Surface *surface);
+E_Subsurface *e_subsurface_try_from_surface(E_Surface *surface);
 E_Subsurface *e_subsurface_from_ec(E_Client *ec);
 Eina_Bool e_subsurface_position_set(E_Subsurface *subsurface, int x, int y);
 void e_subsurface_destroy_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
@@ -54,7 +54,7 @@ void e_subsurface_stand_alone_mode_set(E_Subsurface *sub);
 void e_subsurface_stand_alone_mode_unset(E_Subsurface *sub);
 void e_subsurface_coord_get(E_Subsurface *subsurface, int *x, int *y);
 E_Surface *e_subsurface_surface_get(E_Subsurface *subsurface);
-E_Surface *e_subsurface_parent_get(E_Subsurface *subsurface);
+E_Surface *e_subsurface_parent_try_get(E_Subsurface *subsurface);
 void e_subsurface_view_position_set(E_Subsurface *subsurface, int x, int y);
 void e_subsurface_view_reposition(E_Subsurface *subsurface);
 
index be059ae..17533b1 100644 (file)
@@ -562,7 +562,7 @@ _viewport_export_handle_generate(E_Video_Viewport *viewport)
 static void
 _viewport_name_init(E_Video_Viewport *viewport)
 {
-   E_Surface *parent_surface = e_subsurface_parent_get(viewport->subsurface);
+   E_Surface *parent_surface = e_subsurface_parent_try_get(viewport->subsurface);
    E_Client *parent_ec = e_surface_ec_get(parent_surface);
    char name[256];
 
@@ -614,7 +614,7 @@ _video_shell_cb_export_viewport(struct wl_client *client, struct wl_resource *re
    viewport->reposition.notify = _viewport_cb_reposition;
    e_subsurface_reposition_listener_add(viewport->subsurface, &viewport->reposition);
 
-   parent_surface = e_subsurface_parent_get(viewport->subsurface);
+   parent_surface = e_subsurface_parent_try_get(viewport->subsurface);
 
    viewport->parent_map.notify = _viewport_cb_parent_map;
    e_surface_map_listener_add(parent_surface, &viewport->parent_map);
@@ -1199,7 +1199,7 @@ _video_surface_name_update(E_Video_Surface *surface)
 
    if (surface->role == E_VIDEO_SURFACE_ROLE_SUBSURFACE)
      {
-        ec = e_surface_ec_get(e_subsurface_parent_get(surface->subsurface));
+        ec = e_surface_ec_get(e_subsurface_parent_try_get(surface->subsurface));
         snprintf(suffix, sizeof(suffix), "VS::Subsurface(Parent 0x%08zx)", e_log_client_util_win_get(ec));
      }
    else if (surface->role == E_VIDEO_SURFACE_ROLE_VIEWPORT_SOURCE)
@@ -1868,7 +1868,7 @@ _viewport_info_print(E_Video_Viewport *viewport, FILE *fp)
    fprintf(fp, "\ttransform: %s\n", _viewport_transform_to_str(viewport->current.transform));
    fprintf(fp, "\tmap: %s\n", viewport->current.map ? "true" :  "false");
 
-   ec = e_surface_ec_get(e_subsurface_parent_get(viewport->subsurface));
+   ec = e_surface_ec_get(e_subsurface_parent_try_get(viewport->subsurface));
    name = (char *)e_client_netwm_name_get(ec);
    if (!name)
      name = (char *)e_client_icccm_title_get(ec);
@@ -2057,7 +2057,7 @@ _viewport_border_init(E_Video_Viewport *viewport)
    evas_object_layer_set(viewport->border, evas_object_layer_get(ec->frame));
    evas_object_stack_above(viewport->border, ec->frame);
 
-   parent_ec = e_surface_ec_get(e_subsurface_parent_get(viewport->subsurface));
+   parent_ec = e_surface_ec_get(e_subsurface_parent_try_get(viewport->subsurface));
    if (evas_object_visible_get(parent_ec->frame))
      evas_object_show(viewport->border);
 
@@ -2080,7 +2080,7 @@ _viewport_border_finish(E_Video_Viewport *viewport)
    else
      ec = e_surface_ec_get(e_subsurface_surface_get(viewport->subsurface));
 
-   parent_surface = e_subsurface_parent_get(viewport->subsurface);
+   parent_surface = e_subsurface_parent_try_get(viewport->subsurface);
    if (parent_surface)
      {
         parent_ec = e_surface_ec_get(parent_surface);