Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Apr 2020 12:03:16 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Brooks Davis <brooks@freebsd.org>
Cc:        Hans Petter Selasky <hps@selasky.org>, "freebsd-arch@freebsd.org" <arch@freebsd.org>, net@freebsd.org
Subject:   Re: additional ifreq accessors?
Message-ID:  <CAG6CVpUtd0wZ0C0fAGM-YT-EsNhYMonYpVBGYTM-MdSDOJc%2Bag@mail.gmail.com>
In-Reply-To: <20200407174522.GC72584@spindle.one-eyed-alien.net>
References:  <20200407172151.GB72584@spindle.one-eyed-alien.net> <62336.1586280397@critter.freebsd.dk> <af189ac8-8120-8759-2f7b-f265ed3236ff@selasky.org> <20200407174522.GC72584@spindle.one-eyed-alien.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Apr 7, 2020 at 10:45 AM Brooks Davis <brooks@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpUtd0wZ0C0fAGM-YT-EsNhYMonYpVBGYTM-MdSDOJc%2Bag>