qemu-trivial
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] util/cutils: Turn FIXME comment into QEMU_BUILD_BUG_ON()


From: Laurent Vivier
Subject: Re: [PATCH 1/2] util/cutils: Turn FIXME comment into QEMU_BUILD_BUG_ON()
Date: Wed, 18 Dec 2019 12:28:06 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

Le 25/11/2019 à 14:38, Markus Armbruster a écrit :
> qemu_strtoi64() assumes int64_t is long long.  This is marked FIXME.
> Replace by a QEMU_BUILD_BUG_ON() to avoid surprises.
> 
> Same for qemu_strtou64().
> 
> Fix a typo in qemu_strtoul()'s contract while there.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  util/cutils.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/util/cutils.c b/util/cutils.c
> index fd591cadf0..b372dd3e68 100644
> --- a/util/cutils.c
> +++ b/util/cutils.c
> @@ -502,7 +502,7 @@ int qemu_strtoul(const char *nptr, const char **endptr, 
> int base,
>   * Convert string @nptr to an int64_t.
>   *
>   * Works like qemu_strtol(), except it stores INT64_MAX on overflow,
> - * and INT_MIN on underflow.
> + * and INT64_MIN on underflow.
>   */
>  int qemu_strtoi64(const char *nptr, const char **endptr, int base,
>                   int64_t *result)
> @@ -517,8 +517,9 @@ int qemu_strtoi64(const char *nptr, const char **endptr, 
> int base,
>          return -EINVAL;
>      }
>  
> +    /* This assumes int64_t is long long TODO relax */
> +    QEMU_BUILD_BUG_ON(sizeof(int64_t) != sizeof(long long)); 
>      errno = 0;
> -    /* FIXME This assumes int64_t is long long */
>      *result = strtoll(nptr, &ep, base);
>      return check_strtox_error(nptr, ep, endptr, errno);
>  }
> @@ -541,8 +542,9 @@ int qemu_strtou64(const char *nptr, const char **endptr, 
> int base,
>          return -EINVAL;
>      }
>  
> +    /* This assumes uint64_t is unsigned long long TODO relax */
> +    QEMU_BUILD_BUG_ON(sizeof(uint64_t) != sizeof(unsigned long long));
>      errno = 0;
> -    /* FIXME This assumes uint64_t is unsigned long long */
>      *result = strtoull(nptr, &ep, base);
>      /* Windows returns 1 for negative out-of-range values.  */
>      if (errno == ERANGE) {
> 

Applied to my trivial-patches branch with removed trailing whitespace.

Thanks,
Laurent




reply via email to

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