From 3e7ea8715bf6817bee847e3bc5816abf69242fc5 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 1 Oct 2022 17:49:27 +0200 Subject: [PATCH] render/allocator/drm_dumb: get format info before allocating Simplifies error handling a bit. --- render/allocator/drm_dumb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c index 27aa1a8d..024e5d4f 100644 --- a/render/allocator/drm_dumb.c +++ b/render/allocator/drm_dumb.c @@ -55,6 +55,14 @@ static struct wlr_drm_dumb_buffer *create_buffer( return NULL; } + const struct wlr_pixel_format_info *info = + drm_get_pixel_format_info(format->format); + if (info == NULL) { + wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported", + format->format); + return NULL; + } + struct wlr_drm_dumb_buffer *buffer = calloc(1, sizeof(*buffer)); if (buffer == NULL) { return NULL; @@ -62,14 +70,6 @@ static struct wlr_drm_dumb_buffer *create_buffer( wlr_buffer_init(&buffer->base, &buffer_impl, width, height); wl_list_insert(&alloc->buffers, &buffer->link); - const struct wlr_pixel_format_info *info = - drm_get_pixel_format_info(format->format); - if (info == NULL) { - wlr_log(WLR_ERROR, "DRM format 0x%"PRIX32" not supported", - format->format); - goto create_err; - } - struct drm_mode_create_dumb create = {0}; create.width = (uint32_t)width; create.height = (uint32_t)height;