additional ifreq accessors?

Conrad Meyer cem at freebsd.org
Tue Apr 7 19:03:31 UTC 2020


On Tue, Apr 7, 2020 at 10:45 AM Brooks Davis <brooks at freebsd.org> wrote:
> On Tue, Apr 07, 2020 at 07:32:37PM +0200, Hans Petter Selasky wrote:
> > Is there a reason for using "void *" here?
> >
> > char *ifr_addr_get_data(void *ifrp);
>
> Because the type is unknown at this point (it may be struct ifreq or
> struct ifreq32 (or in CheriBSD struct ifreq64)).  By using "void *" here
> we avoid the need to insert a wrong cast.

I think the question (or my question anyway) is: why void*, and not a
union pointer?  A union pointer would never be a wrong cast for the
caller, and inherent in this design is essentially treating the
pointer as a union on the callee side of things.

Thanks,
Conrad


More information about the freebsd-net mailing list