Strange code in _dl_malloc

View: New views
2 Messages — Rating Filter:   Alert me  

Strange code in _dl_malloc

by Will Newton-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...>
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@...>
---
 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

[0001-ldso-ldso-ldso.c-Improve-code-readability-in-_dl_ma.patch]

From 6bd671f8248ede388f1765d3af5f784b780b5c9e Mon Sep 17 00:00:00 2001
From: Will Newton <will.newton@...>
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@...>
---
 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



_______________________________________________
uClibc mailing list
uClibc@...
http://lists.busybox.net/mailman/listinfo/uclibc

Re: Strange code in _dl_malloc

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tuesday 03 November 2009 11:22:06 Will Newton wrote:
> 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.

it looks that way, but i'd be hesitant to go changing this without some
example code that exercises it specifically ...
-mike


_______________________________________________
uClibc mailing list
uClibc@...
http://lists.busybox.net/mailman/listinfo/uclibc

signature.asc (853 bytes) Download Attachment