qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"Emilio G . Cota" <cota@braap.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Alexander Bulekov" <alxndr@bu.edu>
Subject: Re: [PATCH] tests/qht-bench: Fix Clang 'int-conversion' warning
Date: Mon, 4 May 2020 16:39:01 +0200	[thread overview]
Message-ID: <202238cc-034f-d232-12b0-5017a24f96c8@redhat.com> (raw)
In-Reply-To: <20200504142630.12842-1-philmd@redhat.com>

On 5/4/20 4:26 PM, Philippe Mathieu-Daudé wrote:
> When building with Clang 10 on Fedora 32, we get:
> 
>    tests/qht-bench.c:287:29: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion]
>            *threshold = rate * UINT64_MAX;
>                              ~ ^~~~~~~~~~
>    /usr/include/stdint.h:130:23: note: expanded from macro 'UINT64_MAX'
>    # define UINT64_MAX             (__UINT64_C(18446744073709551615))
>                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    /usr/include/stdint.h:107:25: note: expanded from macro '__UINT64_C'
>    #  define __UINT64_C(c) c ## UL
>                            ^~~~~~~
>    <scratch space>:14:1: note: expanded from here
>    18446744073709551615UL
>    ^~~~~~~~~~~~~~~~~~~~~~
> 
> Fix by using nextafter() from <math.h>:
> 
>    float nextafterf( float from, float to );
> 
>        Returns the next representable value of 'from'
>        in the direction of 'to'.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Cc: Emilio G. Cota <cota@braap.org>
> Cc: Alex Bennée <alex.bennee@linaro.org>
> Cc: Richard Henderson <richard.henderson@linaro.org>
> Cc: Alexander Bulekov <alxndr@bu.edu>
> ---
>   tests/qht-bench.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qht-bench.c b/tests/qht-bench.c
> index e3b512f26f..f93f8e0fe2 100644
> --- a/tests/qht-bench.c
> +++ b/tests/qht-bench.c
> @@ -10,6 +10,7 @@
>   #include "qemu/qht.h"
>   #include "qemu/rcu.h"
>   #include "qemu/xxhash.h"
> +#include <math.h>
>   
>   struct thread_stats {
>       size_t rd;
> @@ -284,7 +285,7 @@ static void do_threshold(double rate, uint64_t *threshold)
>       if (rate == 1.0) {
>           *threshold = UINT64_MAX;
>       } else {
> -        *threshold = rate * UINT64_MAX;
> +        *threshold = rate * nextafterf(0x1p64, 0.0);

NAck since of double type. Will send v2.

>       }
>   }
>   
> 



      reply	other threads:[~2020-05-04 14:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 14:26 [PATCH] tests/qht-bench: Fix Clang 'int-conversion' warning Philippe Mathieu-Daudé
2020-05-04 14:39 ` Philippe Mathieu-Daudé [this message]

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=202238cc-034f-d232-12b0-5017a24f96c8@redhat.com \
    --to=philmd@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alxndr@bu.edu \
    --cc=cota@braap.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).