Skip to contentSkip to conversation

fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code

PATCH New Kumar Gala 2 participants 2 messages Jul 6, 2009 – Aug 30, 2013

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code

sys_eeprom.c: In function 'do_mac':
sys_eeprom.c:323: warning: dereferencing type-punned pointer will break strict-aliasing rules sys_eeprom.c: In function 'mac_read_from_eeprom':
sys_eeprom.c:395: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 board/freescale/common/sys_eeprom.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
board/freescale/common/sys_eeprom.c +4 -2
index ae5304a..3e1e332 100644
@@ -78,12 +78,14 @@ static int has_been_read = 0;
 
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
 /* Is this a valid NXID EEPROM? */
-#define is_valid (*((u32 *)e.id) == (('N' << 24) | ('X' << 16) | ('I' << 8) | 'D'))
+#define is_valid ((e.id[0] == 'N') || (e.id[1] == 'X') || \
+		  (e.id[2] == 'I') || (e.id[3] == 'D'))
 #endif
 
 #ifdef CONFIG_SYS_I2C_EEPROM_CCID
 /* Is this a valid CCID EEPROM? */
-#define is_valid (*((u32 *)e.id) == (('C' << 24) | ('C' << 16) | ('I' << 8) | 'D'))
+#define is_valid ((e.id[0] == 'C') || (e.id[1] == 'C') || \
+		  (e.id[2] == 'I') || (e.id[3] == 'D'))
 #endif
 
 /**
Signature · 1 line
1.6.0.6
#1 lore raw

PATCH 1/1 fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code

board/freescale/common/sys_eeprom.c static int has_been_read = 0; · line 83

Quoted 7 lines · Kumar Gala

#ifdef CONFIG_SYS_I2C_EEPROM_NXID
/* Is this a valid NXID EEPROM? */

board/freescale/common/sys_eeprom.c +2 -1
-#define is_valid (*((u32 *)e.id) == (('N' << 24) | ('X' << 16) | ('I' << 8) | 'D'))
+#define is_valid ((e.id[0] == 'N') || (e.id[1] == 'X') || \
+                 (e.id[2] == 'I') || (e.id[3] == 'D'))
 #endif

Four years later, I just noticed that this code is wrong. It should be && instead of ||.