From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?ISO-8859-1?Q?Andreas_Bie=DFmann?= Date: Tue, 04 Sep 2012 23:25:16 +0200 Subject: [U-Boot] [PATCH 2/9] Fix strict-aliasing warning in dlmalloc In-Reply-To: <50291C6D.7030101@gmail.com> References: <1325822097-15227-1-git-send-email-sjg@chromium.org> <1325822097-15227-3-git-send-email-sjg@chromium.org> <50291C6D.7030101@gmail.com> Message-ID: <504671BC.4090106@googlemail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Simon Glas, On 13.08.2012 17:25, Andreas Bie?mann wrote: > Dear Simon Glass, > > On 06.01.2012 04:54, Simon Glass wrote: >> This fixes the following warnings in dlmalloc seen with my gcc 4.6. >> >> dlmalloc.c: In function 'malloc_bin_reloc': >> dlmalloc.c:1493: warning: dereferencing pointer 'p' does break strict-aliasing rules >> dlmalloc.c:1493: warning: dereferencing pointer 'p' does break strict-aliasing rules >> dlmalloc.c:1490: note: initialized from here >> dlmalloc.c:1493: note: initialized from here > > This is really annoying, but ... > >> >> Signed-off-by: Simon Glass >> --- >> common/dlmalloc.c | 8 ++++---- >> 1 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/common/dlmalloc.c b/common/dlmalloc.c >> index c645d73..0a719b4 100644 >> --- a/common/dlmalloc.c >> +++ b/common/dlmalloc.c >> @@ -1487,11 +1487,11 @@ static mbinptr av_[NAV * 2 + 2] = { >> #ifdef CONFIG_NEEDS_MANUAL_RELOC >> void malloc_bin_reloc (void) >> { >> - unsigned long *p = (unsigned long *)(&av_[2]); >> + mbinptr *p = &av_[2]; >> int i; >> - for (i=2; i<(sizeof(av_)/sizeof(mbinptr)); ++i) { >> - *p++ += gd->reloc_off; >> - } >> + >> + for (i = 2; i < ARRAY_SIZE(av_); ++i) >> + *p = (mbinptr)((ulong)*p + gd->reloc_off); ------------------^ Ouch ... isn't there something missing? Who increments the pointer? ;) > your patch breaks avr32 boards at runtime: Will send a new version which supersedes this one and http://patchwork.ozlabs.org/patch/176885/ Best regards Andreas Bie?mann