[flashrom] [PATCH 1/8] ichspi.c: make REGWRITE* macros safer

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Tue Jun 28 05:33:16 CEST 2011


'+' does have a quite high precedence so "calling" those macros with a term including weaker
operators in the off parameter may have unexpected consequences

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 ichspi.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ichspi.c b/ichspi.c
index b4eb236..a78034a 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -216,9 +216,9 @@ static uint16_t REGREAD8(int X)
 	return mmio_readb(ich_spibar + X);
 }
 
-#define REGWRITE32(off,val) mmio_writel(val, ich_spibar+off)
-#define REGWRITE16(off,val) mmio_writew(val, ich_spibar+off)
-#define REGWRITE8(off,val)  mmio_writeb(val, ich_spibar+off)
+#define REGWRITE32(off, val) mmio_writel(val, ich_spibar+(off))
+#define REGWRITE16(off, val) mmio_writew(val, ich_spibar+(off))
+#define REGWRITE8(off, val)  mmio_writeb(val, ich_spibar+(off))
 
 /* Common SPI functions */
 static int find_opcode(OPCODES *op, uint8_t opcode);
-- 
1.7.1





More information about the flashrom mailing list