diff options
author | Simon Ser <contact@emersion.fr> | 2023-07-11 17:54:08 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-07-11 20:16:17 +0200 |
commit | fe06e5f49a12174ceeb5e307bf5c3d7f623177d5 (patch) | |
tree | 40984fb21cd0cbf6be531206a86167298ab2d537 /render/gles2 | |
parent | c2c536de034cc27d3a15001cc478f5a327b8f910 (diff) |
Use wl_container_of() instead of casts
This slightly improves type safety.
The culprits were found with:
git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
Diffstat (limited to 'render/gles2')
-rw-r--r-- | render/gles2/renderer.c | 5 | ||||
-rw-r--r-- | render/gles2/texture.c | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 9cbc646e..2b6c04b9 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -45,7 +45,8 @@ bool wlr_renderer_is_gles2(struct wlr_renderer *wlr_renderer) { struct wlr_gles2_renderer *gles2_get_renderer( struct wlr_renderer *wlr_renderer) { assert(wlr_renderer_is_gles2(wlr_renderer)); - return (struct wlr_gles2_renderer *)wlr_renderer; + struct wlr_gles2_renderer *renderer = wl_container_of(wlr_renderer, renderer, wlr_renderer); + return renderer; } static struct wlr_gles2_renderer *gles2_get_renderer_in_context( @@ -634,7 +635,7 @@ static int gles2_get_render_time(struct wlr_render_timer *wlr_timer) { } static void gles2_render_timer_destroy(struct wlr_render_timer *wlr_timer) { - struct wlr_gles2_render_timer *timer = (struct wlr_gles2_render_timer *)wlr_timer; + struct wlr_gles2_render_timer *timer = wl_container_of(wlr_timer, timer, base); struct wlr_gles2_renderer *renderer = timer->renderer; struct wlr_egl_context prev_ctx; diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 4f884d73..6cfd103d 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -25,7 +25,8 @@ bool wlr_texture_is_gles2(struct wlr_texture *wlr_texture) { struct wlr_gles2_texture *gles2_get_texture( struct wlr_texture *wlr_texture) { assert(wlr_texture_is_gles2(wlr_texture)); - return (struct wlr_gles2_texture *)wlr_texture; + struct wlr_gles2_texture *texture = wl_container_of(wlr_texture, texture, wlr_texture); + return texture; } static bool gles2_texture_update_from_buffer(struct wlr_texture *wlr_texture, |