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>
This commit is contained in:
parent
c4e40f646b
commit
b0e6c2de09
|
@ -64,6 +64,26 @@ typedef struct {
|
||||||
uint16_t length;
|
uint16_t length;
|
||||||
} xcb_setup_generic_t;
|
} 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()! */
|
/* Keep this list in sync with is_static_error_conn()! */
|
||||||
static const int xcb_con_error = XCB_CONN_ERROR;
|
static const int xcb_con_error = XCB_CONN_ERROR;
|
||||||
static const int xcb_con_closed_mem_er = XCB_CONN_CLOSED_MEM_INSUFFICIENT;
|
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)
|
const xcb_setup_t *xcb_get_setup(xcb_connection_t *c)
|
||||||
{
|
{
|
||||||
if(is_static_error_conn(c))
|
if(is_static_error_conn(c))
|
||||||
return 0;
|
return &xcb_error_setup;
|
||||||
/* doesn't need locking because it's never written to. */
|
/* doesn't need locking because it's never written to. */
|
||||||
return c->setup;
|
return c->setup;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue