egl_dri2: Check for xcb_connect() failure the right way
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 28 May 2010 19:50:11 +0000 (15:50 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Sat, 29 May 2010 01:31:22 +0000 (21:31 -0400)
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

index eb9a6510ed0c282c27d581d8cd3d7e96d080a892..a9c9b986cc530c5a89a0acf418d75322aaf38ed6 100644 (file)
@@ -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))