[PATCH] The compiler's revenge

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

 



... for lying to it is to produce code that does unexpected things.

In include/asm-mips/io.h, mips_io_port_base is declared to be const,
but can actually be modified using set_io_port_base(). The compiler
believes the const declaration and uses the uninitialized value if
an in(b|w|l) or out(b|w|l) is used right after set_io_port_base().


Signed-off-by: Thomas Koeller <thomas.koeller@xxxxxxxxxxxxx>



--- linux-mips-cvs/include/asm-mips/io.h	2004-10-25 11:16:42.000000000 +0200
+++ linux-mips-basler/include/asm-mips/io.h	2004-11-04 10:40:57.796646368 +0100
@@ -67,10 +67,9 @@
  * instruction, so the lower 16 bits must be zero.  Should be true on
  * on any sane architecture; generic code does not use this assumption.
  */
-extern const unsigned long mips_io_port_base;
+extern unsigned long mips_io_port_base;
 
-#define set_io_port_base(base)	\
-	do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
+#define set_io_port_base(base) mips_io_port_base = (base)
 
 /*
  * Thanks to James van Artsdalen for a better timing-fix than
--- linux-mips-cvs/arch/mips/kernel/setup.c	2004-07-14 16:21:29.000000000 +0200
+++ linux-mips-basler/arch/mips/kernel/setup.c	2004-11-04 10:39:45.359658464 +0100
@@ -78,7 +78,7 @@
  * mips_io_port_base is the begin of the address space to which x86 style
  * I/O ports are mapped.
  */
-const unsigned long mips_io_port_base = -1;
+unsigned long mips_io_port_base = -1;
 EXPORT_SYMBOL(mips_io_port_base);
 
 /*

-- 
--------------------------------------------------

Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com
http://www.baslerweb.com

==============================



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

  Powered by Linux