Re: [PATCH][MIPS] fix run_uncached warning about 32bit kernel

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 06, 2007 at 06:20:39PM +0000, Maciej W. Rozycki wrote:

> > > arch/mips/lib/uncached.c: In function 'run_uncached':
> > > arch/mips/lib/uncached.c:47: warning: comparison is always true due to limited range of data type
> > > arch/mips/lib/uncached.c:48: warning: comparison is always false due to limited range of data type
> > > arch/mips/lib/uncached.c:57: warning: comparison is always true due to limited range of data type
> > > arch/mips/lib/uncached.c:58: warning: comparison is always false due to limited range of data type
> > 
> > Thanks, applied.
> 
>  "Fixing" bugs in the compiler, huh? ;-)  I suppose there should be a note 
> somewhere nearby then, so there is a remote chance to remove the clutter 
> in the future.

Well, some of the warnings are also simply due to broken code.  This is
the result of preprocessing the code without Yoichi's patch applied:

[...]
 if (sp >= (long)0x80000000 && sp < (long)0xc0000000)
  usp = ((((int)(int)(sp)) & 0x1fffffff) | 0xa0000000);
 else if ((long long)sp >= (long long)(0x8000000000000000LL | ((0LL)<<59) | (0)) &&
   (long long)sp < (long long)(0x8000000000000000LL | ((8LL)<<59) | (0)))
  usp = (0x8000000000000000LL | (((long long)2)<<59) | ((((long long)sp) & -1)));

else {
  do { __asm__ __volatile__("break %0" : : "i" (512)); } while (0);
  usp = sp;
 }
[...]

So (0x8000000000000000LL | ((0LL)<<59) | (0)) is 0x8000000000000000LL which
then is casted to _signed_ long long, so becomes -9223372036854775808, the
most negative representable number so the two "comparison is always true
due to limited range of data type" warnings are perfectly correct.

Treating addresses as signed is a dangerous thing and we reallly only
should do it where extending 32-bit addresses to 64-bit because that's
what the architecture does.  So I would suggest as part of cleaning u the
mess something like below totally untested patch.

Comments?

  Ralf

Signed-off-by: Ralf Baechle <ralf@xxxxxxxxxxxxxx>

diff --git a/include/asm-mips/addrspace.h b/include/asm-mips/addrspace.h
index c627508..ff2dd38 100644
--- a/include/asm-mips/addrspace.h
+++ b/include/asm-mips/addrspace.h
@@ -10,6 +10,7 @@
 #ifndef _ASM_ADDRSPACE_H
 #define _ASM_ADDRSPACE_H
 
+#include <linux/types.h>
 #include <spaces.h>
 
 /*
@@ -22,12 +23,12 @@
 #define _CONST64_(x)	x
 #else
 #define _ATYPE_		__PTRDIFF_TYPE__
-#define _ATYPE32_	int
-#define _ATYPE64_	__s64
+#define _ATYPE32_	unsigned int
+#define _ATYPE64_	__u64
 #ifdef CONFIG_64BIT
-#define _CONST64_(x)	x ## L
+#define _CONST64_(x)	x ## UL
 #else
-#define _CONST64_(x)	x ## LL
+#define _CONST64_(x)	x ## ULL
 #endif
 #endif
 


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux