diff mbox

net: ethernet: aquantia: fix alloc_cast.cocci warnings

Message ID 20170119090931.GA28354@lkp-ne04.lkp.intel.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

kernel test robot Jan. 19, 2017, 9:09 a.m. UTC
drivers/net/ethernet/aquantia/atlantic/aq_ring.c:24:20-41: WARNING: casting value returned by memory allocation function to (struct aq_ring_buff_s *) is useless.

 Remove casting the values returned by memory allocation functions
 like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc.

Semantic patch information:
 This makes an effort to find cases of casting of values returned by
 kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc,
 kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes
 the casting as it is not required. The result in the patch case may
need some reformatting.

Generated by: scripts/coccinelle/api/alloc/alloc_cast.cocci

CC: David VomLehn <vomlehn@texas.net>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

 aq_ring.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Perches Jan. 20, 2017, 8:19 a.m. UTC | #1
On Thu, 2017-01-19 at 17:09 +0800, kbuild test robot wrote:
> drivers/net/ethernet/aquantia/atlantic/aq_ring.c:24:20-41: WARNING: casting value returned by memory allocation function to (struct aq_ring_buff_s *) is useless.
> 
>  Remove casting the values returned by memory allocation functions
>  like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc.
[]
> --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
> @@ -21,7 +21,7 @@ static struct aq_ring_s *aq_ring_alloc(s
>  {
>  	int err = 0;
>  
> -	self->buff_ring = (struct aq_ring_buff_s *)
> +	self->buff_ring =
>  		kzalloc(sizeof(struct aq_ring_buff_s) * self->size, GFP_KERNEL);

This should likely be kcalloc
diff mbox

Patch

--- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c
@@ -21,7 +21,7 @@  static struct aq_ring_s *aq_ring_alloc(s
 {
 	int err = 0;
 
-	self->buff_ring = (struct aq_ring_buff_s *)
+	self->buff_ring =
 		kzalloc(sizeof(struct aq_ring_buff_s) * self->size, GFP_KERNEL);
 
 	if (!self->buff_ring) {