about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-02-06 16:52:17 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-17 16:12:41 -0300
commit6677c619032b1b284e40ca752c0338e8f10b6d94 (patch)
tree8b664668077253b1e6600f3cef536363c0048c31
parent230d65fc7342d98816799b46ecb92b35d33f922c (diff)
downloadglibc-6677c619032b1b284e40ca752c0338e8f10b6d94.tar.gz
glibc-6677c619032b1b284e40ca752c0338e8f10b6d94.tar.xz
glibc-6677c619032b1b284e40ca752c0338e8f10b6d94.zip
benchtests: Remove clang warnings
clangs warns of the implicit cast of RAND_MAX to float:

  error: implicit conversion from 'int' to 'float' changes value from
  2147483647 to 2147483648 [-Werror,-Wimplicit-const-int-float-conversion]

So make it explicit.
-rw-r--r--benchtests/bench-malloc-thread.c2
-rw-r--r--benchtests/bench-strchr.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/benchtests/bench-malloc-thread.c b/benchtests/bench-malloc-thread.c
index 46fdabd30c..74e71ec9ce 100644
--- a/benchtests/bench-malloc-thread.c
+++ b/benchtests/bench-malloc-thread.c
@@ -63,7 +63,7 @@ get_block_size (unsigned int rand_data)
   float min_pow = powf (dist_min, exponent + 1);
   float max_pow = powf (dist_max, exponent + 1);
 
-  float r = (float) rand_data / RAND_MAX;
+  float r = (float) rand_data / (float) RAND_MAX;
 
   return (unsigned int) powf ((max_pow - min_pow) * r + min_pow,
 			      1 / (exponent + 1));
diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c
index 5ef3a9d438..35e674fed0 100644
--- a/benchtests/bench-strchr.c
+++ b/benchtests/bench-strchr.c
@@ -97,7 +97,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl,
                               const CHAR *s, const CHAR *c)
 {
   size_t i, iters = INNER_LOOP_ITERS8;
-  int must_execute = 0;
+  volatile int must_execute = 0;
   timing_t start, stop, cur;
   TIMING_NOW (start);
   for (i = 0; i < iters; ++i)
@@ -162,7 +162,7 @@ do_rand_test (json_ctx_t *json_ctx, size_t align, size_t pos, size_t len,
   buf[align + len] = 0;
   buf[align + pos] = 1;
 
-  perc_zero_int = perc_zero * RAND_MAX;
+  perc_zero_int = perc_zero * (float) RAND_MAX;
   for (i = 0; i < NUM_SEARCH_CHARS; ++i)
     {
       if (rand () > perc_zero_int)