Skip to contentSkip to conversation

ppc: mpc8323erdb: Fix compiler warning

PATCH New Marek Vasut 2 participants 3 messages Jul 13, 2013 – Jul 14, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc: mpc8323erdb: Fix compiler warning

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.

Cc Michael Barkowski <[email protected]>
Cc Tom Rini <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 board/freescale/mpc8323erdb/mpc8323erdb.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
board/freescale/mpc8323erdb/mpc8323erdb.c +3 -2
index f29b2f4..710589f 100644
@@ -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)) {
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 ppc: mpc8323erdb: Fix compiler warning

Dear Marek Vasut,

Quoted 7 lines · In message <[email protected]> you wrote:

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]) {
   ^
Quoted 6 lines

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.

Please see Timur's review comments to my original patch for this isssue ([1]). The "unsigned int" should indeed be fixed.

I resubmitted a v2 with the review comments incorporated on July 08, see [2], but I caught only one part of the needed changes. V3 sent right now; see [3]. I'd rather see this added than yours.

Also note that it might be a good idea to add the MPC83xx custodion to the Cc: list of such patches...

[1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/163386
[2] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/165266
[3] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/165731

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You got to learn three things. What's  real,  what's  not  real,  and
what's the difference."           - Terry Pratchett, _Witches Abroad_
#2 lore raw

PATCH 1/1 ppc: mpc8323erdb: Fix compiler warning

Hello Wolfgang,

Quoted 17 lines

Dear Marek Vasut,

Quoted 14 lines · In message <[email protected]> you wrote:

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

Quoted 8 lines
Quoted 1 line

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

Please see Timur's review comments to my original patch for this isssue ([1]). The "unsigned int" should indeed be fixed.

I resubmitted a v2 with the review comments incorporated on July 08, see [2], but I caught only one part of the needed changes. V3 sent right now; see [3]. I'd rather see this added than yours.

OK, I didn't know you were at it.

Quoted 2 lines

Also note that it might be a good idea to add the MPC83xx custodion to the Cc: list of such patches...

Yes, I only added the board maintainer, who's apparently no longer at FSL :(

Quoted 3 lines

[1] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/163386
[2] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/165266
[3] http://article.gmane.org/gmane.comp.boot-loaders.u-boot/165731

Best regards,
Marek Vasut