[igt-dev] [PATCH i-g-t 3/6] tests/kms_color: Reuse some already compute values

Daniel Vetter daniel at ffwll.ch
Wed Apr 3 10:51:46 UTC 2019


On Tue, Apr 02, 2019 at 07:33:45PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> We already compute the lut_size*entry_size so let's reuse those
> when allocating the LUTs.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  tests/kms_color.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/kms_color.c b/tests/kms_color.c
> index 43e59dd42b0b..c65bb88cd7dc 100644
> --- a/tests/kms_color.c
> +++ b/tests/kms_color.c
> @@ -1079,8 +1079,8 @@ invalid_lut_sizes(data_t *data)
>  	size_t degamma_lut_size = data->degamma_lut_size * sizeof(struct drm_color_lut);
>  	size_t gamma_lut_size = data->gamma_lut_size * sizeof(struct drm_color_lut);
>  
> -	struct drm_color_lut *degamma_lut = malloc(data->degamma_lut_size * sizeof(struct drm_color_lut) * 2);
> -	struct drm_color_lut *gamma_lut = malloc(data->gamma_lut_size * sizeof(struct drm_color_lut) * 2);
> +	struct drm_color_lut *degamma_lut = malloc(degamma_lut_size * 2);
> +	struct drm_color_lut *gamma_lut = malloc(gamma_lut_size * 2);

Could also bikeshed to calloc, but this isn't kernel code, so who cares
about overflows.

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

>  
>  	igt_display_commit2(display, display->is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
>  
> -- 
> 2.19.2
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev

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


More information about the igt-dev mailing list