softfloat: Use correct type in float64_to_uint64_round_to_zero()

Message ID 1486148371-11692-1-git-send-email-peter.maydell@linaro.org
State Superseded
Headers show

Commit Message

Peter Maydell Feb. 3, 2017, 6:59 p.m.
In float64_to_uint64_round_to_zero() a typo meant that we were
taking the uint64_t return value from float64_to_uint64() and
putting it into an int64_t variable before returning it as
uint64_t again. Use uint64_t instead of pointlessly casting it
back and forth to int64_t.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
Spotted while reading the code...

 fpu/softfloat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.4

Comments

Laurent Vivier Feb. 5, 2017, 6:03 p.m. | #1
Le 03/02/2017 à 19:59, Peter Maydell a écrit :
> In float64_to_uint64_round_to_zero() a typo meant that we were

> taking the uint64_t return value from float64_to_uint64() and

> putting it into an int64_t variable before returning it as

> uint64_t again. Use uint64_t instead of pointlessly casting it

> back and forth to int64_t.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Laurent Vivier <laurent@vivier.eu>


> ---

> Spotted while reading the code...

> 

>  fpu/softfloat.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/fpu/softfloat.c b/fpu/softfloat.c

> index c295f31..218b375 100644

> --- a/fpu/softfloat.c

> +++ b/fpu/softfloat.c

> @@ -7386,7 +7386,7 @@ uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *status)

>  {

>      signed char current_rounding_mode = status->float_rounding_mode;

>      set_float_rounding_mode(float_round_to_zero, status);

> -    int64_t v = float64_to_uint64(a, status);

> +    uint64_t v = float64_to_uint64(a, status);

>      set_float_rounding_mode(current_rounding_mode, status);

>      return v;

>  }

>
Philippe Mathieu-Daudé Feb. 9, 2017, 10:15 p.m. | #2
On 02/03/2017 03:59 PM, Peter Maydell wrote:
> In float64_to_uint64_round_to_zero() a typo meant that we were

> taking the uint64_t return value from float64_to_uint64() and

> putting it into an int64_t variable before returning it as

> uint64_t again. Use uint64_t instead of pointlessly casting it

> back and forth to int64_t.

>

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

> Spotted while reading the code...

>

>  fpu/softfloat.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/fpu/softfloat.c b/fpu/softfloat.c

> index c295f31..218b375 100644

> --- a/fpu/softfloat.c

> +++ b/fpu/softfloat.c

> @@ -7386,7 +7386,7 @@ uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *status)

>  {

>      signed char current_rounding_mode = status->float_rounding_mode;

>      set_float_rounding_mode(float_round_to_zero, status);

> -    int64_t v = float64_to_uint64(a, status);

> +    uint64_t v = float64_to_uint64(a, status);

>      set_float_rounding_mode(current_rounding_mode, status);

>      return v;

>  }

>
Michael Tokarev Feb. 15, 2017, 10:12 a.m. | #3
03.02.2017 21:59, Peter Maydell wrote:
> In float64_to_uint64_round_to_zero() a typo meant that we were

> taking the uint64_t return value from float64_to_uint64() and

> putting it into an int64_t variable before returning it as

> uint64_t again. Use uint64_t instead of pointlessly casting it

> back and forth to int64_t.


Applied to -trivial, thanks!

/mjt

Patch hide | download patch | download mbox

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c295f31..218b375 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -7386,7 +7386,7 @@  uint64_t float64_to_uint64_round_to_zero(float64 a, float_status *status)
 {
     signed char current_rounding_mode = status->float_rounding_mode;
     set_float_rounding_mode(float_round_to_zero, status);
-    int64_t v = float64_to_uint64(a, status);
+    uint64_t v = float64_to_uint64(a, status);
     set_float_rounding_mode(current_rounding_mode, status);
     return v;
 }