[igt-dev] [PATCH i-g-t v2 02/21] lib/i915/gem_context: Help static analysis with execution flow

Petri Latvala
2019-01-18T10:42:21Z

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

v2: Braces on both branches of an if (Chris)

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
lib/i915/gem_context.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c
index 669bd318..16004685 100644
--- a/lib/i915/gem_context.c
+++ b/lib/i915/gem_context.c
@@ -80,10 +80,12 @@ int __gem_context_create(int fd, uint32_t *ctx_id)
int err = 0;

memset(&create, 0, sizeof(create));
- if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) == 0)
+ if (igt_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE, &create) == 0) {
*ctx_id = create.ctx_id;
- else
- err = -errno;
+ } else {
+ err = -errno;
+ igt_assume(err != 0);
+ }

errno = 0;
return err;
--
2.19.1