All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code
@ 2009-07-06 15:11 Kumar Gala
  2013-08-30 13:43 ` Timur Tabi
  0 siblings, 1 reply; 2+ messages in thread
From: Kumar Gala @ 2009-07-06 15:11 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 board/freescale/common/sys_eeprom.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/board/freescale/common/sys_eeprom.c b/board/freescale/common/sys_eeprom.c
index ae5304a..3e1e332 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -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
 
 /**
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code
  2009-07-06 15:11 [U-Boot] [PATCH] fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code Kumar Gala
@ 2013-08-30 13:43 ` Timur Tabi
  0 siblings, 0 replies; 2+ messages in thread
From: Timur Tabi @ 2013-08-30 13:43 UTC (permalink / raw)
  To: u-boot

On Mon, Jul 6, 2009 at 10:11 AM, Kumar Gala <galak@kernel.crashing.org> wrote:
>
>  #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

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-30 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-06 15:11 [U-Boot] [PATCH] fsl: Fix compiler warnings from gcc-4.4 in sys_eeprom code Kumar Gala
2013-08-30 13:43 ` Timur Tabi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.