Skip to content

Commit 06c4cc3

Browse files
rth7680pm215
authored andcommitted
qht: Fix threshold rate calculation
tests/qht-bench.c:287:29: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion] *threshold = rate * UINT64_MAX; ~ ^~~~~~~~~~ Fix this by splitting the 64-bit constant into two halves, each of which is individually perfectly representable, the sum of which produces the correct arithmetic result. This is very likely just a sticking plaster over some underlying incorrect code, but it will suppress the warning for the moment. Cc: Emilio G. Cota <[email protected]> Reported-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Richard Henderson <[email protected]> Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 4d28582 commit 06c4cc3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/qht-bench.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ static void do_threshold(double rate, uint64_t *threshold)
284284
if (rate == 1.0) {
285285
*threshold = UINT64_MAX;
286286
} else {
287-
*threshold = rate * UINT64_MAX;
287+
*threshold = (rate * 0xffff000000000000ull)
288+
+ (rate * 0x0000ffffffffffffull);
288289
}
289290
}
290291

0 commit comments

Comments
 (0)