diff options
author | Simon Ser <contact@emersion.fr> | 2022-10-13 17:30:06 +0200 |
---|---|---|
committer | Alexander Orzechowski <orzechowski.alexander@gmail.com> | 2022-10-13 16:11:39 +0000 |
commit | 0c0cea02587f5f31c88c4af75fcf082843b24b85 (patch) | |
tree | cd01139704baae3919da386b1202f952d683387a /backend/drm | |
parent | ada6f104e63dc270bb979cffba555aad0318e90d (diff) |
backend/drm: use wl_container_of() instead of casts for wlr_drm_mode
Instead of casting a wlr_output_mode to wlr_drm_mode, use
wl_container_of() for slightly better type safety.
Diffstat (limited to 'backend/drm')
-rw-r--r-- | backend/drm/drm.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 60e49db6..d5e6c21e 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -391,7 +391,8 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state, if (base->committed & WLR_OUTPUT_STATE_MODE) { switch (base->mode_type) { case WLR_OUTPUT_STATE_MODE_FIXED:; - struct wlr_drm_mode *mode = (struct wlr_drm_mode *)base->mode; + struct wlr_drm_mode *mode = + wl_container_of(base->mode, mode, wlr_mode); state->mode = mode->drm_mode; break; case WLR_OUTPUT_STATE_MODE_CUSTOM: @@ -403,7 +404,7 @@ static void drm_connector_state_init(struct wlr_drm_connector_state *state, } } else if (state->active) { struct wlr_drm_mode *mode = - (struct wlr_drm_mode *)conn->output.current_mode; + wl_container_of(conn->output.current_mode, mode, wlr_mode); assert(mode != NULL); state->mode = mode->drm_mode; } @@ -714,7 +715,7 @@ struct wlr_output_mode *wlr_drm_connector_add_mode(struct wlr_output *output, struct wlr_output_mode *wlr_mode; wl_list_for_each(wlr_mode, &conn->output.modes, link) { - struct wlr_drm_mode *mode = (struct wlr_drm_mode *)wlr_mode; + struct wlr_drm_mode *mode = wl_container_of(wlr_mode, mode, wlr_mode); if (memcmp(&mode->drm_mode, modeinfo, sizeof(*modeinfo)) == 0) { return wlr_mode; } |