Subject: Re: devprop bogosity
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 05/02/2006 20:25:06
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() != (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

christos