Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Feb 2008 12:29:26 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        Kris Kennaway <kris@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org, "David E. O'Brien" <obrien@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/fs/nullfs null_vfsops.c src/sys/fs/nwfs nwfs_vfsops.c src/sys/fs/smbfs smbfs_vfsops.c src/sys/ufs/ufs quota.h ufs_quota.c ufs_vfsops.c src/sys/kern vfs_default.c vfs_vnops.c vnode_if.src src/sys/sys mount.h vnode.h
Message-ID:  <86d4qli8a1.fsf@ds4.des.no>
In-Reply-To: <47C29A07.2070908@FreeBSD.org> (Kris Kennaway's message of "Mon\,  25 Feb 2008 11\:35\:51 %2B0100")
References:  <200802250855.m1P8t3w6052042@repoman.freebsd.org> <47C29A07.2070908@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kennaway <kris@FreeBSD.org> writes:
> David E. O'Brien <obrien@FreeBSD.org> writes:
> > [...]
> >   MFC: Eradicate caddr_t from the VFS API.
> Does this change the KAPI on a stable branch?

No, it changes neither the API nor the ABI.  It replaces caddr_t (which
is typedef'd to char *) with void *, and those two are compatible types.

The following program demonstrates this:

#include <sys/types.h>
void *f1(void *arg) { return arg; }
caddr_t f2(caddr_t arg) { return arg; }
int main(void) { caddr_t ca; void *vp; ca =3D f1(ca); ca =3D f1(vp); vp =3D=
 f2(ca); vp =3D f2(vp); return 0; }

Compile it with 'cc -Wall -Wextra -pedantic -o /dev/null caddr_t.c'

The program tests both passing a caddr_t in to a function that expects
void * and returning a void * to a caller that expects caddr_t, which
are two of the three cases that might break (for completeness, it also
tests the reverse, which isn't actually relevant here).

The third case, which the program doesn't test, is the case where the
type of a member of a struct that is exposed through the API changes;
that would indeed change the API, because the caller might want to
perform pointer arithmetic on that member.

However, the patch does none of these things.  It only changes internal
use of caddr_t, and the type of some API function arguments - no return
types, no structure members - so it's completely safe.

To tell you the truth, I'm surprised this wasn't MFCed earlier...
Thanks, David :)

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86d4qli8a1.fsf>