public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ppc: mpc8323erdb: Fix compiler warning
@ 2013-07-13 10:22 Marek Vasut
  2013-07-14 17:43 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2013-07-13 10:22 UTC (permalink / raw)
  To: u-boot

Fix the following warning:

mpc8323erdb.c: In function 'mac_read_from_eeprom':
mpc8323erdb.c:198:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   if (crc32(crc, buf, 24) == *(unsigned int *)&buf[24]) {
   ^

Size remains unchanged after and before fix:

   text    data     bss     dec     hex filename
 206977   18748   23344  249069   3cced ./u-boot

Note the fix is the crudest possible, but also least intrusive.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Michael Barkowski <michael.barkowski@freescale.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 board/freescale/mpc8323erdb/mpc8323erdb.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
index f29b2f4..710589f 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -184,7 +184,8 @@ void ft_board_setup(void *blob, bd_t *bd)
 #if defined(CONFIG_SYS_I2C_MAC_OFFSET)
 int mac_read_from_eeprom(void)
 {
-	uchar buf[28];
+	uint32_t bbuf[28 / 4];
+	uchar *buf = (uchar *)bbuf;
 	char str[18];
 	int i = 0;
 	unsigned int crc = 0;
@@ -195,7 +196,7 @@ 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]) {
+		if (crc32(crc, buf, 24) == bbuf[24 / 4]) {
 			printf("Reading MAC from EEPROM\n");
 			for (i = 0; i < 4; i++) {
 				if (memcmp(&buf[i * 6], "\0\0\0\0\0\0", 6)) {
-- 
1.7.10.4

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

end of thread, other threads:[~2013-07-14 23:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-13 10:22 [U-Boot] [PATCH] ppc: mpc8323erdb: Fix compiler warning Marek Vasut
2013-07-14 17:43 ` Wolfgang Denk
2013-07-14 23:32   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox