[PATCH v17 02/14] compositor-drm: Avoid cast by using unsigned loop index

Pekka Paalanen ppaalanen at gmail.com
Mon Jul 9 13:55:08 UTC 2018


On Mon,  9 Jul 2018 14:23:08 +0100
Daniel Stone <daniels at collabora.com> wrote:

> ARRAY_LENGTH returns a size_t; rather than casting its result to
> int so we can compare to our signed index variable, just declare the
> index as a compatible type in the first place.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  libweston/compositor-drm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index e09719ce4..7753dfba6 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -914,7 +914,7 @@ drm_fb_addfb(struct drm_fb *fb)
>  	int ret = -EINVAL;
>  #ifdef HAVE_DRM_ADDFB2_MODIFIERS
>  	uint64_t mods[4] = { };
> -	int i;
> +	size_t i;
>  #endif
>  
>  	/* If we have a modifier set, we must only use the WithModifiers
> @@ -923,7 +923,7 @@ drm_fb_addfb(struct drm_fb *fb)
>  		/* KMS demands that if a modifier is set, it must be the same
>  		 * for all planes. */
>  #ifdef HAVE_DRM_ADDFB2_MODIFIERS
> -		for (i = 0; i < (int) ARRAY_LENGTH(mods) && fb->handles[i]; i++)
> +		for (i = 0; i < ARRAY_LENGTH(mods) && fb->handles[i]; i++)
>  			mods[i] = fb->modifier;
>  		ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height,
>  						 fb->format->format,

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180709/b7dbdaaa/attachment.sig>


More information about the wayland-devel mailing list