All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc
@ 2017-03-10  6:42 sayli karnik
  2017-03-10  6:46 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: sayli karnik @ 2017-03-10  6:42 UTC (permalink / raw)
  To: outreachy-kernel
  Cc: Greg Kroah-Hartman, Florian Fainelli, Ray Jui, Scott Branden,
	bcm-kernel-feedback-list, Stephen Warren, Lee Jones, Eric Anholt

This patch replaces kmalloc and memset with kzalloc.
Done using coccinelle:
@@
type T, T2;
expression x;
expression E1,E2;
statement S;
@@

- x = (T)kmalloc(E1,E2);
+ x = kzalloc(E1,E2);
  if ((x==NULL) || ...) S
- memset((T2)x,0,E1);

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
---
 drivers/staging/bcm2835-audio/bcm2835-vchiq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
index fa23a13..a117b05 100644
--- a/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
+++ b/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
@@ -289,11 +289,10 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
 		return NULL;
 	}
 	/* Allocate memory for this instance */
-	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
+	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
 	if (!instance)
 		return NULL;
 
-	memset(instance, 0, sizeof(*instance));
 	instance->num_connections = num_connections;
 
 	/* Create a lock for exclusive, serialized VCHI connection access */
-- 
2.7.4



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

* Re: [Outreachy kernel] [PATCH] staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc
  2017-03-10  6:42 [PATCH] staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc sayli karnik
@ 2017-03-10  6:46 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2017-03-10  6:46 UTC (permalink / raw)
  To: sayli karnik; +Cc: outreachy-kernel, Greg Kroah-Hartman



On Fri, 10 Mar 2017, sayli karnik wrote:

> This patch replaces kmalloc and memset with kzalloc.
> Done using coccinelle:
> @@
> type T, T2;
> expression x;
> expression E1,E2;
> statement S;
> @@
>
> - x = (T)kmalloc(E1,E2);
> + x = kzalloc(E1,E2);
>   if ((x==NULL) || ...) S
> - memset((T2)x,0,E1);
>
> Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
> ---
>  drivers/staging/bcm2835-audio/bcm2835-vchiq.c | 3 +--

The file has not existed for a few days now.  It is in another directory.
I think that there has already been a patch on this issue, but you can
check if it is still relevant.

As Alison suggested, it is good to update your kernel every time you start
to work.  There are a lot of patches flying around on this code at the
moment.

julia

>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/staging/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
> index fa23a13..a117b05 100644
> --- a/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
> +++ b/drivers/staging/bcm2835-audio/bcm2835-vchiq.c
> @@ -289,11 +289,10 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance,
>  		return NULL;
>  	}
>  	/* Allocate memory for this instance */
> -	instance = kmalloc(sizeof(*instance), GFP_KERNEL);
> +	instance = kzalloc(sizeof(*instance), GFP_KERNEL);
>  	if (!instance)
>  		return NULL;
>
> -	memset(instance, 0, sizeof(*instance));
>  	instance->num_connections = num_connections;
>
>  	/* Create a lock for exclusive, serialized VCHI connection access */
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170310064211.GA7443%40sayli-HP-15-Notebook-PC.
> For more options, visit https://groups.google.com/d/optout.
>


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

end of thread, other threads:[~2017-03-10  6:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10  6:42 [PATCH] staging: bcm2835-audio: bcm2835-vchiq: Replace kmalloc with kzalloc sayli karnik
2017-03-10  6:46 ` [Outreachy kernel] " Julia Lawall

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.