misc: xcb_connect() always returns a non-NULL pointer

Instead, we need to check if xcb_connection_has_error() says something
went wrong. We also need to call xcb_disconnect() on the disfunctional
XCB connection object.
This commit is contained in:
Daniel Eklöf 2019-01-19 18:45:15 +01:00
parent 406d6b3b83
commit 9d5bbe0566
5 changed files with 29 additions and 11 deletions

View file

@ -376,7 +376,13 @@ run(struct module *mod)
struct sockaddr_un addr = {.sun_family = AF_UNIX};
{
xcb_connection_t *conn = xcb_connect(NULL, NULL);
int default_screen;
xcb_connection_t *conn = xcb_connect(NULL, &default_screen);
if (xcb_connection_has_error(conn) > 0) {
LOG_ERR("failed to connect to X");
xcb_disconnect(conn);
return 1;
}
const xcb_setup_t *setup = xcb_get_setup(conn);
xcb_screen_t *screen = xcb_setup_roots_iterator(setup).data;