tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: return value of prop_*_recv_syscall()



On 24.09.2011 22:35, Francois Tigeot wrote:
[snip]
While learning how to use proplib, I've found an inconsistency between the
documentation and the actual kernel implementations:

the manual page for prop_array_send_syscall, prop_array_recv_syscall,
prop_dictionary_send_syscall and prop_dictionary_recv_syscall says these
functions return true if successful

The kernel implementations are different for prop_array_recv_syscall() and
prop_dictionary_recv_syscall, they return 0 if there's no error:

http://nxr.netbsd.org/source/xref/src/common/lib/libprop/prop_kern.c#227

Since DragonFly's proplib implementation comes from NetBSD, I figured it
would be best to ask here what to do:
fix the documentation or fix the implementation ?

Hmm, good question; it seems that the API has not been designed "symmetrically".

prop_*_recv_syscall() are used as if they returned an int that indicates "no error" (0) or error (!= 0). They capture the return value of _prop_object_internalize_from_pref() directly.

However, prop_*_send_syscall() do it differently: being an alias for prop_*_externalize_to_pref(), they return a boolean, and set errno to the correct value in case the result is "false".

I believe the API needs to be consistent; one way to do that is to have a prop_*_internalize_from_pref() similar to prop_*_externalize_to_pref() [1] that returns a boolean and set errno to the error value, and use these for recv_syscall via __strong_alias().

Just replacing
        return (_prop_object_internalize_from_pref(blah));
by
        return (_prop_object_internalize_from_pref(blah) == 0);

in prop_kern.c should be enough to fix it, but I'm not sure if this is the
better idea in the long run ...

IMHO, it's not: we are losing a way to report the type of error encountered in case there is one.

I would suggest to contact Manuel Bouyer directly, I think he is the one that designed the API.

[1] http://nxr.netbsd.org/source/xref/src/common/lib/libprop/prop_kern.c#78

--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index