Subject: devprop bogosity
To: None <tech-kern@NetBSD.org>
From: Garrett D'Amore <firstname.lastname@example.org>
Date: 05/02/2006 13:01:59
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.
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
Phone: 951 325-2134 Fax: 951 325-2191