Skip to contentSkip to conversation

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

PATCH Superseded Chen Gang 3 participants 13 messages May 30, 2013 – Jun 3, 2013

Subsystems (2)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: m68k: math-emu: unsigned issue, 'unsigned long' will never be less than zero.

'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'.

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

---
 arch/m68k/math-emu/fp_arith.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m68k/math-emu/fp_arith.c +1 -1
index 08f286d..ef013c5 100644
@@ -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))
 				return;
 			if (oldmant.m32[0] & 1)
 				break;
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 4 lines · Chen Gang

'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.

arch/m68k/math-emu/fp_arith.c static void fp_roundint(struct fp_ext *dest, int mode) · line 522

Quoted 10 lines
arch/m68k/math-emu/fp_arith.c +1 -1
index 08f286d..ef013c5 100644
@@ -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.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw
In reply to Chen Gang
Quoted 4 lines · Chen Gang

'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.

arch/m68k/math-emu/fp_arith.c static void fp_roundint(struct fp_ext *dest, int mode) · line 522

Quoted 10 lines
arch/m68k/math-emu/fp_arith.c +1 -1
index 08f286d..ef013c5 100644
@@ -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.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
author
#3 lore raw
Quoted 8 lines · Andreas Schwab
Quoted 4 lines · Chen Gang
Quoted 4 lines

'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.

That sounds good.

Quoted 11 lines
Quoted 10 lines

arch/m68k/math-emu/fp_arith.c static void fp_roundint(struct fp_ext *dest, int mode) · line 522

Quoted 10 lines
arch/m68k/math-emu/fp_arith.c +1 -1
index 08f286d..ef013c5 100644
@@ -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)

OK, I will send patch v2.

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation
author
#4 lore raw

PATCH v2 1/1 arch: m68k: math-emu: unsigned issue, 'unsigned long' will never be less than zero

In reply to Andreas Schwab

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

So need make the bit test explicit (which is better than type cast form 'unsigned long' to 'long').

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

---
 arch/m68k/math-emu/fp_arith.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/m68k/math-emu/fp_arith.c +1 -1
index 08f286d..239eb19 100644
@@ -519,7 +519,7 @@ static void fp_roundint(struct fp_ext *dest, int mode)
 				return;
 			break;
 		case 0x401e:
-			if (!(oldmant.m32[1] >= 0))
+			if (oldmant.m32[1] & 0x80000000)
 				return;
 			if (oldmant.m32[0] & 1)
 				break;
Signature · 1 line
1.7.7.6
maintainer Applied
#5 lore raw

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

Quoted 10 lines · Chen Gang

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

So need make the bit test explicit (which is better than type cast form 'unsigned long' to 'long').

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Thanks, applied and queued for 3.11!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

maintainer Applied
#6 lore raw

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

In reply to Chen Gang
Quoted 10 lines · Chen Gang

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

So need make the bit test explicit (which is better than type cast form 'unsigned long' to 'long').

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Thanks, applied and queued for 3.11!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#7 lore raw

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

Quoted 7 lines · Geert Uytterhoeven
Quoted 6 lines · Chen Gang

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

So need make the bit test explicit (which is better than type cast form 'unsigned long' to 'long').

Quoted 7 lines
Quoted 4 lines

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation
author
#8 lore raw

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

In reply to Geert Uytterhoeven
Quoted 7 lines · Geert Uytterhoeven
Quoted 6 lines · Chen Gang

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

So need make the bit test explicit (which is better than type cast form 'unsigned long' to 'long').

Quoted 7 lines
Quoted 4 lines

The related warning: (with EXTRA_CFLAGS=-W ARCH=m68k for allmodconfig)
arch/m68k/math-emu/fp_arith.c:522:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation
#9 lore raw

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

Quoted 4 lines · Chen Gang
Quoted 2 lines

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Linux v3.11.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#10 lore raw

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

In reply to Chen Gang
Quoted 4 lines · Chen Gang
Quoted 2 lines

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Linux v3.11.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#11 lore raw

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

Quoted 6 lines · Geert Uytterhoeven
Quoted 4 lines · Chen Gang
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Linux v3.11.

OK, thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation
author
#12 lore raw

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

In reply to Geert Uytterhoeven
Quoted 6 lines · Geert Uytterhoeven
Quoted 4 lines · Chen Gang
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Thanks, applied and queued for 3.11!

Thank you too, and pardon: what is '3.11' ? :-)

Linux v3.11.

OK, thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation