From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 2D6483858297; Wed, 7 Feb 2024 14:14:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D6483858297 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707315296; bh=MsBt3BUwMRhz90ro+PYfDIU5XS/6GakFnOH8n0fT2ko=; h=From:To:Subject:Date:From; b=G3wMSRFxRODA+kAKyzVRLZPpMVM96jx2nn/k0jrlU5rhpb8050kYN3m4y0r3VWuw9 0OKFqnoBvwaomYOfJBxUkSjdR3F6qgWYGJuSleMvFIB06EUFXodxZ3UTtOTQchNtG6 SG1Rjm1qIqy/PIGRvO1LSJOCVUNQiwg6BKDjj/oI= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] benchtests: Remove clang warnings X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 18b8fd93998ebb25ea7b0301906bcae94e0f2efe X-Git-Newrev: 0e9df23335856f6aeb420798eaf814cbd2c2039f Message-Id: <20240207141456.2D6483858297@sourceware.org> Date: Wed, 7 Feb 2024 14:14:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0e9df23335856f6aeb420798eaf814cbd2c2039f commit 0e9df23335856f6aeb420798eaf814cbd2c2039f Author: Adhemerval Zanella 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)