Subject: Re: OpenFirmware, node numbers, handles etc.
To: Valeriy E.Ushakov <email@example.com>
From: Michael Lorenz <firstname.lastname@example.org>
Date: 11/28/2007 12:17:01
-----BEGIN PGP SIGNED MESSAGE-----
On Nov 28, 2007, at 11:28, Valeriy E. Ushakov wrote:
> 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
>>>> 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
>> 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
> 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.
As I said, testing for >0 is wrong and usually happens with just
that, -1 as error, in mind.
> So you are just trading one set of signedness related problems for
I want to keep people from thinking of handles as signed at all.
Don't call it -1, call it 0xffffffff.
> 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.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
-----END PGP SIGNATURE-----