lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 2 Feb 2024 17:59:46 -0300
From: Arthur Grillo <arthurgrillo@...eup.net>
To: Louis Chauvet <louis.chauvet@...tlin.com>,
 Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>,
 Melissa Wen <melissa.srw@...il.com>, MaĆ­ra Canal
 <mairacanal@...eup.net>, Haneen Mohammed <hamohammed.sa@...il.com>,
 Daniel Vetter <daniel@...ll.ch>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 David Airlie <airlied@...il.com>, marcheu@...gle.com, seanpaul@...gle.com,
 nicolejadeyee@...gle.com
Cc: dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
 thomas.petazzoni@...tlin.com, miquel.raynal@...tlin.com
Subject: Re: [PATCH 1/2] drm/vkms: Create a type to check a function pointer
 validity



On 01/02/24 14:31, Louis Chauvet wrote:
> Add the pixel_read_t type to check function prototype in structures
> and functions.
> It avoids casting to (void *) and at the same occasion allows the
> compiler to check the type properly.
> 
> Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
> ---
>  drivers/gpu/drm/vkms/vkms_drv.h     | 17 +++++++++++++++--
>  drivers/gpu/drm/vkms/vkms_formats.c |  4 ++--
>  drivers/gpu/drm/vkms/vkms_formats.h |  2 +-
>  3 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h
> index 51349a0c32d8..cb20bab26cae 100644
> --- a/drivers/gpu/drm/vkms/vkms_drv.h
> +++ b/drivers/gpu/drm/vkms/vkms_drv.h
> @@ -48,6 +48,20 @@ struct vkms_writeback_job {
>  	void (*pixel_write)(u8 *dst_pixels, struct pixel_argb_u16 *in_pixel);
>  };
>  
> +/**
> + * typedef pixel_read_t - These functions are used to read the pixels in the source frame, convert
> + * them to argb16 and write them to out_pixel.
> + * It assumes that src_pixels point to a valid pixel (not a block, or a block of 1x1 pixel)
> + *
> + * @src_pixels: Source pointer to a pixel
> + * @out_pixel: Pointer where to write the pixel value
> + * @encoding: Color encoding to use (mainly used for YUV formats)
> + * @range: Color range to use (mainly used for YUV formats)
> + */
> +typedef void (*pixel_read_t)(u8 **src_pixels, int y,
> +			     struct pixel_argb_u16 *out_pixel, enum drm_color_encoding enconding,
> +			     enum drm_color_range range);
> +
>  /**
>   * vkms_plane_state - Driver specific plane state
>   * @base: base plane state
> @@ -56,8 +70,7 @@ struct vkms_writeback_job {
>  struct vkms_plane_state {
>  	struct drm_shadow_plane_state base;
>  	struct vkms_frame_info *frame_info;
> -	void (*pixel_read)(u8 **src_buffer, struct pixel_argb_u16 *out_pixel,
> -			   enum drm_color_encoding enconding, enum drm_color_range range);
> +	pixel_read_t pixel_read;

Hi,

Please Cc me on the next versions,

You added the argument 'y' to the function but did not change the calls
to it, resulting in a compiler error. I think this argument addition
would be better on patch #2.

Best Regards,
~Arthur Grillo

>  };
>  
>  struct vkms_plane {
> diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c
> index e06bbd7c0a67..c6376db58d38 100644
> --- a/drivers/gpu/drm/vkms/vkms_formats.c
> +++ b/drivers/gpu/drm/vkms/vkms_formats.c
> @@ -390,7 +390,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb,
>  		wb->pixel_write(dst_pixels, &in_pixels[x]);
>  }
>  
> -void *get_pixel_conversion_function(u32 format)
> +pixel_read_t get_pixel_conversion_function(u32 format)
>  {
>  	switch (format) {
>  	case DRM_FORMAT_ARGB8888:
> @@ -420,7 +420,7 @@ void *get_pixel_conversion_function(u32 format)
>  	case DRM_FORMAT_YVU444:
>  		return &planar_yvu_to_argb_u16;
>  	default:
> -		return NULL;
> +		return (pixel_read_t)NULL;
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h
> index 0cf835292cec..04e31e126ab1 100644
> --- a/drivers/gpu/drm/vkms/vkms_formats.h
> +++ b/drivers/gpu/drm/vkms/vkms_formats.h
> @@ -5,7 +5,7 @@
>  
>  #include "vkms_drv.h"
>  
> -void *get_pixel_conversion_function(u32 format);
> +pixel_read_t get_pixel_conversion_function(u32 format);
>  
>  void *get_pixel_write_function(u32 format);
>  
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ