public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] benchtests: Remove clang warnings
@ 2024-04-17 20:15 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2024-04-17 20:15 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6677c619032b1b284e40ca752c0338e8f10b6d94

commit 6677c619032b1b284e40ca752c0338e8f10b6d94
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Feb 6 16:52:17 2024 -0300

    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.

Diff:
---
 benchtests/bench-malloc-thread.c | 2 +-
 benchtests/bench-strchr.c        | 4 ++--
 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)

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

* [glibc/azanella/clang] benchtests: Remove clang warnings
@ 2024-04-02 16:01 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2024-04-02 16:01 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5a73f250adbe00cb7e62b50ddb1137b48da05a06

commit 5a73f250adbe00cb7e62b50ddb1137b48da05a06
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Feb 6 16:52:17 2024 -0300

    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.

Diff:
---
 benchtests/bench-malloc-thread.c | 2 +-
 benchtests/bench-strchr.c        | 4 ++--
 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)

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

* [glibc/azanella/clang] benchtests: Remove clang warnings
@ 2024-02-09 17:39 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2024-02-09 17:39 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=79a99d11da2083e551ae6fc28f692d08344069c6

commit 79a99d11da2083e551ae6fc28f692d08344069c6
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Feb 6 16:52:17 2024 -0300

    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.

Diff:
---
 benchtests/bench-malloc-thread.c | 2 +-
 benchtests/bench-strchr.c        | 4 ++--
 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)

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

* [glibc/azanella/clang] benchtests: Remove clang warnings
@ 2024-02-07 14:14 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2024-02-07 14:14 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0e9df23335856f6aeb420798eaf814cbd2c2039f

commit 0e9df23335856f6aeb420798eaf814cbd2c2039f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Feb 6 16:52:17 2024 -0300

    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.

Diff:
---
 benchtests/bench-malloc-thread.c | 2 +-
 benchtests/bench-strchr.c        | 4 ++--
 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)

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

end of thread, other threads:[~2024-04-17 20:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 20:15 [glibc/azanella/clang] benchtests: Remove clang warnings Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2024-04-02 16:01 Adhemerval Zanella
2024-02-09 17:39 Adhemerval Zanella
2024-02-07 14:14 Adhemerval Zanella

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 read-only IMAP folder(s) and NNTP newsgroup(s).