Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1679146

[PATCH 4/4] staging: vt6656: Use variable instead of its type in sizeof(...)

From Simon Sandström <simon@nikanor.nu>
Newsgroups linux.kernel
Subject [PATCH 4/4] staging: vt6656: Use variable instead of its type in sizeof(...)
Date 2017-06-30 23:40 +0200
Message-ID <tYbNU-2ht-29@gated-at.bofh.it> (permalink)
References <tYbNT-2ht-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] staging: vt6656: Correct checkpatch.pl warnings Simon Sandström <simon@nikanor.nu> - 2017-06-30 23:40 +0200
  [PATCH 4/4] staging: vt6656: Use variable instead of its type in sizeof(...) Simon Sandström <simon@nikanor.nu> - 2017-06-30 23:40 +0200
  [PATCH 3/4] staging: vt6656: Align function parameters Simon Sandström <simon@nikanor.nu> - 2017-06-30 23:40 +0200
  [PATCH 1/4] staging: vt6656: Add spaces between operators Simon Sandström <simon@nikanor.nu> - 2017-06-30 23:50 +0200

csiph-web