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);
+ }
+ if (psc->fd < 0) {
+ ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
+ goto handle_error;
+ }
+
psc->driver = driOpenDriver(driverName);
if (psc->driver == NULL) {
ErrorMessageF("driver pointer missing\n");
goto handle_error;
}
-#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);
- }
- if (psc->fd < 0) {
- ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
- goto handle_error;
- }
-
if (drmGetMagic(psc->fd, &magic)) {
ErrorMessageF("failed to get magic\n");
goto handle_error;