Re: [PATCH 3/3] drm/i915/crt: Silence compiler warning for uninitialised status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 15, 2017 at 10:50:36AM +0000, Chris Wilson wrote:
> clang is confused by our if-else-chain that abruptly exits before a
> final else:
> 
> drivers/gpu/drm/i915/intel_crt.c:821:11: warning: variable 'status' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>         else if (ret < 0)
>                  ^~~~~~~
> drivers/gpu/drm/i915/intel_crt.c:826:9: note: uninitialized use occurs here
>         return status;
>                ^~~~~~
> drivers/gpu/drm/i915/intel_crt.c:821:7: note: remove the 'if' if its condition is always true
>         else if (ret < 0)
>              ^~~~~~~~~~~~
> drivers/gpu/drm/i915/intel_crt.c:761:12: note: initialize the variable 'status' to silence this warning
>         int status, ret;
> 
> In this case, we can reduce the final else-if clause to an unconditional else.
> 
> Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
> Cc: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/i915/intel_crt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
> index 9f31aea51dff..ae55afcbdc2c 100644
> --- a/drivers/gpu/drm/i915/intel_crt.c
> +++ b/drivers/gpu/drm/i915/intel_crt.c
> @@ -810,10 +810,11 @@ intel_crt_detect(struct drm_connector *connector,
>  		else
>  			status = connector_status_unknown;
>  		intel_release_load_detect_pipe(connector, &tmp, ctx);
> -	} else if (ret == 0)
> +	} else if (ret == 0) {
>  		status = connector_status_unknown;
> -	else if (ret < 0)
> +	} else {
>  		status = ret;
> +	}

Patch lgtm
Reviewed-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

On a somewhat related note, the return value of intel_get_load_detect_pipe()
is quite a mess. It's mixing ints and bools in a way that makes the whole
thing look very confusing. In the end it looks like like -EDEADLK is the
only error we can get here.

>  
>  out:
>  	intel_display_power_put(dev_priv, intel_encoder->power_domain);
> -- 
> 2.15.0

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux