[Mesa-dev] [PATCH] Break instead of loop all paths once dri driver is gotten successfully

Quanxian Wang quanxian.wang at intel.com
Wed Dec 18 21:11:29 PST 2013


Originally it will continue all paths. The next search will overwrite previous
result even if the previous is successful. In some case it will cause error.

Signed-off-by: Quanxian Wang <quanxian.wang at intel.com>
Reviewed-By: Gong, Zhigang <zhigang.gong at gmail.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 3 +++
 src/gbm/backends/dri/gbm_dri.c  | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index e703f28..892f1f4 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -403,6 +403,9 @@ dri2_open_driver(_EGLDisplay *disp)
 	 if (dri2_dpy->driver == NULL)
 	    _eglLog(_EGL_DEBUG, "failed to open %s: %s\n", path, dlerror());
       }
+      /* not need continue to loop all paths once the driver is found */
+      if (dri2_dpy->driver != NULL)
+         break;
    }
 
    if (dri2_dpy->driver == NULL) {
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index b4b97ac..cd31221 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -224,9 +224,10 @@ dri_load_driver(struct gbm_dri_device *dri)
          snprintf(path, sizeof path,
                   "%.*s/%s_dri.so", len, p, dri->base.driver_name);
          dri->driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
-         if (dri->driver == NULL)
-            fprintf(stderr, "failed to open %s: %s\n", path, dlerror());
       }
+      /* not need continue to loop all paths once the driver is found */
+      if (dri->driver != NULL)
+         break;
    }
 
    if (dri->driver == NULL) {
-- 
1.8.1.2



More information about the mesa-dev mailing list