All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Use sizeof type *pointer instead of sizeof type
@ 2016-09-15 11:35 sayli karnik
  2016-09-16  8:32 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: sayli karnik @ 2016-09-15 11:35 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: aditya.shankar, ganesh.krishna, gregkh

The patch uses the size of the dereference to a variable instead of it's type,
to make the code more resistant to type changes in the future. The type of the 
pointer variable here is the same as the type in the argument that is being
replaced in sizeof().

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
---
v2: Updated the commit message.
 drivers/staging/wilc1000/host_interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 78f524f..d0cb568 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3329,7 +3329,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
 
 	init_completion(&hif_wait_response);
 
-	hif_drv  = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL);
+	hif_drv  = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
 	if (!hif_drv) {
 		result = -ENOMEM;
 		goto _fail_;
@@ -3878,7 +3878,7 @@ static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo)
 	pu8IEs = ptstrNetworkInfo->ies;
 	u16IEsLen = ptstrNetworkInfo->ies_len;
 
-	pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL);
+	pNewJoinBssParam = kzalloc(sizeof(*pNewJoinBssParam), GFP_KERNEL);
 	if (pNewJoinBssParam) {
 		pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period;
 		pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period;
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Use sizeof type *pointer instead of sizeof type
  2016-09-15 11:35 [PATCH v2] Use sizeof type *pointer instead of sizeof type sayli karnik
@ 2016-09-16  8:32 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-09-16  8:32 UTC (permalink / raw)
  To: sayli karnik; +Cc: outreachy-kernel, aditya.shankar, ganesh.krishna

On Thu, Sep 15, 2016 at 05:05:08PM +0530, sayli karnik wrote:
> The patch uses the size of the dereference to a variable instead of it's type,
> to make the code more resistant to type changes in the future. The type of the 
> pointer variable here is the same as the type in the argument that is being
> replaced in sizeof().
> 
> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> ---
> v2: Updated the commit message.
>  drivers/staging/wilc1000/host_interface.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Please fix up the subject to say what part of the kernel you are
modifying, like the other patches are done for this driver.

thanks,

greg k-h


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-16  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 11:35 [PATCH v2] Use sizeof type *pointer instead of sizeof type sayli karnik
2016-09-16  8:32 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.