linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Nam Cao <namcaov@gmail.com>
To: forest@alittletooquiet.net, gregkh@linuxfoundation.org
Cc: namcaov@gmail.com, linux-kernel@vger.kernel.org,
	linux-staging@lists.linux.dev
Subject: [PATCH v3 2/2] staging: vt6655: use memset to make code clearer
Date: Fri,  9 Sep 2022 14:17:56 +0200	[thread overview]
Message-ID: <e545c514608bbef296baa37417d2c5af4403ee4c.1662724786.git.namcaov@gmail.com> (raw)
In-Reply-To: <cover.1662724786.git.namcaov@gmail.com>

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>
---
 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 3397c78b975a..34a65a92d602 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(&rd->rd0, 0, sizeof(rd->rd0));
 
 	rd->rd0.res_count = cpu_to_le16(priv->rx_buf_sz);
 	rd->rd0.owner = OWNED_BY_NIC;
-- 
2.25.1


  parent reply	other threads:[~2022-09-09 12:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 12:17 [PATCH v3 0/2] use memset to make code clearer Nam Cao
2022-09-09 12:17 ` [PATCH v3 1/2] staging: vt6655: remove unnecessary volatile qualifier Nam Cao
2022-09-09 18:03   ` Greg KH
2022-09-11  7:12     ` Nam Cao
2022-09-11  7:25       ` Greg KH
2022-09-13 16:52         ` Nam Cao
2022-09-14  8:02           ` Greg KH
2022-09-09 12:17 ` Nam Cao [this message]
2022-09-09 17:58 ` [PATCH v3 0/2] use memset to make code clearer Philipp Hortmann

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=e545c514608bbef296baa37417d2c5af4403ee4c.1662724786.git.namcaov@gmail.com \
    --to=namcaov@gmail.com \
    --cc=forest@alittletooquiet.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).