Subject: Re: OpenFirmware, node numbers, handles etc.
To: None <>
From: Valeriy E. Ushakov <>
List: tech-kern
Date: 11/28/2007 19:28:35
On Wed, Nov 28, 2007 at 09:33:38 -0500, Michael Lorenz wrote:

> On Nov 28, 2007, at 01:36, der Mouse wrote:
> >>is there a good reason why OF handles, node numbers etc. are
> >>represented as int in our code?  As far as I can tell using a signed
> >>type here only causes trouble since at least node numbers may well
> >>have the upper bit set.
> >
> >Perhaps I'm missing something, but, what difference does it make if
> >some of the values happen to be negative?  They're just opaque  
> >handles,
> >right?
> People (including myself at times ) keep running into the trap of  
> checking node numbers for >0, which apparently works on some machines  
> ( not macs though ). Since there is no reason for node numbers and  
> handles to be signed as far as I can see I want to make them unsigned.

OFW standard says that some client interface functions,
e.g. finddevice or instance-to-package return (cell_t)-1 on error so
an invalid handle is going to pass your > 0 test for an unsigned type.

So you are just trading one set of signedness related problems for

The issue here is not signedness per se (unsigned type is more natural
(whatever that means) for handles, I guess), it's how you use it.

SY, Uwe
--                       |       Zu Grunde kommen          |       Ist zu Grunde gehen