]> git.sur5r.net Git - u-boot/commitdiff
Fix strict-aliasing warning in dlmalloc
authorSimon Glass <sjg@chromium.org>
Tue, 4 Sep 2012 11:31:07 +0000 (11:31 +0000)
committerAndreas Bießmann <andreas.devel@googlemail.com>
Thu, 13 Sep 2012 11:32:41 +0000 (13:32 +0200)
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 version is tested on avr32 arch boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
common/dlmalloc.c

index c645d7314bfe3a517e1273f7dce349a2dac0c1da..1d7e527b9dff98dd3974a4cf805fec6a6362963f 100644 (file)
@@ -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]);
-       int i;
-       for (i=2; i<(sizeof(av_)/sizeof(mbinptr)); ++i) {
-               *p++ += gd->reloc_off;
-       }
+       mbinptr *p = &av_[2];
+       size_t i;
+
+       for (i = 2; i < ARRAY_SIZE(av_); ++i, ++p)
+               *p = (mbinptr)((ulong)*p + gd->reloc_off);
 }
 #endif