Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1295380 > unrolled thread

[PATCH V2] ALSA: oss: consolidate kmalloc/memset 0 call to kzalloc

Started byNicholas Mc Guire <hofrat@osadl.org>
First post2015-12-19 15:40 +0100
Last post2015-12-20 22:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V2] ALSA: oss: consolidate kmalloc/memset 0 call to kzalloc Nicholas Mc Guire <hofrat@osadl.org> - 2015-12-19 15:40 +0100
    Re: [PATCH V2] ALSA: oss: consolidate kmalloc/memset 0 call to kzalloc Takashi Iwai <tiwai@suse.de> - 2015-12-20 22:40 +0100

#1295380 — [PATCH V2] ALSA: oss: consolidate kmalloc/memset 0 call to kzalloc

FromNicholas Mc Guire <hofrat@osadl.org>
Date2015-12-19 15:40 +0100
Subject[PATCH V2] ALSA: oss: consolidate kmalloc/memset 0 call to kzalloc
Message-ID<qHqPT-4ns-3@gated-at.bofh.it>
This is an API consolidation only. The use of kmalloc + memset to 0
is equivalent to kzalloc.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---

V2: somehow managed to insert exactly the same line being removed
    so this time actually do the intended kmalloc->kzalloc replacement 

Found by coccinelle script (relaxed version of
scripts/coccinelle/api/alloc/kzalloc-simple.cocci)

Patch was compile tested with: x86_64_defconfig
CONFIG_SND_PCM_OSS=y

Patch is against linux-next (localversion-next is -next-20150518)

diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index e557dbe..8cdd06f 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -851,7 +851,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
 
 	if (mutex_lock_interruptible(&runtime->oss.params_lock))
 		return -EINTR;
-	sw_params = kmalloc(sizeof(*sw_params), GFP_KERNEL);
+	sw_params = kzalloc(sizeof(*sw_params), GFP_KERNEL);
 	params = kmalloc(sizeof(*params), GFP_KERNEL);
 	sparams = kmalloc(sizeof(*sparams), GFP_KERNEL);
 	if (!sw_params || !params || !sparams) {
@@ -989,7 +989,6 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
 		goto failure;
 	}
 
-	memset(sw_params, 0, sizeof(*sw_params));
 	if (runtime->oss.trigger) {
 		sw_params->start_threshold = 1;
 	} else {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1295694

FromTakashi Iwai <tiwai@suse.de>
Date2015-12-20 22:40 +0100
Message-ID<qHTRV-60u-11@gated-at.bofh.it>
In reply to#1295380
On Sat, 19 Dec 2015 15:23:13 +0100,
Nicholas Mc Guire wrote:
> 
> This is an API consolidation only. The use of kmalloc + memset to 0
> is equivalent to kzalloc.
> 
> Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>

Applied, thanks.


Takashi

> ---
> 
> V2: somehow managed to insert exactly the same line being removed
>     so this time actually do the intended kmalloc->kzalloc replacement 
> 
> Found by coccinelle script (relaxed version of
> scripts/coccinelle/api/alloc/kzalloc-simple.cocci)
> 
> Patch was compile tested with: x86_64_defconfig
> CONFIG_SND_PCM_OSS=y
> 
> Patch is against linux-next (localversion-next is -next-20150518)
> 
> diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
> index e557dbe..8cdd06f 100644
> --- a/sound/core/oss/pcm_oss.c
> +++ b/sound/core/oss/pcm_oss.c
> @@ -851,7 +851,7 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
>  
>  	if (mutex_lock_interruptible(&runtime->oss.params_lock))
>  		return -EINTR;
> -	sw_params = kmalloc(sizeof(*sw_params), GFP_KERNEL);
> +	sw_params = kzalloc(sizeof(*sw_params), GFP_KERNEL);
>  	params = kmalloc(sizeof(*params), GFP_KERNEL);
>  	sparams = kmalloc(sizeof(*sparams), GFP_KERNEL);
>  	if (!sw_params || !params || !sparams) {
> @@ -989,7 +989,6 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
>  		goto failure;
>  	}
>  
> -	memset(sw_params, 0, sizeof(*sw_params));
>  	if (runtime->oss.trigger) {
>  		sw_params->start_threshold = 1;
>  	} else {
> -- 
> 1.7.10.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web