qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qapi: fix input visitor bugs


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] qapi: fix input visitor bugs
Date: Wed, 18 Jun 2014 09:41:56 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

On 06/18/2014 09:36 AM, Michael S. Tsirkin wrote:
> Remove dead code.  Reset errno to 0 before each strtoull call, as the
> man page requires.
> 
> Reported-by: Eric Blake <address@hidden>
> Signed-off-by: Michael S. Tsirkin <address@hidden>
> ---
>  qapi/string-input-visitor.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
> index 72722e6..d8a8db0 100644
> --- a/qapi/string-input-visitor.c
> +++ b/qapi/string-input-visitor.c
> @@ -48,11 +48,10 @@ static void parse_str(StringInputVisitor *siv, Error 
> **errp)
>          return;
>      }
>  
> -    errno = 0;
>      do {
> +        errno = 0;
>          start = strtoll(str, &endptr, 0);
> -        if (errno == 0 && endptr > str && INT64_MIN <= start &&
> -            start <= INT64_MAX) {
> +        if (errno == 0 && endptr > str) {

Based on this conditional...

>              if (*endptr == '\0') {
>                  cur = g_malloc0(sizeof(*cur));
>                  cur->begin = start;
> @@ -63,9 +62,9 @@ static void parse_str(StringInputVisitor *siv, Error **errp)
>                  str = NULL;
>              } else if (*endptr == '-') {
>                  str = endptr + 1;
> +                errno = 0;

...this assignment to errno is dead code (we already know it is 0).  But
I'd rather leave it in for robustness sake (any change to intermediate
code may change the situation where we are no longer assured of the
current value of errno at this point).

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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