Re: [PATCH] arch: m68k: math-emu: unsigned issue, 'unsigned long' will never be less than zero.

Andreas Schwab
2013-05-30T07:09:58Z

Chen Gang <gang.chen@asianux.com> writes:

> 'oldmant.m32[1]' is 'unsigned long' which never '< 0', and the original
> author wanted to check the highest bit whether set.
>
> So need type cast form 'unsigned long' to 'long'.

Better to make the bit test explicit, since it is not a sign bit.

> diff --git a/arch/m68k/math-emu/fp_arith.c b/arch/m68k/math-emu/fp_arith.c
> index 08f286d..ef013c5 100644
> --- a/arch/m68k/math-emu/fp_arith.c
> +++ b/arch/m68k/math-emu/fp_arith.c
> @@ -519,7 +519,7 @@ static void fp_roundint(struct fp_ext *dest, int mode)
> return;
> break;
> case 0x401e:
> - if (!(oldmant.m32[1] >= 0))
> + if (!((long)oldmant.m32[1] >= 0))

if (oldmant.m32[1] & 0x80000000)

Andreas.

--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."