public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Nam Cao <namcaov@gmail.com>
Cc: forest@alittletooquiet.net, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: Re: [PATCH v2] staging: vt6655: use memset to make code clearer
Date: Fri, 9 Sep 2022 12:23:13 +0200	[thread overview]
Message-ID: <YxsUEUqbKRW85Z24@kroah.com> (raw)
In-Reply-To: <20220909090856.18427-1-namcaov@gmail.com>

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@gmail.com>
> ---
> 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

  reply	other threads:[~2022-09-09 10:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09  9:08 [PATCH v2] staging: vt6655: use memset to make code clearer Nam Cao
2022-09-09 10:23 ` Greg KH [this message]
2022-09-09 11:29   ` Nam Cao
2022-09-09 11:47     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YxsUEUqbKRW85Z24@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=forest@alittletooquiet.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=namcaov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox