summaryrefslogtreecommitdiff
path: root/src/xcbint.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-01-18 17:10:53 +0200
committerUli Schlachter <psychon@znc.in>2014-02-19 22:01:58 +0100
commit4ffa6f83b92763eb901c7ddb7c20775e24d507ca (patch)
treec94482763a0c3785fa196a4acf89f1bbbeb3a8c4 /src/xcbint.h
parentd7eb0bdf3b5b11ee9f40ee5e73df8fc0bdfa59f3 (diff)
Add comments about how _xcb_conn_ret_error() works
If xcb_connect() fails, it doesn't return NULL. Instead, it always returns an xcb_connection_t*, and the user should check for errors with the xcb_connection_has_error() function. What this function does is check if conn->has_error contains a non-zero error code, and returns it. If an error did occur, xcb doesn't actually return a full xcb_connection_t though, it just returns (xcb_connection_t *) error_code. Since the 'has_error' field is the first, it is still possible to check conn->has_error. That last trick was not immediately obvious to me, so add some guiding comments. This also ensures no one obliviously rearranges the struct. Signed-off-by: Ran Benita <ran234@gmail.com> Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src/xcbint.h')
-rw-r--r--src/xcbint.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/xcbint.h b/src/xcbint.h
index b25f03b..67cf571 100644
--- a/src/xcbint.h
+++ b/src/xcbint.h
@@ -192,6 +192,7 @@ void _xcb_ext_destroy(xcb_connection_t *c);
/* xcb_conn.c */
struct xcb_connection_t {
+ /* This must be the first field; see _xcb_conn_ret_error(). */
int has_error;
/* constant data */