Mesa (master): egl_dri2: Check for xcb_connect() failure the right way

Kristian Høgsberg krh at kemper.freedesktop.org
Sat May 29 01:32:38 UTC 2010


Module: Mesa
Branch: master
Commit: c5ddaa2cd71c100fe4aa6da36b6ac1a59e6665e3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c5ddaa2cd71c100fe4aa6da36b6ac1a59e6665e3

Author: Kristian Høgsberg <krh at bitplanet.net>
Date:   Fri May 28 15:50:11 2010 -0400

egl_dri2: Check for xcb_connect() failure the right way

It always returns a valid xcb_connection_t, but if connection failed, it's in the
error state.

---

 src/egl/drivers/dri2/egl_dri2.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index eb9a651..a9c9b98 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -647,16 +647,14 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
    disp->DriverData = (void *) dri2_dpy;
    if (disp->NativeDisplay == NULL) {
       dri2_dpy->conn = xcb_connect(0, 0);
-      if (!dri2_dpy->conn) {
-	 _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
-	 goto cleanup_dpy;
-      }
    } else {
       dri2_dpy->conn = XGetXCBConnection(disp->NativeDisplay);
    }
 
-   if (dri2_dpy->conn == NULL)
-      goto cleanup_conn;
+   if (xcb_connection_has_error(dri2_dpy->conn)) {
+      _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed");
+      goto cleanup_dpy;
+   }
 
    if (dri2_dpy->conn) {
       if (!dri2_connect(dri2_dpy))




More information about the mesa-commit mailing list