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

Dag-Erling Smørgrav des at des.no
Mon Feb 25 11:29:36 UTC 2008


Kris Kennaway <kris at FreeBSD.org> writes:
> David E. O'Brien <obrien at 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 = f1(ca); ca = f1(vp); vp = f2(ca); vp = 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
-- 
Dag-Erling Smørgrav - des at des.no


More information about the cvs-all mailing list