]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
benchtests: Remove clang warnings
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 6 Feb 2024 19:52:17 +0000 (16:52 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 28 Oct 2025 16:54:55 +0000 (13:54 -0300)
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.

benchtests/bench-malloc-thread.c
benchtests/bench-strchr.c

index 7759c618477e81cff67ae524d7b5a32cd291d891..2371c42e65ade9b3c9b9773a893769db057194a7 100644 (file)
@@ -68,7 +68,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));
index 63bb9552de9bcce98b6c00c99fe327e00344fc6c..734d44b6ded51eb4d1d3d709cd034031f08cdcfb 100644 (file)
@@ -100,7 +100,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)
@@ -166,7 +166,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)