Re: factoring out "at" syscalls common code in nlookup
2009/7/26 Matthew Dillon <dillon@apollo.backplane.com>:
> =A0 =A0Looks pretty good but what is nl_atfp used for? =A0The fp has to b=
e
> =A0 =A0held anyway, I know, but I think I'd rather it be done explicitly
> =A0 =A0in the system calls like it is already.
Well, I did it that way to simplify the callers (no need to keep track
of fp). Also I thought that, as nl_nch depends on fp being ref'ed for
correctness, it is more maintainable to store the ref in the same
structure as nl_nch. This avoids lifetime issues (bogus caller
dropping the ref early) and leaks (ref never dropped).
Would you be happier with the following?
struct file *fp =3D NULL;
....
error =3D nlookup_init_at(&nd, &fp, uap->fd, uap->path, UIO_USERSPACE, 0);
if (error =3D=3D 0) {
error =3D kern_open(...);
}
nlookup_done_at(&nd, fp);
That keeps the callers simple and makes the ref to fp somewhat explicit.
討論串 (同標題文章)
完整討論串 (本文為第 3 之 3 篇):