[U-Boot] [PATCH 2/9] Fix strict-aliasing warning in dlmalloc
Simon Glass
sjg at chromium.org
Fri Jan 6 04:54:50 CET 2012
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
Signed-off-by: Simon Glass <sjg at chromium.org>
---
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);
}
#endif
--
1.7.3.1
More information about the U-Boot
mailing list