From 44c164bb350500c8231b59c1723eca0686a89b22 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 3 Jun 2014 05:44:53 +0200 Subject: fix errors in gamma-x-randr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/lib/gamma-x-randr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/gamma-x-randr.c b/src/lib/gamma-x-randr.c index af3fe50..7ca8674 100644 --- a/src/lib/gamma-x-randr.c +++ b/src/lib/gamma-x-randr.c @@ -192,7 +192,7 @@ int libgamma_x_randr_site_initialise(libgamma_site_state_t* restrict this, /* Connect to the display server. */ this->data = connection = xcb_connect(site, NULL); if (connection == NULL) - return LIBGAMMA_NO_SUCH_SITE; + return LIBGAMMA_OPEN_SITE_FAILED; /* Query the version of the X RandR extension protocol. */ cookie = xcb_randr_query_version(connection, RANDR_VERSION_MAJOR, RANDR_VERSION_MINOR); @@ -203,6 +203,10 @@ int libgamma_x_randr_site_initialise(libgamma_site_state_t* restrict this, { /* Release resources. */ free(reply); + /* If `xcb_connect` failed, both `error` and `reply` will be `NULL`. + XXX: Can both be `NULL` for any other reason? */ + if ((error == NULL) && (reply == NULL)) + return LIBGAMMA_OPEN_SITE_FAILED; xcb_disconnect(connection); /* Translate and report error. */ if (error != NULL) @@ -311,6 +315,7 @@ int libgamma_x_randr_partition_initialise(libgamma_partition_state_t* restrict t /* Get screen list. */ if ((setup = xcb_get_setup(connection)) == NULL) return LIBGAMMA_LIST_PARTITIONS_FAILED; + iter = xcb_setup_roots_iterator(setup); /* Get the screen. */ for (i = 0; iter.rem > 0; i++, xcb_screen_next(&iter)) -- cgit v1.2.3-70-g09d2