[PATCH 3/5] compositor-rdp: Use non-cast functions to retrieve backend and output objects

Armin Krezović krezovic.armin at gmail.com
Mon Aug 1 17:17:56 UTC 2016


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ć <krezovic.armin at gmail.com>
---
 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 2a270d3..11f5f05 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);
-- 
2.9.2



More information about the wayland-devel mailing list