mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 03:13:44 +08:00
host-utils: Fix overflow detection in divu128()
The previous code didn't detect overflows if the high 64-bit of the dividend were equal to the 64-bit divisor. In that case, 64 bits wouldn't be enough to hold the quotient. Signed-off-by: Luis Pires <luis.pires@eldorado.org.br> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20210910112624.72748-2-luis.pires@eldorado.org.br> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
6b54a31bf7
commit
06c0259a08
@ -102,7 +102,7 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t divisor)
|
||||
*plow = dlo / divisor;
|
||||
*phigh = dlo % divisor;
|
||||
return 0;
|
||||
} else if (dhi > divisor) {
|
||||
} else if (dhi >= divisor) {
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user