PERFORCE change 100954 for review
John Baldwin
jhb at FreeBSD.org
Sat Jul 8 03:04:41 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=100954
Change 100954 by jhb at jhb_mutex on 2006/07/08 03:03:42
- Use PTRIN() in a few places it wasn't being used.
- Push the copyout of msg.msg_namelen out to the few places that
need it to simplify the interface to kern_recvit() (we can now
drop the namelenp arg).
Affected files ...
.. //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#38 edit
.. //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#32 edit
.. //depot/projects/smpng/sys/kern/uipc_syscalls.c#84 edit
.. //depot/projects/smpng/sys/sys/syscallsubr.h#43 edit
Differences ...
==== //depot/projects/smpng/sys/compat/freebsd32/freebsd32_misc.c#38 (text+ko) ====
@@ -1000,8 +1000,8 @@
error = freebsd32_copyinmsghdr(uap->msg, &msg);
if (error)
return (error);
- error = freebsd32_copyiniov((struct iovec32 *)(uintptr_t)m32.msg_iov,
- m32.msg_iovlen, &iov, EMSGSIZE);
+ error = freebsd32_copyiniov(PTRIN(m32.msg_iov), m32.msg_iovlen, &iov,
+ EMSGSIZE);
if (error)
return (error);
msg.msg_flags = uap->flags;
@@ -1009,7 +1009,7 @@
msg.msg_iov = iov;
controlp = (msg.msg_control != NULL) ? &control : NULL;
- error = kern_recvit(td, uap->s, &msg, NULL, UIO_USERSPACE,
+ error = kern_recvit(td, uap->s, &msg, UIO_USERSPACE,
UIO_USERSPACE, controlp);
if (error == 0) {
msg.msg_iov = uiov;
@@ -1086,8 +1086,8 @@
error = freebsd32_copyinmsghdr(uap->msg, &msg);
if (error)
return (error);
- error = freebsd32_copyiniov((struct iovec32 *)(uintptr_t)m32.msg_iov,
- m32.msg_iovlen, &iov, EMSGSIZE);
+ error = freebsd32_copyiniov(PTRIN(m32.msg_iov), m32.msg_iovlen, &iov,
+ EMSGSIZE);
if (error)
return (error);
msg.msg_iov = iov;
@@ -1135,24 +1135,26 @@
int error;
if (uap->fromlenaddr) {
- error = copyin((void *)(uintptr_t)uap->fromlenaddr,
- &msg.msg_namelen, sizeof(msg.msg_namelen));
+ error = copyin(PTRIN(uap->fromlenaddr), &msg.msg_namelen,
+ sizeof(msg.msg_namelen));
if (error)
return (error);
} else {
msg.msg_namelen = 0;
}
- msg.msg_name = (void *)(uintptr_t)uap->from;
+ msg.msg_name = PTRIN(uap->from);
msg.msg_iov = &aiov;
msg.msg_iovlen = 1;
- aiov.iov_base = (void *)(uintptr_t)uap->buf;
+ aiov.iov_base = PTRIN(uap->buf);
aiov.iov_len = uap->len;
msg.msg_control = 0;
msg.msg_flags = uap->flags;
- error = kern_recvit(td, uap->s, &msg,
- (void *)(uintptr_t)uap->fromlenaddr, UIO_USERSPACE, UIO_USERSPACE,
- NULL);
+ error = kern_recvit(td, uap->s, &msg, UIO_USERSPACE,
+ UIO_USERSPACE, NULL);
+ if (error == 0 && uap->fromlenaddr)
+ error = copyout(&msg.msg_namelen, PTRIN(uap->fromlenaddr),
+ sizeof (msg.msg_namelen));
return (error);
}
@@ -1611,14 +1613,14 @@
CP(hdtr32, hdtr, trl_cnt);
if (hdtr.headers != NULL) {
- iov32 = (struct iovec32 *)(uintptr_t)hdtr32.headers;
+ iov32 = PTRIN(hdtr32.headers);
error = freebsd32_copyinuio(iov32,
hdtr32.hdr_cnt, &hdr_uio);
if (error)
goto out;
}
if (hdtr.trailers != NULL) {
- iov32 = (struct iovec32 *)(uintptr_t)hdtr32.trailers;
+ iov32 = PTRIN(hdtr32.trailers);
error = freebsd32_copyinuio(iov32,
hdtr32.trl_cnt, &trl_uio);
if (error)
==== //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#32 (text+ko) ====
@@ -1859,7 +1859,7 @@
aiov.iov_len = dat.maxlen;
msg.msg_flags = 0;
- error = kern_recvit(td, uap->fd, &msg, NULL, UIO_USERSPACE,
+ error = kern_recvit(td, uap->fd, &msg, UIO_USERSPACE,
UIO_SYSSPACE, NULL);
if (error) {
==== //depot/projects/smpng/sys/kern/uipc_syscalls.c#84 (text+ko) ====
@@ -952,11 +952,10 @@
}
int
-kern_recvit(td, s, mp, namelenp, uioseg, fromseg, controlp)
+kern_recvit(td, s, mp, uioseg, fromseg, controlp)
struct thread *td;
int s;
struct msghdr *mp;
- void *namelenp;
enum uio_seg uioseg, fromseg;
struct mbuf **controlp;
{
@@ -1055,15 +1054,6 @@
bcopy(fromsa, mp->msg_name, len);
}
mp->msg_namelen = len;
- if (namelenp &&
- (error = copyout(&len, namelenp, sizeof (socklen_t)))) {
-#ifdef COMPAT_OLDSOCK
- if (mp->msg_flags & MSG_COMPAT)
- error = 0; /* old recvfrom didn't check */
- else
-#endif
- goto out;
- }
}
if (mp->msg_control && controlp == NULL) {
#ifdef COMPAT_OLDSOCK
@@ -1132,9 +1122,19 @@
struct msghdr *mp;
void *namelenp;
{
+ int error;
- return (kern_recvit(td, s, mp, namelenp, UIO_USERSPACE, UIO_USERSPACE,
- NULL));
+ error = kern_recvit(td, s, mp, UIO_USERSPACE, UIO_USERSPACE, NULL);
+ if (error)
+ return (error);
+ if (namelenp) {
+ error = copyout(&mp->msg_namelen, namelenp, sizeof (socklen_t));
+#ifdef COMPAT_OLDSOCK
+ if (mp->msg_flags & MSG_COMPAT)
+ error = 0; /* old recvfrom didn't check */
+#endif
+ }
+ return (error);
}
/*
==== //depot/projects/smpng/sys/sys/syscallsubr.h#43 (text+ko) ====
@@ -126,8 +126,7 @@
char *buf, enum uio_seg bufseg, int count);
int kern_readv(struct thread *td, int fd, struct uio *auio);
int kern_recvit(struct thread *td, int s, struct msghdr *mp,
- void *namelenp, enum uio_seg uioseg, enum uio_seg fromseg,
- struct mbuf **controlp);
+ enum uio_seg uioseg, enum uio_seg fromseg, struct mbuf **controlp);
int kern_rename(struct thread *td, char *from, char *to,
enum uio_seg pathseg);
int kern_rmdir(struct thread *td, char *path, enum uio_seg pathseg);
More information about the p4-projects
mailing list