glx: Use loader_open_device() helper
authorDerek Foreman <derekf@osg.samsung.com>
Wed, 17 Jun 2015 16:28:50 +0000 (11:28 -0500)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 23 Jun 2015 15:54:53 +0000 (16:54 +0100)
We've moved the open with CLOEXEC idiom into a helper function, so
call it instead of duplicating the code here.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
src/glx/dri2_glx.c

index 538cf1adb828f45009b77dc5963fcc9ff3e6203d..27ea9521e50a68df780c047ad3ec9178089f05ea 100644 (file)
@@ -1183,15 +1183,7 @@ dri2CreateScreen(int screen, struct glx_display * priv)
       return NULL;
    }
 
-#ifdef O_CLOEXEC
-   psc->fd = open(deviceName, O_RDWR | O_CLOEXEC);
-   if (psc->fd == -1 && errno == EINVAL)
-#endif
-   {
-      psc->fd = open(deviceName, O_RDWR);
-      if (psc->fd != -1)
-         fcntl(psc->fd, F_SETFD, fcntl(psc->fd, F_GETFD) | FD_CLOEXEC);
-   }
+   psc->fd = loader_open_device(deviceName);
    if (psc->fd < 0) {
       ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
       goto handle_error;