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

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: Michael Barkowski michael.barkowski@freescale.com cc: Kim Phillips kim.phillips@freescale.com --- board/freescale/mpc8323erdb/mpc8323erdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
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]) { + unsigned int 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)) {

Dear Kim,
In message 1371198068-3581-1-git-send-email-wd@denx.de you wrote:
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: Michael Barkowski michael.barkowski@freescale.com
The address of the board maintainer bounces:
| Delivery has failed to these recipients or groups: | | Michael Barkowski | (michael.barkowski@freescale.com)mailto:michael.barkowski@freescale.com | The e-mail address you entered couldn't be found. Please check the | recipient's e-mail address and try to resend the message. If the | problem continues, please contact your helpdesk. | | The following organization rejected your message: | tx30smr01.am.freescale.net.
Do you know if there is a new maintainer for this board, or should we enter it as orphaned?
Best regards,
Wolfgang Denk

On Fri, Jun 14, 2013 at 4:14 AM, Wolfgang Denk wd@denx.de wrote:
Dear Kim,
In message 1371198068-3581-1-git-send-email-wd@denx.de you wrote:
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: Michael Barkowski michael.barkowski@freescale.com
The address of the board maintainer bounces:
| Delivery has failed to these recipients or groups: | | Michael Barkowski | (michael.barkowski@freescale.com)<mailto:michael.barkowski@freescale.com
| The e-mail address you entered couldn't be found. Please check the | recipient's e-mail address and try to resend the message. If the | problem continues, please contact your helpdesk. | | The following organization rejected your message: | tx30smr01.am.freescale.net.
Do you know if there is a new maintainer for this board, or should we enter it as orphaned?
Well, he hasn't been at Freescale for years, now, so that's not surprising. It's not entirely clear to me whether that board is one we actively support, but I suspect we can get away with maintenance moving over to Kim. That said, I guess I shouldn't volunteer him. :)
Andy

On Fri, Jun 28, 2013 at 4:47 PM, Andy Fleming afleming@gmail.com wrote:
Well, he hasn't been at Freescale for years, now, so that's not surprising. It's not entirely clear to me whether that board is one we actively support, but I suspect we can get away with maintenance moving over to Kim. That said, I guess I shouldn't volunteer him. :)
There's been a lot of churn at Freescale over the past couple years. I think a lot of the email addresses are no longer valid. It's probably time for an update.
For the record, I actually have an mpc8323erdb. I'm not sure if I want to be the maintainer for it, though.

On 06/29/2013 12:11 AM, Timur Tabi wrote:
On Fri, Jun 28, 2013 at 4:47 PM, Andy Fleming afleming@gmail.com wrote:
Well, he hasn't been at Freescale for years, now, so that's not surprising. It's not entirely clear to me whether that board is one we actively support, but I suspect we can get away with maintenance moving over to Kim. That said, I guess I shouldn't volunteer him. :)
There's been a lot of churn at Freescale over the past couple years. I think a lot of the email addresses are no longer valid. It's probably time for an update.
For the record, I actually have an mpc8323erdb. I'm not sure if I want to be the maintainer for it, though.
I have that board too and can run regular tests if that is any help
-- sinan

Dear Timur Tabi,
In message CAOZdJXWiKuGm5wOXQ5NwkPnBUgoEUSLOZPsbT1jJLn2c+M+kOw@mail.gmail.com you wrote:
On Fri, Jun 28, 2013 at 4:47 PM, Andy Fleming afleming@gmail.com wrote:
Well, he hasn't been at Freescale for years, now, so that's not surprising. It's not entirely clear to me whether that board is one we actively support, but I suspect we can get away with maintenance moving over to Kim. That said, I guess I shouldn't volunteer him. :)
There's been a lot of churn at Freescale over the past couple years. I think a lot of the email addresses are no longer valid. It's probably time for an update.
For the record, I actually have an mpc8323erdb. I'm not sure if I want to be the maintainer for it, though.
Well, while you're discussing a potential new maintainer for this board, can please anybody ACK/NAK or - even better - pull that patch so we can fix the build warnings for the release?
Thanks.
Best regards,
Wolfgang Denk

Dear Kim,
ping!!
In message 1371198068-3581-1-git-send-email-wd@denx.de I wrote:
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: Michael Barkowski michael.barkowski@freescale.com cc: Kim Phillips kim.phillips@freescale.com
board/freescale/mpc8323erdb/mpc8323erdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
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]) {
unsigned int 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)) {
-- 1.7.11.7
Best regards,
Wolfgang Denk

On Fri, Jun 14, 2013 at 3:21 AM, Wolfgang Denk wd@denx.de wrote:
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]) {
unsigned int crc_buf;
This should be a uint32_t, because you specifically want only four bytes.
If you fix that,
Acked-by: Timur Tabi timur@tabi.org

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(-)
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)) {

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).

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

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(-)
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)) {

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. V3: also use uint32_t for the size of the memcpy(), again thanks to Timur Tabi for pointing out.
board/freescale/mpc8323erdb/mpc8323erdb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
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(uint32_t)); + + 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)) {

Wolfgang Denk wrote:
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 Denkwd@denx.de cc: Timur Tabitimur@tabi.org cc: Kim Phillipskim.phillips@freescale.com
Ack.

On Sun, Jul 14, 2013 at 07:42:40PM +0200, Wolfgang Denk wrote:
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
Applied to u-boot/master, thanks!
participants (5)
-
Andy Fleming
-
Sinan Akman
-
Timur Tabi
-
Tom Rini
-
Wolfgang Denk