summaryrefslogtreecommitdiff
path: root/libmisc/tests/test_rand.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-22 18:51:59 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-06 11:53:17 -0600
commit24e5d0ec1219e2dbb4b9510ef20833092a2b3871 (patch)
tree01bbcc34c6190fa1c35b2625e9ba1744b1447606 /libmisc/tests/test_rand.c
parentf09b7435b3a5222597d27238226d23ec0cbd5bd2 (diff)
wip: Build with -Wconversionlukeshu/safe-conversion
I think this found a real bug in the dhcp packet parser. I don't think anything called lib9p_str{,n}() values that could be big enough, but their bounds-checking was broken.
Diffstat (limited to 'libmisc/tests/test_rand.c')
-rw-r--r--libmisc/tests/test_rand.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libmisc/tests/test_rand.c b/libmisc/tests/test_rand.c
index 02f4c1c..b98dacf 100644
--- a/libmisc/tests/test_rand.c
+++ b/libmisc/tests/test_rand.c
@@ -53,14 +53,14 @@ static void test_n(uint64_t cnt) {
bool seen[MAX_SEE_ALL] = {0};
for (int i = 0; i < ROUNDS; i++) {
uint64_t val = rand_uint63n(cnt);
- sum += val;
+ sum += (double)val;
test_assert(val < cnt);
if (cnt < MAX_SEE_ALL)
seen[val] = true;
}
if (cnt > 1) {
- test_assert(sum/ROUNDS > 0.45*(cnt-1));
- test_assert(sum/ROUNDS < 0.55*(cnt-1));
+ test_assert(sum/ROUNDS > 0.45*(double)(cnt-1));
+ test_assert(sum/ROUNDS < 0.55*(double)(cnt-1));
}
if (cnt < MAX_SEE_ALL) {
for (uint64_t i = 0; i < cnt; i++)