[Intel-gfx] [PATCH] drm/i915/selftests: Always initialise err

Pandiyan, Dhinakaran dhinakaran.pandiyan at intel.com
Tue Nov 14 21:59:31 UTC 2017


On Tue, 2017-11-14 at 19:47 +0000, Chris Wilson wrote:
> smatch does not track initialised values as well as gcc, and this
> triggers many warnings by smatch not presented by gcc. Silence smatch by
> initialising the error values to -ENODEV, which we use to denote
> internal errors. (If we see a selftest fail with a silent -ENODEV, we
> know smatch was right!)
> 

The missed initialization in igt_vma_create() looks genuine.

> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/selftests/i915_gem_context.c  | 2 +-
>  drivers/gpu/drm/i915/selftests/i915_gem_gtt.c      | 8 ++++----
>  drivers/gpu/drm/i915/selftests/i915_gem_request.c  | 2 +-
>  drivers/gpu/drm/i915/selftests/i915_gem_timeline.c | 2 +-
>  drivers/gpu/drm/i915/selftests/i915_syncmap.c      | 6 +++---
>  drivers/gpu/drm/i915/selftests/i915_vma.c          | 2 +-
>  6 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_context.c b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> index 61fcfa2c4dfd..664d1b4f8c69 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_context.c
> @@ -321,7 +321,7 @@ static int igt_ctx_exec(void *arg)
>  	LIST_HEAD(objects);
>  	unsigned long ncontexts, ndwords, dw;
>  	bool first_shared_gtt = true;
> -	int err;
> +	int err = -ENODEV;
>  
>  	/* Create a few different contexts (with different mm) and write
>  	 * through each ctx/mm using the GPU making sure those writes end
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> index 581296860539..d9560d8a6cc8 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c
> @@ -699,7 +699,7 @@ static int drunk_hole(struct drm_i915_private *i915,
>  		unsigned int *order, count, n;
>  		struct i915_vma *vma;
>  		u64 hole_size;
> -		int err;
> +		int err = -ENODEV;

The goto label in this function is also named err, the function does
seem drunk.

>  
>  		hole_size = (hole_end - hole_start) >> size;
>  		if (hole_size > KMALLOC_MAX_SIZE / sizeof(u32))

<snip>

> diff --git a/drivers/gpu/drm/i915/selftests/i915_vma.c b/drivers/gpu/drm/i915/selftests/i915_vma.c
> index 2e86ec136b35..19ad42974431 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_vma.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_vma.c
> @@ -150,7 +150,7 @@ static int igt_vma_create(void *arg)
>  	IGT_TIMEOUT(end_time);
>  	LIST_HEAD(contexts);
>  	LIST_HEAD(objects);
> -	int err;
> +	int err = -ENODEV;
>  
>  	/* Exercise creating many vma amonst many objections, checking the
>  	 * vma creation and lookup routines.


More information about the Intel-gfx mailing list