tech-userlevel archive

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

Re: xdrproc_t prototype

On Wed, Aug 24, 2011 at 10:08:09AM +0100, Iain Hibbert wrote:
> Hi
> I found a problem building NetBSD with pcc, in that the xdrproc_t typedef
> in /usr/include/rpc/xdr.h does not provide a complete prototype, which
> causes warnings with -Wmissing-prototypes (gcc accepts a partial, for some
> reason)
> FreeBSD some years ago changed this to a varargs prototype (about the best
> option I think), like so
> -typedef      bool_t (*xdrproc_t)(/* XDR *, void *, u_int */);
> +typedef      bool_t (*xdrproc_t)(XDR *, ...);
> and I would like to do that also. It causes no functional change but
> requires a bunch of additional casts throughout the codebase (there are
> some already, in similar positions), since the functions that are
> generally used as xdrproc_t are not actual vararg functions (but they do
> have a varying number of arguments), and browsing the FreeBSD cvsweb, they
> seem to have made the a similar choice regarding the casts.  As to third
> party code, I think that since FreeBSD did this nearly 10 years ago most
> problem code has likely been flagged and fixed.
> patch attached, any objections?
> iain

I'm not sure there is any benefit it marking the functions anything
other than 'bool_t (*xdrproc_t)(void)'.
The argument passing rules for varargs and non-varargs functions can be
different - so the function pointers should be cast back to the
correct prototype before being called.

The code changes can be made less pervasive by using #defines
to add in the cast to the call sites.


David Laight:

Home | Main Index | Thread Index | Old Index