All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sylvain Munaut <tnt@246tNt.com>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] powerpc: change rheap functions to use long integers instead of pointers
Date: Wed, 04 Apr 2007 20:00:44 +0200	[thread overview]
Message-ID: <4613E7CC.1020001@246tNt.com> (raw)
In-Reply-To: <4613E39A.70606@freescale.com>

Timur Tabi wrote:
> Kumar Gala wrote:
>
>> I'm concerned the error handling isn't correctly.  What happens if 
>> the rheap I'm managing has addresses at 0xf0000000.  When I compare 
>> offset to 0, its going to report as an error, even if the offset 
>> returned is valid.
>
> The return value is an offset INTO the actual buffer.  Unless you have
> buffer larger than 2GB, the return value will never be negative unless
> it's an error.  So technically, the maximum size of the remote heap is
> 2GB.  It doesn't matter where it was located.
That's what I tried to explain yesterday on IRC. Using rheap to manage
offset into a buffer is one of the usage model. The other one is to use
rh to manage addresses directly.
Since the case where you manage offset is more common, it make senses to
change the types to unsigned long. However the other usage model (manage
addresses) should still be possible (using type casts only).

I agree that _for the moment_, no code make uses of rheap to manage
addresses but that could happen.

> Please keep in mind that I'm not changing the actual numeric values
> that are being returned.  I'm only changing the types, because they
> were wrong.  rh_alloc() was returning a void pointer, but it was NEVER
> a pointer.  It was always a simple offset.
That's because _currently_ all the code use it like that, but nothing
prevents them to use it other wise ...

But you're right, your not changing the actual values returned,
ERR_PTR(x) == x ....
So if someone wants to use it with addresses, he still can. He should
just do cast to (void *). And to detect errors on alloc he should he
IS_ERR(...)

>   The first time you call rh_alloc(), you will get back a value of 0,
> because that's the beginning of the heap.
No, it doesn't always return 0.
That depends on what free region you "attached" at initialisation. And
you could have attached 0xffff0000 -> 0xffffffff ....



    Sylvain

  reply	other threads:[~2007-04-04 18:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-03 16:02 [PATCH] powerpc: change rheap functions to use long integers instead of pointers Timur Tabi
2007-04-04 16:42 ` Kumar Gala
2007-04-04 17:36   ` Pantelis Antoniou
2007-04-04 17:42   ` Timur Tabi
2007-04-04 18:00     ` Sylvain Munaut [this message]
2007-04-04 18:05       ` Timur Tabi
2007-04-04 18:13       ` Timur Tabi
2007-04-04 19:15         ` Dan Malek
2007-04-04 19:20           ` Timur Tabi
2007-04-04 19:31             ` Sylvain Munaut
2007-04-04 18:13       ` Scott Wood
2007-04-04 18:19         ` Timur Tabi
2007-04-04 18:24           ` Scott Wood
2007-04-04 18:27             ` Timur Tabi
2007-04-04 18:31               ` Scott Wood
2007-04-04 18:34                 ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4613E7CC.1020001@246tNt.com \
    --to=tnt@246tnt.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=timur@freescale.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.