Subject: Re: devprop bogosity
To: Christos Zoulas <christos@astron.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 05/02/2006 13:34:40
--oLBj+sq0vYjzfsbl
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Tue, May 02, 2006 at 08:25:06PM +0000, Christos Zoulas wrote:
> In article <4457BAB7.9020101@tadpole.com>,
> Garrett D'Amore <garrett_damore@tadpole.com> wrote:
> >I've noticed something that I consider to be poor form.
> >
> >The prop_get (and devprop_get()) routines return a size_t. This is an
> >unsigned value. Unfortunately, the implementation code returns -1 to
> >indicate error, such as no such property.
> >
> >This means that I can't just do
> >
> > if (devprop_get(&sc->sc_dev, "videomode", ...) > 0)
> >
> >to check for an existing and non-empty property. Instead, I have to do
> >something like this:
> >
> > if (devprop_get() !=3D (size_t)-1)
> >
> >I don't particularly like having to cast in order to test for error
> >results, and the bug this led to (in my own code) demonstrates that this
> >kind of API is error prone.
> >
> >I'd recommend changing the return type of prop_get (and devprop_get())
> >to be ssize_t (a signed value).
> >
> >Any arguments with this? If not, then I'll just make the change.
>=20
> Or have a:
>=20
> #define NOPROP (size_t)-1
I'd say use ssize_t. However since Jason is driving this at the moment, we=
=20
probably should wait a bit for him to chime in.
Take care,
Bill
--oLBj+sq0vYjzfsbl
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
iD8DBQFEV8JgWz+3JHUci9cRAiVEAKCOK7JTkrHGIutGlc//y4cCuq4vIwCeI7Rj
IJpDPxL5atfS7uYwy+qVQTk=
=LXWx
-----END PGP SIGNATURE-----
--oLBj+sq0vYjzfsbl--