qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] audio: Convert use of atoi to qemu_strtoi


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] audio: Convert use of atoi to qemu_strtoi
Date: Mon, 19 Mar 2018 09:47:18 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

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 <address@hidden>
---
  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 via email to

[Prev in Thread] Current Thread [Next in Thread]