All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning
@ 2020-05-04 14:41 Philippe Mathieu-Daudé
  2020-05-04 14:43 ` Philippe Mathieu-Daudé
  2020-05-05  8:26 ` no-reply
  0 siblings, 2 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-04 14:41 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alex Bennée, Richard Henderson, Emilio G . Cota,
	Philippe Mathieu-Daudé,
	Alexander Bulekov

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>:

  double nextafter( double from, double to );

      Returns the next representable value of 'from'
      in the direction of 'to'.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Since v1: nextafterf() -> nextafter()

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..54ce1e8188 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 * nextafter(0x1p64, 0.0);
     }
 }
 
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning
  2020-05-04 14:41 [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning Philippe Mathieu-Daudé
@ 2020-05-04 14:43 ` Philippe Mathieu-Daudé
  2020-05-05  8:26 ` no-reply
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-04 14:43 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Emilio G . Cota, Alex Bennée, Alexander Bulekov

Wrong subject =) v3 coming...

On 5/4/20 4:41 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>:
> 
>    double nextafter( double from, double to );
> 
>        Returns the next representable value of 'from'
>        in the direction of 'to'.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> Since v1: nextafterf() -> nextafter()
> 
> 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..54ce1e8188 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 * nextafter(0x1p64, 0.0);
>       }
>   }
>   
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning
  2020-05-04 14:41 [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning Philippe Mathieu-Daudé
  2020-05-04 14:43 ` Philippe Mathieu-Daudé
@ 2020-05-05  8:26 ` no-reply
  1 sibling, 0 replies; 3+ messages in thread
From: no-reply @ 2020-05-05  8:26 UTC (permalink / raw)
  To: philmd; +Cc: philmd, richard.henderson, qemu-devel, alxndr, cota, alex.bennee

Patchew URL: https://patchew.org/QEMU/20200504144125.22435-1-philmd@redhat.com/



Hi,

This series failed the asan build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
export ARCH=x86_64
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===




The full log is available at
http://patchew.org/logs/20200504144125.22435-1-philmd@redhat.com/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-05  8:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 14:41 [PATCH v2] tests/qht-bench: Fix Clang 'int-conversion' warning Philippe Mathieu-Daudé
2020-05-04 14:43 ` Philippe Mathieu-Daudé
2020-05-05  8:26 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.