All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaroslav Kysela <perex@perex.cz>
To: Arnd Bergmann <arnd@arndb.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
	John Kacur <jkacur@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Takashi Iwai <tiwai@suse.de>,
	ALSA development <alsa-devel@alsa-project.org>
Subject: Re: [PATCH 3/3] sound: push BKL into open functions
Date: Sun, 11 Jul 2010 09:15:22 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1007110913120.16744@eeebox2.perex-int.cz> (raw)
In-Reply-To: <1278798701-11171-4-git-send-email-arnd@arndb.de>

On Sat, 10 Jul 2010, Arnd Bergmann wrote:

> --- a/sound/core/hwdep.c
> +++ b/sound/core/hwdep.c
> @@ -94,13 +94,18 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> 		hw = snd_lookup_oss_minor_data(iminor(inode),
> 					       SNDRV_OSS_DEVICE_TYPE_DMFM);
> #endif
> -	} else
> -		return -ENXIO;
> +	} else {
> +		err = -ENXIO;
> +		goto out;
> +	}
> +
> +	err = -ENODEV;
> 	if (hw == NULL)
> -		return -ENODEV;
> +		goto out;
>
> +	err = -EFAULT;
> 	if (!try_module_get(hw->card->module))
> -		return -EFAULT;
> +		goto out;
>
> 	init_waitqueue_entry(&wait, current);
> 	add_wait_queue(&hw->open_wait, &wait);
> @@ -147,6 +152,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> 	mutex_unlock(&hw->open_mutex);
> 	if (err < 0)
> 		module_put(hw->card->module);
> +out:
> 	return err;
> }
>
> diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
> index f50ebf2..c30b1f3 100644
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -49,17 +49,19 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
>
> 	card = snd_lookup_oss_minor_data(iminor(inode),
> 					 SNDRV_OSS_DEVICE_TYPE_MIXER);
> -	if (card == NULL)
> -		return -ENODEV;
> -	if (card->mixer_oss == NULL)
> -		return -ENODEV;
> +	err = -ENODEV;
> +	if (card == NULL || card->mixer_oss == NULL)
> +		goto out;
> +
> 	err = snd_card_file_add(card, file);
> 	if (err < 0)
> -		return err;
> +		goto out;
> +
> 	fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
> 	if (fmixer == NULL) {
> 		snd_card_file_remove(card, file);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto out;
> 	}
> 	fmixer->card = card;
> 	fmixer->mixer = card->mixer_oss;
> @@ -67,9 +69,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
> 	if (!try_module_get(card->module)) {
> 		kfree(fmixer);
> 		snd_card_file_remove(card, file);
> -		return -EFAULT;
> +		err = -EFAULT;
> 	}
> -	return 0;
> +out:
> +	return err;
> }
>

I don't see any reason (benefit) to add gotos to these two functions.

 						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.

WARNING: multiple messages have this Message-ID (diff)
From: Jaroslav Kysela <perex@perex.cz>
To: Arnd Bergmann <arnd@arndb.de>
Cc: John Kacur <jkacur@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	ALSA development <alsa-devel@alsa-project.org>,
	LKML <linux-kernel@vger.kernel.org>, Takashi Iwai <tiwai@suse.de>
Subject: Re: [PATCH 3/3] sound: push BKL into open functions
Date: Sun, 11 Jul 2010 09:15:22 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LNX.2.00.1007110913120.16744@eeebox2.perex-int.cz> (raw)
In-Reply-To: <1278798701-11171-4-git-send-email-arnd@arndb.de>

On Sat, 10 Jul 2010, Arnd Bergmann wrote:

> --- a/sound/core/hwdep.c
> +++ b/sound/core/hwdep.c
> @@ -94,13 +94,18 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> 		hw = snd_lookup_oss_minor_data(iminor(inode),
> 					       SNDRV_OSS_DEVICE_TYPE_DMFM);
> #endif
> -	} else
> -		return -ENXIO;
> +	} else {
> +		err = -ENXIO;
> +		goto out;
> +	}
> +
> +	err = -ENODEV;
> 	if (hw == NULL)
> -		return -ENODEV;
> +		goto out;
>
> +	err = -EFAULT;
> 	if (!try_module_get(hw->card->module))
> -		return -EFAULT;
> +		goto out;
>
> 	init_waitqueue_entry(&wait, current);
> 	add_wait_queue(&hw->open_wait, &wait);
> @@ -147,6 +152,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
> 	mutex_unlock(&hw->open_mutex);
> 	if (err < 0)
> 		module_put(hw->card->module);
> +out:
> 	return err;
> }
>
> diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
> index f50ebf2..c30b1f3 100644
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -49,17 +49,19 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
>
> 	card = snd_lookup_oss_minor_data(iminor(inode),
> 					 SNDRV_OSS_DEVICE_TYPE_MIXER);
> -	if (card == NULL)
> -		return -ENODEV;
> -	if (card->mixer_oss == NULL)
> -		return -ENODEV;
> +	err = -ENODEV;
> +	if (card == NULL || card->mixer_oss == NULL)
> +		goto out;
> +
> 	err = snd_card_file_add(card, file);
> 	if (err < 0)
> -		return err;
> +		goto out;
> +
> 	fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
> 	if (fmixer == NULL) {
> 		snd_card_file_remove(card, file);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto out;
> 	}
> 	fmixer->card = card;
> 	fmixer->mixer = card->mixer_oss;
> @@ -67,9 +69,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
> 	if (!try_module_get(card->module)) {
> 		kfree(fmixer);
> 		snd_card_file_remove(card, file);
> -		return -EFAULT;
> +		err = -EFAULT;
> 	}
> -	return 0;
> +out:
> +	return err;
> }
>

I don't see any reason (benefit) to add gotos to these two functions.

 						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project; Red Hat, Inc.

  reply	other threads:[~2010-07-11  7:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-10 21:51 [PATCH 0/3] further BKL removal Arnd Bergmann
2010-07-10 21:51 ` [PATCH 1/3] drm: kill BKL from common code Arnd Bergmann
2010-08-24 18:46   ` Andreas Schwab
2010-08-24 20:45     ` Arnd Bergmann
2010-07-10 21:51 ` [PATCH 2/3] Remove BKL from fs/locks.c Arnd Bergmann
2010-07-10 22:01   ` Christoph Hellwig
2010-07-11 10:31     ` Arnd Bergmann
2010-07-10 21:51 ` [PATCH 3/3] sound: push BKL into open functions Arnd Bergmann
2010-07-11  7:15   ` Jaroslav Kysela [this message]
2010-07-11  7:15     ` Jaroslav Kysela
2010-07-11 10:16     ` Arnd Bergmann
2010-07-12 15:53       ` Takashi Iwai
2010-07-12 15:53         ` Takashi Iwai
2010-07-12 17:53         ` [PATCH] sound/oss: convert to unlocked_ioctl Arnd Bergmann
2010-07-12 20:38           ` Takashi Iwai
2010-07-12 20:38             ` Takashi Iwai
2010-07-12 21:13             ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.00.1007110913120.16744@eeebox2.perex-int.cz \
    --to=perex@perex.cz \
    --cc=alsa-devel@alsa-project.org \
    --cc=arnd@arndb.de \
    --cc=fweisbec@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.