Subject: Re: devprop bogosity
To: Christos Zoulas <email@example.com>
From: Bill Studenmund <firstname.lastname@example.org>
Date: 05/02/2006 13:34:40
Content-Type: text/plain; charset=us-ascii
On Tue, May 02, 2006 at 08:25:06PM +0000, Christos Zoulas wrote:
> In article <4457BAB7.email@example.com>,
> Garrett D'Amore <firstname.lastname@example.org> 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.
> Or have a:
> #define NOPROP (size_t)-1
I'd say use ssize_t. However since Jason is driving this at the moment, we=
probably should wait a bit for him to chime in.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
-----END PGP SIGNATURE-----