Patchwork [U-Boot,08/13] board/evb64260/zuma_pbb_mbox.c: Fix GCC 4.6 build warnings

login
register
mail settings
Submitter Wolfgang Denk
Date Nov. 9, 2011, 7:29 p.m.
Message ID <1320866946-28235-8-git-send-email-wd@denx.de>
Download mbox | patch
Permalink /patch/124671/
State Accepted
Commit 504f7080c33f2b39ac9528b00421f3da9096309b
Headers show

Comments

Wolfgang Denk - Nov. 9, 2011, 7:29 p.m.
Fix:
zuma_pbb_mbox.c: In function 'zuma_mbox_dump':
zuma_pbb_mbox.c:115:2: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
zuma_pbb_mbox.c:117:2: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]

Signed-off-by: Wolfgang Denk <wd@denx.de>
---
 board/evb64260/zuma_pbb_mbox.c |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)
Wolfgang Denk - Nov. 16, 2011, 8:04 p.m.
Dear Wolfgang Denk,

In message <1320866946-28235-8-git-send-email-wd@denx.de> you wrote:
> Fix:
> zuma_pbb_mbox.c: In function 'zuma_mbox_dump':
> zuma_pbb_mbox.c:115:2: warning: dereferencing type-punned pointer will
> break strict-aliasing rules [-Wstrict-aliasing]
> zuma_pbb_mbox.c:117:2: warning: dereferencing type-punned pointer will
> break strict-aliasing rules [-Wstrict-aliasing]
> 
> Signed-off-by: Wolfgang Denk <wd@denx.de>
> ---
>  board/evb64260/zuma_pbb_mbox.c |   25 ++++++++++++++++++-------
>  1 files changed, 18 insertions(+), 7 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/board/evb64260/zuma_pbb_mbox.c b/board/evb64260/zuma_pbb_mbox.c
index 3d7c976..621c64c 100644
--- a/board/evb64260/zuma_pbb_mbox.c
+++ b/board/evb64260/zuma_pbb_mbox.c
@@ -112,13 +112,24 @@  static int zuma_mbox_do_all_mailbox(void)
 
 static void zuma_mbox_dump(void)
 {
-	printf("ACC MAC=%04x%08x\n", *(unsigned short *) (&zuma_acc_mac),
-	       *(unsigned int *) ((char *) &zuma_acc_mac + 2));
-	printf("PRV MAC=%04x%08x\n", *(unsigned short *) (&zuma_prv_mac),
-	       *(unsigned int *) ((char *) &zuma_prv_mac + 2));
-	printf("slot:bac=%d:%d\n", (zuma_slot_bac >> 2) & 0xf,
-	       zuma_slot_bac & 0x3);
-	printf("BAUD1=%d BAUD2=%d\n", zuma_console_baud, zuma_debug_baud);
+	unsigned short s;
+	unsigned int i;
+
+	memcpy(&s, &zuma_acc_mac,    sizeof(s));
+	memcpy(&i, &zuma_acc_mac[2], sizeof(i));
+	printf("ACC MAC=%04x%08x\n", s, i);
+
+	memcpy(&s, &zuma_prv_mac,    sizeof(s));
+	memcpy(&s, &zuma_prv_mac[2], sizeof(i));
+	printf("PRV MAC=%04x%08x\n", s, i);
+
+	printf("slot:bac=%d:%d\n",
+		(zuma_slot_bac >> 2) & 0xf,
+		zuma_slot_bac & 0x3);
+
+	printf("BAUD1=%d BAUD2=%d\n",
+		zuma_console_baud,
+		zuma_debug_baud);
 }