From: "Simon Sandström" <simon@nikanor.nu>
To: gregkh@linuxfoundation.org
Cc: forest@alittletooquiet.net, linux-kernel@vger.kernel.org,
devel@driverdev.osuosl.org, "Simon Sandström" <simon@nikanor.nu>
Subject: [PATCH 4/4] staging: vt6656: Use variable instead of its type in sizeof(...)
Date: Fri, 30 Jun 2017 23:38:54 +0200 [thread overview]
Message-ID: <20170630213854.4687-5-simon@nikanor.nu> (raw)
In-Reply-To: <20170630213854.4687-1-simon@nikanor.nu>
Use sizeof(variable) instead of sizeof(type) in memory allocations to
prevent problems if the variable type changes in the future.
Signed-off-by: Simon Sandström <simon@nikanor.nu>
---
drivers/staging/vt6656/main_usb.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index 095b85567306..cc6d8778fe5b 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -419,8 +419,7 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
int ii;
for (ii = 0; ii < priv->num_tx_context; ii++) {
- tx_context = kmalloc(sizeof(struct vnt_usb_send_context),
- GFP_KERNEL);
+ tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL);
if (!tx_context)
goto free_tx;
@@ -437,7 +436,7 @@ static bool vnt_alloc_bufs(struct vnt_private *priv)
}
for (ii = 0; ii < priv->num_rcb; ii++) {
- priv->rcb[ii] = kzalloc(sizeof(struct vnt_rcb), GFP_KERNEL);
+ priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL);
if (!priv->rcb[ii]) {
dev_err(&priv->usb->dev,
"failed to allocate rcb no %d\n", ii);
--
2.11.0
prev parent reply other threads:[~2017-06-30 21:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 21:38 [PATCH 0/4] staging: vt6656: Correct checkpatch.pl warnings Simon Sandström
2017-06-30 21:38 ` [PATCH 1/4] staging: vt6656: Add spaces between operators Simon Sandström
2017-06-30 21:38 ` [PATCH 2/4] staging: vt6656: Remove unnecessary blank lines Simon Sandström
2017-06-30 21:38 ` [PATCH 3/4] staging: vt6656: Align function parameters Simon Sandström
2017-06-30 21:38 ` Simon Sandström [this message]
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=20170630213854.4687-5-simon@nikanor.nu \
--to=simon@nikanor.nu \
--cc=devel@driverdev.osuosl.org \
--cc=forest@alittletooquiet.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®