From 61903ed66beed175556101635e4936a9f51d74db Mon Sep 17 00:00:00 2001 From: JiDe Zhang Date: Tue, 25 Jul 2023 15:08:13 +0800 Subject: [PATCH] wlr_output_cursor: assert renderer isn't NULL When a wlr_output add to wlr_output_layout, wlr_cursor will create wlr_buffer of xcursor for the wlr_output, this behavior depends wlr_renderer of wlr_output, using assert to ensure renderer is initialized before wlr_output_layout_add and wlr_cursor_set_buffer/ wlr_cursor_set_xcursor. --- types/output/cursor.c | 4 +--- types/wlr_cursor.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/types/output/cursor.c b/types/output/cursor.c index c2510896..4d0cc19a 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -394,9 +394,7 @@ static bool output_cursor_attempt_hardware(struct wlr_output_cursor *cursor) { bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor, struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y) { struct wlr_renderer *renderer = cursor->output->renderer; - if (!renderer) { - return false; - } + assert(renderer != NULL); struct wlr_texture *texture = NULL; struct wlr_fbox src_box = {0}; diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c index aca43bee..e1fabe5d 100644 --- a/types/wlr_cursor.c +++ b/types/wlr_cursor.c @@ -509,9 +509,7 @@ static void cursor_output_cursor_update(struct wlr_cursor_output_cursor *output_ if (cur->state->buffer != NULL) { struct wlr_renderer *renderer = output_cursor->output_cursor->output->renderer; - if (!renderer) { - return; - } + assert(renderer != NULL); struct wlr_buffer *buffer = cur->state->buffer; int32_t hotspot_x = cur->state->buffer_hotspot.x;