From e10ba6b51c028ce945605d1f720c598c93e8ad8f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 25 Nov 2015 14:19:15 +0000 Subject: igt/drm_read: Clear O_NONBLOCK between tests Ensure that O_NONBLOCK isn't accidentally set when we want a nonblocking file descroptor. Signed-off-by: Chris Wilson --- tests/drm_read.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/drm_read.c') diff --git a/tests/drm_read.c b/tests/drm_read.c index d18cb55e..faa3df86 100644 --- a/tests/drm_read.c +++ b/tests/drm_read.c @@ -80,20 +80,21 @@ static void wait_for_event(int fd) static int setup(int in, int nonblock) { int fd; + int ret = -1; alarm(0); fd = dup(in); - if (nonblock) { - int ret = -1; - if (fd != -1) - ret = fcntl(fd, F_GETFL); - if (ret != -1) { + if (fd != -1) + ret = fcntl(fd, F_GETFL); + if (ret != -1) { + if (nonblock) ret |= O_NONBLOCK; - ret = fcntl(fd, F_SETFL, ret); - } - igt_require(ret != -1); + else + ret &= ~O_NONBLOCK; + ret = fcntl(fd, F_SETFL, ret); } + igt_require(ret != -1); assert_empty(fd); return fd; -- cgit v1.2.3