[igt-dev] [PATCH i-g-t 03/21] lib/ioctl_wrappers: Help static analysis with execution flow

Petri Latvala petri.latvala at intel.com
Wed Jan 16 11:20:32 UTC 2019


If an ioctl fails, errno is set to non-zero, and static analysis
doesn't quite get it. Add igt_assume()s where applicable.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: MichaƂ Winiarski <michal.winiarski at intel.com>
---
 lib/ioctl_wrappers.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 9f255508..3fb57893 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -549,8 +549,10 @@ int __gem_create(int fd, uint64_t size, uint32_t *handle)
 
 	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &create) == 0)
 		*handle = create.handle;
-	else
+	else {
 		err = -errno;
+		igt_assume(err != 0);
+	}
 
 	errno = 0;
 	return err;
@@ -586,8 +588,10 @@ uint32_t gem_create(int fd, uint64_t size)
 int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
 {
 	int err = 0;
-	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf))
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf)) {
 		err = -errno;
+		igt_assume(err != 0);
+	}
 	errno = 0;
 	return err;
 }
@@ -616,8 +620,10 @@ void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
 int __gem_execbuf_wr(int fd, struct drm_i915_gem_execbuffer2 *execbuf)
 {
 	int err = 0;
-	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf))
+	if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2_WR, execbuf)) {
 		err = -errno;
+		igt_assume(err != 0);
+	}
 	errno = 0;
 	return err;
 }
-- 
2.19.1



More information about the igt-dev mailing list