From fb371c62c2b142493124206c1efb5bda4cbf0f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20Krezovi=C4=87?= Date: Mon, 1 Aug 2016 19:17:56 +0200 Subject: [PATCH] compositor-rdp: Use non-cast functions to retrieve backend and output objects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This uses container_of instead of explicit cast to retrieve backend and output objects from generic weston_backend and weston_output pointers. Signed-off-by: Armin Krezović Reviewed-by: Pekka Paalanen --- libweston/compositor-rdp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libweston/compositor-rdp.c b/libweston/compositor-rdp.c index 2a270d390..11f5f05bb 100644 --- a/libweston/compositor-rdp.c +++ b/libweston/compositor-rdp.c @@ -137,6 +137,18 @@ struct rdp_peer_context { }; typedef struct rdp_peer_context RdpPeerContext; +static inline struct rdp_output * +to_rdp_output(struct weston_output *base) +{ + return container_of(base, struct rdp_output, base); +} + +static inline struct rdp_backend * +to_rdp_backend(struct weston_compositor *base) +{ + return container_of(base->backend, struct rdp_backend, base); +} + static void rdp_peer_refresh_rfx(pixman_region32_t *damage, pixman_image_t *image, freerdp_peer *peer) { @@ -362,7 +374,7 @@ rdp_output_repaint(struct weston_output *output_base, pixman_region32_t *damage) static void rdp_output_destroy(struct weston_output *output_base) { - struct rdp_output *output = (struct rdp_output *)output_base; + struct rdp_output *output = to_rdp_output(output_base); wl_event_source_remove(output->finish_frame_timer); free(output); @@ -532,7 +544,7 @@ rdp_restore(struct weston_compositor *ec) static void rdp_destroy(struct weston_compositor *ec) { - struct rdp_backend *b = (struct rdp_backend *) ec->backend; + struct rdp_backend *b = to_rdp_backend(ec); int i; weston_compositor_shutdown(ec);