Strange code in _dl_malloc

Will Newton will.newton at gmail.com
Tue Nov 3 16:22:06 UTC 2009


Hi all,

I noticed some rather strange code in _dl_malloc, and was wondering
whether this patch might be appropriate.

It looks like the code is intended to do an alignment, but the use of
& would appear to be equivalent to an assignment.

>From 6bd671f8248ede388f1765d3af5f784b780b5c9e Mon Sep 17 00:00:00 2001
From: Will Newton <will.newton at gmail.com>
Date: Tue, 3 Nov 2009 15:57:29 +0000
Subject: [PATCH] ldso/ldso/ldso.c: Improve code readability in _dl_malloc.

The rounding of the allocation to the page size is written in a rather
strange manner.

Signed-off-by: Will Newton <will.newton at gmail.com>
---
 ldso/ldso/ldso.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 021f109..9ab9a2f 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -187,7 +187,7 @@ void *_dl_malloc(size_t size)
 		   The actual page size doesn't really matter; as long
 		   as we're self-consistent here, we're safe.  */
 		if (size < _dl_pagesize)
-			rounded_size = (size + ADDR_ALIGN) & _dl_pagesize;
+			rounded_size = _dl_pagesize;
 		else
 			rounded_size = size;

-- 
1.5.5.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ldso-ldso-ldso.c-Improve-code-readability-in-_dl_ma.patch
Type: text/x-patch
Size: 897 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20091103/438edb44/attachment.bin>


More information about the uClibc mailing list