From ba6d0dce2c3afa26a1dd3ceed024e281395cc7ce Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 21 Mar 2017 15:48:49 +0000 Subject: 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 --- lib/igt_debugfs.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/igt_debugfs.c') 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; } -- cgit v1.2.3