Skip to contentSkip to conversation

dlmalloc: fix compiler warning

PATCH Applied Alexander Aring 2 participants 2 messages Nov 7, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlmalloc: fix compiler warning

This patch fix a compiler warning while building sandbox barebox with gcc version 4.8.2.

common/dlmalloc.c: In function ‘barebox_calloc’:
common/dlmalloc.c:1756:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
void *mem = malloc(sz);
^

---
 common/dlmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/dlmalloc.c +2 -1
index b4341fe..f006206 100644
@@ -1745,6 +1745,7 @@ void *calloc(size_t n, size_t elem_size)
 	mchunkptr p;
 	INTERNAL_SIZE_T csz;
 	INTERNAL_SIZE_T sz = n * elem_size;
+	void *mem;
 
 	/* check if expand_top called, in which case don't need to clear */
 	mchunkptr oldtop = top;
@@ -1753,7 +1754,7 @@ void *calloc(size_t n, size_t elem_size)
 	if ((long)n < 0)
 		return NULL;
 
-	void *mem = malloc(sz);
+	mem = malloc(sz);
 
 	if (!mem)
 		return NULL;
Signature · 7 lines
1.8.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 10 lines · Alexander Aring

This patch fix a compiler warning while building sandbox barebox with gcc version 4.8.2.

common/dlmalloc.c: In function ‘barebox_calloc’:
common/dlmalloc.c:1756:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
void *mem = malloc(sz);
^

Applied, thanks

Sascha

Quoted 33 lines
---
 common/dlmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/dlmalloc.c +2 -1
index b4341fe..f006206 100644
@@ -1745,6 +1745,7 @@ void *calloc(size_t n, size_t elem_size)
 	mchunkptr p;
 	INTERNAL_SIZE_T csz;
 	INTERNAL_SIZE_T sz = n * elem_size;
+	void *mem;
 
 	/* check if expand_top called, in which case don't need to clear */
 	mchunkptr oldtop = top;
@@ -1753,7 +1754,7 @@ void *calloc(size_t n, size_t elem_size)
 	if ((long)n < 0)
 		return NULL;
 
-	void *mem = malloc(sz);
+	mem = malloc(sz);
 
 	if (!mem)
 		return NULL;
Signature · 7 lines
1.8.4.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox