Re: [PATCH v2] staging: vt6655: use memset to make code clearer

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

 



On Fri, Sep 09, 2022 at 11:08:57AM +0200, Nam Cao wrote:
> A line of code sets the entire struct vnt_rdes0 to zero by treating it as
> unsigned int. This works because sizeof(unsigned int) is equal to
> sizeof(struct vnt_rdes0) (4 bytes). However it is not obvious what this
> code is doing. Re-write this using memset to make the code clearer.
> 
> Signed-off-by: Nam Cao <namcaov@xxxxxxxxx>
> ---
> v2: re-write commit message because previous message describes a
> non-existent problem.
> 
>  drivers/staging/vt6655/device_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
> index 8e2a976aaaad..a38657769c20 100644
> --- a/drivers/staging/vt6655/device_main.c
> +++ b/drivers/staging/vt6655/device_main.c
> @@ -867,7 +867,7 @@ static bool device_alloc_rx_buf(struct vnt_private *priv,
>  		return false;
>  	}
>  
> -	*((unsigned int *)&rd->rd0) = 0; /* FIX cast */
> +	memset((void *)&rd->rd0, 0, sizeof(rd->rd0));

Why do you have to cast this to (void *)?  That should almost never be
needed.

thanks,

greg k-h




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux