tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: xdrproc_t prototype
On Wed, 24 Aug 2011, David Laight wrote:
> 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?
>
> I'm not sure there is any benefit it marking the functions anything
> other than 'bool_t (*xdrproc_t)(void)'.
well I thought about it, but FreeBSD used the vararg already so following
that seemed more logical
> 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.
I don't think thats quite possible, since the calls can be made from
inside generic library code which doesn't really know what the correct
cast will be. I think thats an argument for varargs since at least it can
pass what it likes.
I guess all of this predates void pointers..
> The code changes can be made less pervasive by using #defines
> to add in the cast to the call sites.
clnt_call() at least is already a macro.. I'll do another build with the
macro calls changed to include the cast, it cuts out quite a bit.
iain
Home |
Main Index |
Thread Index |
Old Index