egl: break instead of looping after driver is found
authorQuanxian Wang <quanxian.wang@intel.com>
Thu, 19 Dec 2013 05:11:00 +0000 (22:11 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 19 Dec 2013 19:44:11 +0000 (12:44 -0700)
Stop searching for a driver after success.

Signed-off-by: Quanxian Wang <quanxian.wang@intel.com>
Reviewed-By: Gong, Zhigang <zhigang.gong@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/egl/drivers/dri2/egl_dri2.c
src/gbm/backends/dri/gbm_dri.c

index e703f282c92bf5ecd431df5b8c6042d46c2cd6e2..892f1f4def787d4bd8b173b754c4c978ad495f7d 100644 (file)
@@ -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) {
index b4b97ac6a972d53f751b7ceb0e1342d9539ad25e..cd3122199eb6babfa635c1e35389d03d18699782 100644 (file)
@@ -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) {