diff mbox series

[3/6] ALSA: seq: oss: use kzalloc

Message ID 20220312102705.71413-4-Julia.Lawall@inria.fr
State Accepted
Commit 3baa40d4fd7ff6553325715b8a64cc8b43fd02ef
Headers show
Series use kzalloc | expand

Commit Message

Julia Lawall March 12, 2022, 10:27 a.m. UTC
Use kzalloc instead of kmalloc + memset.

The semantic patch that makes this change is:
(https://coccinelle.gitlabpages.inria.fr/website/)

//<smpl>
@@
expression res, size, flag;
@@
- res = kmalloc(size, flag);
+ res = kzalloc(size, flag);
  ...
- memset(res, 0, size);
//</smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 sound/core/seq/oss/seq_oss_init.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Joe Perches March 12, 2022, 9:43 p.m. UTC | #1
On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> Use kzalloc instead of kmalloc + memset.
[]
> diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
[]
> @@ -81,7 +81,6 @@ snd_seq_oss_create_client(void)
>  	system_client = rc;
>  
>  	/* create annoucement receiver port */

unrelated trivia: typo of announcement above

> -	memset(port, 0, sizeof(*port));
>  	strcpy(port->name, "Receiver");
>  	port->addr.client = system_client;
>  	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
>
Takashi Iwai March 13, 2022, 8:09 a.m. UTC | #2
On Sat, 12 Mar 2022 11:27:02 +0100,
Julia Lawall wrote:
> 
> Use kzalloc instead of kmalloc + memset.
> 
> The semantic patch that makes this change is:
> (https://coccinelle.gitlabpages.inria.fr/website/)
> 
> //<smpl>
> @@
> expression res, size, flag;
> @@
> - res = kmalloc(size, flag);
> + res = kzalloc(size, flag);
>   ...
> - memset(res, 0, size);
> //</smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

Applied, thanks.


Takashi
diff mbox series

Patch

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index 0ee4a5081fd6..04a3376a6e66 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -66,7 +66,7 @@  snd_seq_oss_create_client(void)
 	struct snd_seq_port_info *port;
 	struct snd_seq_port_callback port_callback;
 
-	port = kmalloc(sizeof(*port), GFP_KERNEL);
+	port = kzalloc(sizeof(*port), GFP_KERNEL);
 	if (!port) {
 		rc = -ENOMEM;
 		goto __error;
@@ -81,7 +81,6 @@  snd_seq_oss_create_client(void)
 	system_client = rc;
 
 	/* create annoucement receiver port */
-	memset(port, 0, sizeof(*port));
 	strcpy(port->name, "Receiver");
 	port->addr.client = system_client;
 	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */