Skip to contentSkip to conversation

Fix strict-aliasing warning in dlmalloc

PATCH New andreas.devel at googlemail.com 1 participant 4 messages Sep 4, 2012 – Sep 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix strict-aliasing warning in dlmalloc

From: Simon Glass <[email protected]>

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.

---
since v1:
* use size_t for array counter instead of int
* increment the pinter for next iteration

 common/dlmalloc.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
common/dlmalloc.c +5 -5
index c645d73..1d7e527 100644
@@ -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
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/1 Fix strict-aliasing warning in dlmalloc

Dear Andreas Bie?mann,

Quoted 10 lines · andreas.devel at googlemail.com

From: Simon Glass <[email protected]>

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

Quoted 8 lines

This version is tested on avr32 arch boards.

---
since v1:
* use size_t for array counter instead of int
* increment the pinter for next iteration

damn, this is in fact a [PATCH v2]. It is a successor of
http://patchwork.ozlabs.org/patch/134597/

Best regards

Andreas Bie?mann

#2 lore raw

PATCH 1/1 Fix strict-aliasing warning in dlmalloc

In reply to andreas.devel at googlemail.com

Dear all,

Quoted 10 lines · andreas.devel at googlemail.com

From: Simon Glass <[email protected]>

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

Quoted 5 lines

This version is tested on avr32 arch boards.

---

if no one complains I will apply this through u-boot-avr32 next weekend.

Best regards

Andreas Bie?mann

#3 lore raw

PATCH 1/1 Fix strict-aliasing warning in dlmalloc

In reply to andreas.devel at googlemail.com

Dear Andreas Bie?mann,

Quoted 10 lines · andreas.devel at googlemail.com

From: Simon Glass <[email protected]>

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

Quoted 8 lines

This version is tested on avr32 arch boards.

---
since v1:
* use size_t for array counter instead of int
* increment the pinter for next iteration

applied to u-boot-avr32/master, thanks!

Best regards

Andreas Bie?mann