From 98b2b9cf57804cb45afc2e260f63d24d9669aabd Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 8 Oct 2010 15:24:56 +0000 Subject: [PATCH] * libm/common/sf_llrint.c, libm/common/sf_round.c: Add explicit casts to __uint32_t to avoid overflows on implicit casts. --- newlib/ChangeLog | 5 +++++ newlib/libm/common/sf_llrint.c | 2 +- newlib/libm/common/sf_round.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 22e55db5b..50807e61b 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,8 @@ +2010-10-08 Ralf Corsépius + + * libm/common/sf_llrint.c, libm/common/sf_round.c: Add explicit casts + to __uint32_t to avoid overflows on implicit casts. + 2010-10-08 Ralf Corsépius * libm/complex/complex.tex: Add empty stub. diff --git a/newlib/libm/common/sf_llrint.c b/newlib/libm/common/sf_llrint.c index 5cc73c664..7558e89ac 100644 --- a/newlib/libm/common/sf_llrint.c +++ b/newlib/libm/common/sf_llrint.c @@ -71,7 +71,7 @@ TWO23[2]={ GET_FLOAT_WORD (i0, t); /* Detect the all-zeros representation of plus and minus zero, which fails the calculation below. */ - if ((i0 & ~(1 << 31)) == 0) + if ((i0 & ~((__uint32_t)1 << 31)) == 0) return 0; j0 = ((i0 >> 23) & 0xff) - 0x7f; i0 &= 0x7fffff; diff --git a/newlib/libm/common/sf_round.c b/newlib/libm/common/sf_round.c index 6c9087db0..1bf60890c 100644 --- a/newlib/libm/common/sf_round.c +++ b/newlib/libm/common/sf_round.c @@ -38,7 +38,7 @@ w &= 0x80000000; if (exponent_less_127 == -1) /* Result is +1.0 or -1.0. */ - w |= (127 << 23); + w |= ((__uint32_t)127 << 23); } else {