From 29c8a4a4cec1e7eb31df4a7218f2bd09854a8374 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Mon, 21 Nov 2016 13:46:52 +0000 Subject: [PATCH] auxiliary/vl/dri: call get_xcb_screen() only once Signed-off-by: Emil Velikov Reviewed-by: Eric Engestrom --- src/gallium/auxiliary/vl/vl_winsys_dri.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c index 9ecc216b9c5..0b2c939389a 100644 --- a/src/gallium/auxiliary/vl/vl_winsys_dri.c +++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c @@ -326,6 +326,7 @@ vl_dri2_screen_create(Display *display, int screen) xcb_dri2_authenticate_cookie_t authenticate_cookie; xcb_dri2_authenticate_reply_t *authenticate = NULL; xcb_screen_iterator_t s; + xcb_screen_t *xcb_screen; xcb_generic_error_t *error = NULL; char *device_name; int fd, device_name_length; @@ -357,6 +358,9 @@ vl_dri2_screen_create(Display *display, int screen) goto free_query; s = xcb_setup_roots_iterator(xcb_get_setup(scrn->conn)); + xcb_screen = get_xcb_screen(s, screen); + if (!xcb_screen) + goto free_query; driverType = XCB_DRI2_DRIVER_TYPE_DRI; #ifdef DRI2DriverPrimeShift @@ -374,7 +378,7 @@ vl_dri2_screen_create(Display *display, int screen) #endif connect_cookie = xcb_dri2_connect_unchecked(scrn->conn, - get_xcb_screen(s, screen)->root, + xcb_screen->root, driverType); connect = xcb_dri2_connect_reply(scrn->conn, connect_cookie, NULL); if (connect == NULL || @@ -396,7 +400,7 @@ vl_dri2_screen_create(Display *display, int screen) goto close_fd; authenticate_cookie = xcb_dri2_authenticate_unchecked(scrn->conn, - get_xcb_screen(s, screen)->root, + xcb_screen->root, magic); authenticate = xcb_dri2_authenticate_reply(scrn->conn, authenticate_cookie, NULL); -- 2.30.2