public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: alsa-devel@alsa-project.org, clemens@ladisch.de
Subject: Re: [PATCH 4/5] ALSA: control: improve returned value because of the rest
Date: Wed, 11 Feb 2015 13:05:33 +0100	[thread overview]
Message-ID: <s5h386cpsaa.wl-tiwai@suse.de> (raw)
In-Reply-To: <1423651213-19829-5-git-send-email-o-takashi@sakamocchi.jp>

At Wed, 11 Feb 2015 19:40:12 +0900,
Takashi Sakamoto wrote:
 
> When a character device doesn't have enough spaces for requested number
> of controls or values, currently return -ENOMEM. This should be -ENOSPC
> (No space left on device).
> 
> This commit improves this behaviour.

Well, if the error code is passed to user-space, we must not change
the value now unless this change is mandatory.  Otherwise this would
break the user-space behavior.


Takashi

> 
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> ---
>  sound/core/control.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/sound/core/control.c b/sound/core/control.c
> index bce4730..9944d75 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -313,7 +313,7 @@ static int snd_ctl_find_hole(struct snd_card *card, unsigned int count)
>  
>  		/* this situation is very unlikely */
>  		dev_err(card->dev, "unable to allocate new control numid\n");
> -		return -ENOMEM;
> +		return -ENOSPC;
>  	}
>  	return 0;
>  }
> @@ -355,9 +355,9 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol)
>  		err = -EBUSY;
>  		goto error;
>  	}
> -	if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
> +	err = snd_ctl_find_hole(card, kcontrol->count);
> +	if (err < 0) {
>  		up_write(&card->controls_rwsem);
> -		err = -ENOMEM;
>  		goto error;
>  	}
>  	list_add_tail(&kcontrol->list, &card->controls);
> @@ -422,9 +422,9 @@ int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol,
>  		goto error;
>  	}
>  add:
> -	if (snd_ctl_find_hole(card, kcontrol->count) < 0) {
> +	err = snd_ctl_find_hole(card, kcontrol->count);
> +	if (err < 0) {
>  		up_write(&card->controls_rwsem);
> -		ret = -ENOMEM;
>  		goto error;
>  	}
>  	list_add_tail(&kcontrol->list, &card->controls);
> -- 
> 2.1.0
> 

  reply	other threads:[~2015-02-11 12:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11 10:40 [PATCH 0/5] ALSA: control: improve core codes with intrusion Takashi Sakamoto
2015-02-11 10:40 ` [PATCH 1/5] ALSA: control: drop a sub-effect for caller's data Takashi Sakamoto
2015-02-11 10:40 ` [PATCH 2/5] ALSA: control: use dev_dbg() for warning to add duplicated controls Takashi Sakamoto
2015-02-11 10:40 ` [PATCH 3/5] ALSA: control: fix logic error about control count in a device Takashi Sakamoto
2015-02-11 13:15   ` Takashi Iwai
2015-02-12 13:20     ` Takashi Sakamoto
2015-02-12 13:29       ` Takashi Iwai
2015-02-12 23:06         ` Takashi Sakamoto
2015-02-13  8:31           ` Takashi Iwai
2015-02-11 10:40 ` [PATCH 4/5] ALSA: control: improve returned value because of the rest Takashi Sakamoto
2015-02-11 12:05   ` Takashi Iwai [this message]
2015-02-11 10:40 ` [PATCH 5/5] ALSA: control: save stack usage at creating new instance Takashi Sakamoto

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=s5h386cpsaa.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=o-takashi@sakamocchi.jp \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox