Style fixes

Submitted by:	bde
This commit is contained in:
Mike Silbersack 2004-02-04 08:14:47 +00:00
parent 4133136ba7
commit 2ccbe4b596
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125420
2 changed files with 28 additions and 34 deletions

View File

@ -485,39 +485,39 @@ copyinstrfrom(const void * __restrict src, void * __restrict dst, size_t len,
}
int
iov_to_uio(struct iovec *iovp, u_int iovcnt, struct uio *auio)
iov_to_uio(struct iovec *iovp, u_int iovcnt, struct uio *uio)
{
int error = 0, i;
struct iovec *iov;
u_int iovlen;
struct iovec *iov = NULL;
int error, i;
/* note: can't use iovlen until iovcnt is validated */
iovlen = iovcnt * sizeof (struct iovec);
if (iovcnt > UIO_MAXIOV) {
error = EINVAL;
goto done;
}
MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
auio->uio_iov = iov;
auio->uio_iovcnt = iovcnt;
auio->uio_segflg = UIO_USERSPACE;
auio->uio_offset = -1;
if ((error = copyin(iovp, iov, iovlen)))
goto done;
auio->uio_resid = 0;
for (i = 0; i < iovcnt; i++) {
if (iov->iov_len > INT_MAX - auio->uio_resid) {
error = EINVAL;
goto done;
}
auio->uio_resid += iov->iov_len;
iov++;
}
/* note: can't use iovlen until iovcnt is validated */
iovlen = iovcnt * sizeof (struct iovec);
if (iovcnt > UIO_MAXIOV) {
error = EINVAL;
goto done;
}
MALLOC(iov, struct iovec *, iovlen, M_IOV, M_WAITOK);
uio->uio_iov = iov;
uio->uio_iovcnt = iovcnt;
uio->uio_segflg = UIO_USERSPACE;
uio->uio_offset = -1;
if ((error = copyin(iovp, iov, iovlen)))
goto done;
uio->uio_resid = 0;
for (i = 0; i < iovcnt; i++) {
if (iov->iov_len > INT_MAX - uio->uio_resid) {
error = EINVAL;
goto done;
}
uio->uio_resid += iov->iov_len;
iov++;
}
done:
if (error && auio->uio_iov) {
FREE(auio->uio_iov, M_IOV);
auio->uio_iov = NULL;
if (error && uio->uio_iov) {
FREE(uio->uio_iov, M_IOV);
uio->uio_iov = NULL;
}
return (error);

View File

@ -1041,22 +1041,17 @@ m_uiotombuf(struct uio *uio, int how, int len)
total = min(uio->uio_resid, len);
else
total = uio->uio_resid;
if (total > MHLEN)
m_final = m_getcl(how, MT_DATA, M_PKTHDR);
else
m_final = m_gethdr(how, MT_DATA);
if (m_final == NULL)
goto nospace;
m_new = m_final;
while (progress < total) {
length = total - progress;
if (length > MCLBYTES)
length = MCLBYTES;
if (m_new == NULL) {
if (length > MLEN)
m_new = m_getcl(how, MT_DATA, 0);
@ -1065,7 +1060,6 @@ m_uiotombuf(struct uio *uio, int how, int len)
if (m_new == NULL)
goto nospace;
}
error = uiomove(mtod(m_new, void *), length, uio);
if (error)
goto nospace;