summaryrefslogtreecommitdiff
path: root/lib/igt_debugfs.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-03-21 15:48:49 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-03-21 15:50:13 +0000
commitba6d0dce2c3afa26a1dd3ceed024e281395cc7ce (patch)
treeda48731b5c6817479e1bb2c51319c09b2a11abe9 /lib/igt_debugfs.c
parent301ad44cdf1b868b1ab89096721da91fa8541fdc (diff)
lib/debugfs: Only inspect errno after a confirmed error
The contents of errno are strictly only valid after a syscall (or library function) reported an error. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_debugfs.c')
-rw-r--r--lib/igt_debugfs.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 628443a1..629bbddf 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -366,20 +366,25 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
else
sprintf(buf, "%s", pipe_crc_source_name(pipe_crc->source));
- errno = 0;
igt_assert_eq(write(pipe_crc->ctl_fd, buf, strlen(buf)), strlen(buf));
- if (errno != 0)
- return false;
if (!pipe_crc->is_legacy) {
+ int err;
+
sprintf(buf, "crtc-%d/crc/data", pipe_crc->pipe);
- errno = 0;
+ err = 0;
+
pipe_crc->crc_fd = igt_debugfs_open(pipe_crc->fd, buf, pipe_crc->flags);
- if (pipe_crc->crc_fd == -1 && errno == EINVAL)
+ if (pipe_crc->crc_fd < 0)
+ err = -errno;
+
+ if (err == -EINVAL)
return false;
- igt_assert_eq(errno, 0);
+
+ igt_assert_eq(err, 0);
}
+ errno = 0;
return true;
}