[PATCH 2/4] drm: Help unconfuse gcc, avoid accidental impossible unsigned comparisons

Daniel Vetter daniel at ffwll.ch
Mon May 18 14:47:44 UTC 2020


On Sat, May 16, 2020 at 10:23:28PM +0100, Chris Wilson wrote:
> drivers/gpu/drm/drm_client_modeset.c: In function ‘drm_client_firmware_config’:
> ./include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
>    __builtin_constant_p((l) > (h)), (l) > (h), 0)))
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

Took me a while to spot where this goes boom, kinda wonder whether we
should have an

	if (WARN_ON(!connector_count))
		return -EINVAL;

somewhere in here. Just for belts&suspenders approach.

Anyway this looks good.

Reviewed-by: Daniel Vetter <daniel.vetter at ffwll.ch>

> ---
>  drivers/gpu/drm/drm_client_modeset.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
> index 7443114bd713..6e9530df0737 100644
> --- a/drivers/gpu/drm/drm_client_modeset.c
> +++ b/drivers/gpu/drm/drm_client_modeset.c
> @@ -563,7 +563,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
>  				       struct drm_client_offset *offsets,
>  				       bool *enabled, int width, int height)
>  {
> -	unsigned int count = min_t(unsigned int, connector_count, BITS_PER_LONG);
> +	const int count = min_t(unsigned int, connector_count, BITS_PER_LONG);
>  	unsigned long conn_configured, conn_seq, mask;
>  	struct drm_device *dev = client->dev;
>  	int i, j;
> -- 
> 2.20.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list