public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: wilc1000: remove unnecessary cast
@ 2015-06-15 19:04 ChengYi He
  2015-06-20 13:47 ` walter harms
  0 siblings, 1 reply; 2+ messages in thread
From: ChengYi He @ 2015-06-15 19:04 UTC (permalink / raw)
  To: kernel-janitors

kmalloc() returns void pointer.

Signed-off-by: ChengYi He <chengyihetaipei@gmail.com>
---
 drivers/staging/wilc1000/linux_mon.c  | 2 +-
 drivers/staging/wilc1000/linux_wlan.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index d5860ce..bc7feb4 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -258,7 +258,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
 	len += sizeof(struct tx_complete_mon_data *);
 	#endif
 
-	mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC);
+	mgmt_tx->buff = kmalloc(len, GFP_ATOMIC);
 	if (mgmt_tx->buff = NULL) {
 		PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
 		return WILC_FAIL;
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 5f87148..c1e9272 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -580,7 +580,7 @@ static void linux_wlan_dbg(uint8_t *buff)
 static void *linux_wlan_malloc_atomic(uint32_t sz)
 {
 	char *pntr = NULL;
-	pntr = (char *)kmalloc(sz, GFP_ATOMIC);
+	pntr = kmalloc(sz, GFP_ATOMIC);
 	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
 	return (void *)pntr;
 
@@ -588,7 +588,7 @@ static void *linux_wlan_malloc_atomic(uint32_t sz)
 static void *linux_wlan_malloc(uint32_t sz)
 {
 	char *pntr = NULL;
-	pntr = (char *)kmalloc(sz, GFP_KERNEL);
+	pntr = kmalloc(sz, GFP_KERNEL);
 	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
 	return (void *)pntr;
 }
@@ -605,7 +605,7 @@ void linux_wlan_free(void *vp)
 static void *internal_alloc(uint32_t size, uint32_t flag)
 {
 	char *pntr = NULL;
-	pntr = (char *)kmalloc(size, flag);
+	pntr = kmalloc(size, flag);
 	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr);
 	return (void *)pntr;
 }
-- 
1.9.1


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

* Re: [PATCH] staging: wilc1000: remove unnecessary cast
  2015-06-15 19:04 [PATCH] staging: wilc1000: remove unnecessary cast ChengYi He
@ 2015-06-20 13:47 ` walter harms
  0 siblings, 0 replies; 2+ messages in thread
From: walter harms @ 2015-06-20 13:47 UTC (permalink / raw)
  To: kernel-janitors



Am 15.06.2015 21:04, schrieb ChengYi He:
> kmalloc() returns void pointer.
> 
> Signed-off-by: ChengYi He <chengyihetaipei@gmail.com>
> ---
>  drivers/staging/wilc1000/linux_mon.c  | 2 +-
>  drivers/staging/wilc1000/linux_wlan.c | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
> index d5860ce..bc7feb4 100644
> --- a/drivers/staging/wilc1000/linux_mon.c
> +++ b/drivers/staging/wilc1000/linux_mon.c
> @@ -258,7 +258,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
>  	len += sizeof(struct tx_complete_mon_data *);
>  	#endif
>  
> -	mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC);
> +	mgmt_tx->buff = kmalloc(len, GFP_ATOMIC);
>  	if (mgmt_tx->buff = NULL) {
>  		PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
>  		return WILC_FAIL;
> diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
> index 5f87148..c1e9272 100644
> --- a/drivers/staging/wilc1000/linux_wlan.c
> +++ b/drivers/staging/wilc1000/linux_wlan.c
> @@ -580,7 +580,7 @@ static void linux_wlan_dbg(uint8_t *buff)
>  static void *linux_wlan_malloc_atomic(uint32_t sz)
>  {
>  	char *pntr = NULL;
> -	pntr = (char *)kmalloc(sz, GFP_ATOMIC);
> +	pntr = kmalloc(sz, GFP_ATOMIC);
>  	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
>  	return (void *)pntr;
>  
> @@ -588,7 +588,7 @@ static void *linux_wlan_malloc_atomic(uint32_t sz)
>  static void *linux_wlan_malloc(uint32_t sz)
>  {
>  	char *pntr = NULL;
> -	pntr = (char *)kmalloc(sz, GFP_KERNEL);
> +	pntr = kmalloc(sz, GFP_KERNEL);
>  	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
>  	return (void *)pntr;
>  }
> @@ -605,7 +605,7 @@ void linux_wlan_free(void *vp)
>  static void *internal_alloc(uint32_t size, uint32_t flag)
>  {
>  	char *pntr = NULL;
> -	pntr = (char *)kmalloc(size, flag);
> +	pntr = kmalloc(size, flag);
>  	PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr);
>  	return (void *)pntr;
>  }


hi your fix is correct, but the code is strange.
1. char *pntr = NULL; not needed
2. you could collaps linux_wlan_malloc,linux_wlan_malloc_atomic into internal_alloc

but why do this functions exists in the first place ?

internal_alloc is kmalloc+PRINT_D, this looks like a left over from some debug session to me.
why no replace the private alloc with a kmalloc ?


just my to cents,
 wh



--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in

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

end of thread, other threads:[~2015-06-20 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-15 19:04 [PATCH] staging: wilc1000: remove unnecessary cast ChengYi He
2015-06-20 13:47 ` walter harms

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox