summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2014-08-18 10:38:48 +0200
committerPeter Harris <pharris@opentext.com>2014-08-25 19:15:34 -0400
commitb0e6c2de09c7474868dd7185674fa113a5c2e0aa (patch)
tree72967b3fbc9ebfe2f88c4466645a61e8c52d6ba6 /src
parentc4e40f646b8da4fd112ea54a612c880be5e942a8 (diff)
xcb_get_setup(): Never return NULL
The documentation doesn't mention it and it's unlikely that a lot of code out there handles this case correctly. So, instead of returning NULL, let xcb_get_setup() return a pointer to a static, invalid, all-zero setup information structure. Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src')
-rw-r--r--src/xcb_conn.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/xcb_conn.c b/src/xcb_conn.c
index 15f707a..7d09637 100644
--- a/src/xcb_conn.c
+++ b/src/xcb_conn.c
@@ -64,6 +64,26 @@ typedef struct {
uint16_t length;
} xcb_setup_generic_t;
+static const xcb_setup_t xcb_error_setup = {
+ 0, /* status: failed (but we wouldn't have a xcb_setup_t in this case) */
+ 0, /* pad0 */
+ 0, 0, /* protocol version, should be 11.0, but isn't */
+ 0, /* length, invalid value */
+ 0, /* release_number */
+ 0, 0, /* resource_id_{base,mask} */
+ 0, /* motion_buffer_size */
+ 0, /* vendor_len */
+ 0, /* maximum_request_length */
+ 0, /* roots_len */
+ 0, /* pixmap_formats_len */
+ 0, /* image_byte_order */
+ 0, /* bitmap_format_bit_order */
+ 0, /* bitmap_format_scanline_unit */
+ 0, /* bitmap_format_scanline_pad */
+ 0, 0, /* {min,max}_keycode */
+ { 0, 0, 0, 0 } /* pad1 */
+};
+
/* Keep this list in sync with is_static_error_conn()! */
static const int xcb_con_error = XCB_CONN_ERROR;
static const int xcb_con_closed_mem_er = XCB_CONN_CLOSED_MEM_INSUFFICIENT;
@@ -289,7 +309,7 @@ static int write_vec(xcb_connection_t *c, struct iovec **vector, int *count)
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c)
{
if(is_static_error_conn(c))
- return 0;
+ return &xcb_error_setup;
/* doesn't need locking because it's never written to. */
return c->setup;
}