From 382ea6837dc4d62d9a3fa039a06ce08837583b19 Mon Sep 17 00:00:00 2001 From: Hannes Winkler Date: Mon, 16 Sep 2024 20:01:42 +0000 Subject: [PATCH] only report error from `gbm_surface_create_with_modifiers` if `gbm_surface_create` fails too --- src/egl_gbm_render_surface.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/egl_gbm_render_surface.c b/src/egl_gbm_render_surface.c index c8dd764a..cf3750de 100644 --- a/src/egl_gbm_render_surface.c +++ b/src/egl_gbm_render_surface.c @@ -146,6 +146,7 @@ static int egl_gbm_render_surface_init( } #endif + int with_modifiers_errno; gbm_surface = NULL; if (allowed_modifiers != NULL) { gbm_surface = gbm_surface_create_with_modifiers( @@ -157,11 +158,10 @@ static int egl_gbm_render_surface_init( n_allowed_modifiers ); if (gbm_surface == NULL) { - ok = errno; - LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s\n", strerror(ok)); - LOG_ERROR("Will retry without modifiers\n"); + with_modifiers_errno = errno; } } + if (gbm_surface == NULL) { gbm_surface = gbm_surface_create( gbm_device, @@ -171,8 +171,17 @@ static int egl_gbm_render_surface_init( GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT ); if (gbm_surface == NULL) { - ok = errno; - LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok)); + ok = errno ? errno : EIO; + if (allowed_modifiers != NULL) { + LOG_ERROR( + "Couldn't create GBM surface for rendering. gbm_surface_create_with_modifiers: %s, gbm_surface_create: %s\n", + strerror(with_modifiers_errno), + strerror(ok) + ); + } else { + LOG_ERROR("Couldn't create GBM surface for rendering. gbm_surface_create: %s\n", strerror(ok)); + } + return ok; } }