Skip to content
Snippets Groups Projects
Commit 06c4cc36 authored by Richard Henderson's avatar Richard Henderson Committed by Peter Maydell
Browse files

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 <cota@braap.org>
Reported-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent 4d285821
No related branches found
No related tags found
No related merge requests found
......@@ -284,7 +284,8 @@ static void do_threshold(double rate, uint64_t *threshold)
if (rate == 1.0) {
*threshold = UINT64_MAX;
} else {
*threshold = rate * UINT64_MAX;
*threshold = (rate * 0xffff000000000000ull)
+ (rate * 0x0000ffffffffffffull);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment