qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Nia Alarie <nia.alarie@gmail.com>, qemu-devel@nongnu.org
Cc: stefanha@gmail.com, jim@groklearning.com, joel@jms.id.au,
	kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH] audio: Convert use of atoi to qemu_strtoi
Date: Mon, 19 Mar 2018 09:47:18 -0500	[thread overview]
Message-ID: <a89c0265-53a0-a708-11fd-1096b565776b@redhat.com> (raw)
In-Reply-To: <20180316144047.30904-1-nia.alarie@gmail.com>

On 03/16/2018 09:40 AM, Nia Alarie wrote:
> If qemu_strtoi indicates an error, return the default value.

Would it be better to diagnose the error instead of silently returning a 
default value?

> 
> Signed-off-by: Nia Alarie <nia.alarie@gmail.com>
> ---
>   audio/audio.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/audio/audio.c b/audio/audio.c
> index 6eccdb17ee..d6e91901aa 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -335,9 +335,8 @@ static int audio_get_conf_int (const char *key, int defval, int *defaultp)
>       char *strval;
>   
>       strval = getenv (key);
> -    if (strval) {
> +    if (strval && !qemu_strtoi(strval, NULL, 10, &val)) {
>           *defaultp = 0;
> -        val = atoi (strval);
>           return val;
>       }
>       else {
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  reply	other threads:[~2018-03-19 14:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 14:40 [Qemu-devel] [PATCH] audio: Convert use of atoi to qemu_strtoi Nia Alarie
2018-03-19 14:47 ` Eric Blake [this message]
2018-03-19 15:01   ` nee
2018-03-19 15:08     ` Eric Blake

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=a89c0265-53a0-a708-11fd-1096b565776b@redhat.com \
    --to=eblake@redhat.com \
    --cc=jim@groklearning.com \
    --cc=joel@jms.id.au \
    --cc=kraxel@redhat.com \
    --cc=nia.alarie@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).