From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Tue, 15 Sep 2009 00:09:21 +0200 Subject: [U-Boot] [PATCH v2] board/flagadm/flash.c: fix compile warning In-Reply-To: <4AAA96B2.7020607@freescale.com> References: <4AAA96B2.7020607@freescale.com> Message-ID: <1252966161-14156-1-git-send-email-wd@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Fix warning: flash.c:531: warning: dereferencing type-punned pointer will break strict-aliasing rules Signed-off-by: Wolfgang Denk Cc: K?ri Dav??sson --- v2: change implementation as suggested by Scott Wood in http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/67828/focus=67900 board/flagadm/flash.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/board/flagadm/flash.c b/board/flagadm/flash.c index bbefbac..a69b1a4 100644 --- a/board/flagadm/flash.c +++ b/board/flagadm/flash.c @@ -528,11 +528,17 @@ int write_word (flash_info_t *info, ulong dest, ulong da) ulong start; char csr; int flag; - ushort * d = (ushort*)&da; int i; + union { + u32 data32; + u16 data16[2]; + } data; + + data.data32 = da; /* Check if Flash is (sufficiently) erased */ - if (((*addr & d[0]) != d[0]) || ((*(addr+1) & d[1]) != d[1])) { + if (((*addr & data.data16[0]) != data.data16[0]) || + ((*(addr+1) & data.data16[1]) != data.data16[1])) { return (2); } /* Disable interrupts which might cause a timeout here */ @@ -544,7 +550,7 @@ int write_word (flash_info_t *info, ulong dest, ulong da) *addr = 0x0010; /* Write Data */ - *addr = d[i]; + *addr = data.data16[i]; /* re-enable interrupts if necessary */ if (flag) -- 1.6.0.6