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/vulkan | |
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/vulkan')
-rw-r--r-- | render/vulkan/renderer.c | 3 | ||||
-rw-r--r-- | render/vulkan/texture.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c index 76da79fe..4419cf2c 100644 --- a/render/vulkan/renderer.c +++ b/render/vulkan/renderer.c @@ -52,7 +52,8 @@ bool wlr_renderer_is_vk(struct wlr_renderer *wlr_renderer) { struct wlr_vk_renderer *vulkan_get_renderer(struct wlr_renderer *wlr_renderer) { assert(wlr_renderer_is_vk(wlr_renderer)); - return (struct wlr_vk_renderer *)wlr_renderer; + struct wlr_vk_renderer *renderer = wl_container_of(wlr_renderer, renderer, wlr_renderer); + return renderer; } static struct wlr_vk_render_format_setup *find_or_create_render_setup( diff --git a/render/vulkan/texture.c b/render/vulkan/texture.c index 083931ff..a72124d2 100644 --- a/render/vulkan/texture.c +++ b/render/vulkan/texture.c @@ -22,7 +22,8 @@ bool wlr_texture_is_vk(struct wlr_texture *wlr_texture) { struct wlr_vk_texture *vulkan_get_texture(struct wlr_texture *wlr_texture) { assert(wlr_texture_is_vk(wlr_texture)); - return (struct wlr_vk_texture *)wlr_texture; + struct wlr_vk_texture *texture = wl_container_of(wlr_texture, texture, wlr_texture); + return texture; } static VkImageAspectFlagBits mem_plane_aspect(unsigned i) { |