[Mesa-dev] [PATCH 7/7] egl/drm: set eglError and provide an error message on failure

Eric Engestrom eric at engestrom.ch
Thu Aug 25 21:44:54 UTC 2016


On Thu, Aug 25, 2016 at 05:23:46PM +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/egl/drivers/dri2/platform_drm.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
> index aa9a186..df711cf 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -657,6 +657,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
>  {
>     struct dri2_egl_display *dri2_dpy;
>     struct gbm_device *gbm;
> +   const char *err;
>     int fd = -1;
>  
>     loader_set_logger(_eglLog);
> @@ -677,20 +678,28 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
>           fd = loader_open_device("/dev/dri/card0");
>        dri2_dpy->own_device = 1;
>        gbm = gbm_create_device(fd);
> -      if (gbm == NULL)
> +      if (gbm == NULL) {
> +         err = "DRI2: failed to create gbm device";
>           goto cleanup;
> +      }
>     } else {
>        fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
> -      if (fd < 0)
> +      if (fd < 0) {
> +         err = "DRI2: failed to fcntl() existing gbm device";
>           goto cleanup;
> +      }
>     }
>  
> -   if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0)
> +   if (strcmp(gbm_device_get_backend_name(gbm), "drm") != 0) {
> +      err = "DRI2: gbm device using incorrect/incompatible backend";
>        goto cleanup;
> +   }
>  
>     dri2_dpy->gbm_dri = gbm_dri_device(gbm);
> -   if (dri2_dpy->gbm_dri->base.type != GBM_DRM_DRIVER_TYPE_DRI)
> +   if (dri2_dpy->gbm_dri->base.type != GBM_DRM_DRIVER_TYPE_DRI) {
> +      err = "DRI2: gbm device using incorrect/incompatible type";
>        goto cleanup;
> +   }
>  
>     dri2_dpy->fd = fd;
>     dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd);
> @@ -721,7 +730,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
>     dri2_setup_screen(disp);
>  
>     if (!drm_add_configs_for_visuals(drv, disp)) {
> -      _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs");
> +      err = "DRI2: failed to add configs";
>        goto cleanup;
>     }
>  
> @@ -744,5 +753,6 @@ cleanup:
>  
>     free(dri2_dpy);
>     disp->DriverData = NULL;
> -   return EGL_FALSE;
> +   return _eglError(EGL_NOT_INITIALIZED, err);
> +;

Stray char.

Reviewed-by: Eric Engestrom <eric at engestrom.ch>

>  }
> -- 
> 2.9.0


More information about the mesa-dev mailing list