From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1exwHf-0000wC-Gc for qemu-devel@nongnu.org; Mon, 19 Mar 2018 11:01:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1exwHe-00079Y-Po for qemu-devel@nongnu.org; Mon, 19 Mar 2018 11:01:11 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:39284) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1exwHe-00076U-In for qemu-devel@nongnu.org; Mon, 19 Mar 2018 11:01:10 -0400 Received: by mail-lf0-x243.google.com with SMTP id p142-v6so3236511lfd.6 for ; Mon, 19 Mar 2018 08:01:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <20180316144047.30904-1-nia.alarie@gmail.com> From: nee Date: Mon, 19 Mar 2018 15:01:08 +0000 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: Re: [Qemu-devel] [PATCH] audio: Convert use of atoi to qemu_strtoi List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Stefan Hajnoczi , Jim Mussared , Joel Stanley , kraxel@redhat.com On Mon, Mar 19, 2018 at 2:47 PM, Eric Blake wrote: > 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 >> --- >> 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 Possibly, while writing these patches I was just going by what was already there. I can see how that would be good. Should the code provide a warning to the user and continue with the default, or provide the warning and exit? And is it more correct to use dolog() or AUD_log() in this context?