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

Chris Wilson chris at chris-wilson.co.uk
Wed Jan 16 14:22:14 UTC 2019


Quoting Petri Latvala (2019-01-16 11:20:31)
> 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.
> 
> 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/i915/gem_context.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/i915/gem_context.c b/lib/i915/gem_context.c
> index 669bd318..781dea00 100644
> --- a/lib/i915/gem_context.c
> +++ b/lib/i915/gem_context.c
> @@ -82,8 +82,10 @@ int __gem_context_create(int fd, uint32_t *ctx_id)
>         memset(&create, 0, sizeof(create));
>         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);
> +       }

Just make sure each branch takes { } and
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
for the three (or how many nearly identical patches it was!).
-Chris


More information about the igt-dev mailing list