hw/ppc/ppc405_uc.c: Avoid integer overflows
commitfb6971c110387cf597b58c411658e3d15cc6c6fb
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 21 Feb 2017 13:33:41 +0000 (21 13:33 +0000)
committerDavid Gibson <david@gibson.dropbear.id.au>
Wed, 22 Feb 2017 03:28:53 +0000 (22 14:28 +1100)
tree9c732699ce1a6457f1c30cb0aa4f2df8845e32b3
parentdf58713396f8b2deb923e39c00b10744c5c63909
hw/ppc/ppc405_uc.c: Avoid integer overflows

When performing clock calculations, the ppc405_uc code
has several places where it multiplies together two
32-bit variables and assigns the result to a 64-bit
variable. This doesn't quite do what is intended because
C will compute a 32-bit multiply result. Add casts to
ensure we don't truncate the result.

(Spotted by Coverity, CID 10055041005505.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/ppc405_uc.c