diff mbox

[U-Boot,2/2,V2] PPC MPC83xx: Fix MPC8323ERDB build warning

Message ID 1373307567-21958-1-git-send-email-wd@denx.de
State Superseded
Headers show

Commit Message

Wolfgang Denk July 8, 2013, 6:19 p.m. UTC
Fix:

mpc8323erdb.c: In function 'mac_read_from_eeprom':
mpc8323erdb.c:198:3: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Wolfgang Denk <wd@denx.de>
cc: Timur Tabi <timur@tabi.org>
cc: Kim Phillips <kim.phillips@freescale.com>
---
V2: use uint32_t for crc_buf to make sure we always get exactly
    32 bit; thanks to Timur Tabi for pointing out.

 board/freescale/mpc8323erdb/mpc8323erdb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Timur Tabi July 8, 2013, 10:04 p.m. UTC | #1
On 07/08/2013 01:19 PM, Wolfgang Denk wrote:
> +		uint32_t crc_buf;
> +
> +		memcpy(&crc_buf, &buf[24], sizeof(unsigned int));

Well, this is wrong, because it should be sizeof(uint32_t).  Or maybe
sizeof(crc_buf).
Wolfgang Denk July 14, 2013, 5:44 p.m. UTC | #2
Dear Timur Tabi,

In message <51DB3787.4000308@tabi.org> you wrote:
> On 07/08/2013 01:19 PM, Wolfgang Denk wrote:
> > +		uint32_t crc_buf;
> > +
> > +		memcpy(&crc_buf, &buf[24], sizeof(unsigned int));
> 
> Well, this is wrong, because it should be sizeof(uint32_t).  Or maybe
> sizeof(crc_buf).

Indedd. Sorry.  V3 on the way.

Thanks!

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
index f29b2f4..533cb08 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -195,7 +195,11 @@  int mac_read_from_eeprom(void)
 		printf("\nEEPROM @ 0x%02x read FAILED!!!\n",
 		       CONFIG_SYS_I2C_EEPROM_ADDR);
 	} else {
-		if (crc32(crc, buf, 24) == *(unsigned int *)&buf[24]) {
+		uint32_t crc_buf;
+
+		memcpy(&crc_buf, &buf[24], sizeof(unsigned int));
+
+		if (crc32(crc, buf, 24) == crc_buf) {
 			printf("Reading MAC from EEPROM\n");
 			for (i = 0; i < 4; i++) {
 				if (memcmp(&buf[i * 6], "\0\0\0\0\0\0", 6)) {