[PATCH Xlib 2/3] Improve connection error handling

Mike Blumenkrantz zmike at samsung.com
Thu Jun 11 11:25:21 PDT 2015


From: Josh Triplett <josh at joshtriplett.org>

Make _XConnectXCB translate error connections to NULL.

Also, call xcb_disconnect on the error path.

Commit by Josh Triplett and Jamey Sharp.

Signed-off-by: Josh Triplett <josh at joshtriplett.org>
Signed-off-by: Jamey Sharp <jamey at minilop.net>
Signed-off-by: Mike Blumenkrantz <zmike at osg.samsung.com>
---
 src/OpenDis.c  | 3 +--
 src/xcb_disp.c | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/OpenDis.c b/src/OpenDis.c
index 8f6d1ef..509060e 100644
--- a/src/OpenDis.c
+++ b/src/OpenDis.c
@@ -115,8 +115,7 @@ XOpenDisplay (
  * If NULL is returned, the connection failed.
  */
 
-	c = _XConnectXCB(display, &iscreen);
-	if(!c || xcb_connection_has_error(c)) {
+	if(!(c = _XConnectXCB(display, &iscreen))) {
 		return NULL;
 	}
 
diff --git a/src/xcb_disp.c b/src/xcb_disp.c
index 74f87c0..9ff650e 100644
--- a/src/xcb_disp.c
+++ b/src/xcb_disp.c
@@ -72,5 +72,9 @@ xcb_connection_t *_XConnectXCB(_Xconst char *display,
int *screenp) c = xcb_connect(display, NULL);
 	_XUnlockMutex(_Xglobal_lock);
 
+	if(xcb_connection_has_error(c)) {
+		xcb_disconnect(c);
+		return NULL;
+	}
 	return c;
 }
-- 
2.4.2



More information about the xorg-devel mailing list