summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-02-10 21:56:11 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-02-10 21:56:11 +0000
commitfb06ed88b5810f53d16a2f3f90904ed7ea4de07a (patch)
tree0ad268ca945306e22e87692f6bb02fcd1220d0e4 /sys/kern
parent4ed4205fc6bdb404dcf67f9f19347eea957f5982 (diff)
First step towards making uiomove() take a size_t size argument:
- rename uiomove() to uiomovei() and update all its users. - introduce uiomove(), which is similar to uiomovei() but with a size_t. - rewrite uiomovei() as an uiomove() wrapper. ok kettenis@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_subr.c13
-rw-r--r--sys/kern/spec_vnops.c6
-rw-r--r--sys/kern/subr_log.c4
-rw-r--r--sys/kern/sys_pipe.c8
-rw-r--r--sys/kern/tty.c4
-rw-r--r--sys/kern/tty_pty.c10
-rw-r--r--sys/kern/uipc_socket.c8
7 files changed, 31 insertions, 22 deletions
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c
index 3c4e44f2b14..71ec338632c 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_subr.c,v 1.42 2014/12/10 15:29:53 mikeb Exp $ */
+/* $OpenBSD: kern_subr.c,v 1.43 2015/02/10 21:56:09 miod Exp $ */
/* $NetBSD: kern_subr.c,v 1.15 1996/04/09 17:21:56 ragge Exp $ */
/*
@@ -47,7 +47,7 @@
#include <sys/resourcevar.h>
int
-uiomove(void *cp, int n, struct uio *uio)
+uiomove(void *cp, size_t n, struct uio *uio)
{
struct iovec *iov;
size_t cnt;
@@ -104,6 +104,15 @@ uiomove(void *cp, int n, struct uio *uio)
return (error);
}
+int
+uiomovei(void *cp, int n, struct uio *uio)
+{
+ if (n < 0)
+ return 0;
+
+ return uiomove(cp, (size_t)n, uio);
+}
+
/*
* Give next character to user as result of read.
*/
diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c
index 0b9106dd7fc..6f161465f1d 100644
--- a/sys/kern/spec_vnops.c
+++ b/sys/kern/spec_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: spec_vnops.c,v 1.82 2014/12/29 05:29:27 miod Exp $ */
+/* $OpenBSD: spec_vnops.c,v 1.83 2015/02/10 21:56:09 miod Exp $ */
/* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */
/*
@@ -256,7 +256,7 @@ spec_read(void *v)
brelse(bp);
return (error);
}
- error = uiomove((char *)bp->b_data + on, n, uio);
+ error = uiomovei((char *)bp->b_data + on, n, uio);
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
return (error);
@@ -338,7 +338,7 @@ spec_write(void *v)
brelse(bp);
return (error);
}
- error = uiomove((char *)bp->b_data + on, n, uio);
+ error = uiomovei((char *)bp->b_data + on, n, uio);
if (n + on == bsize)
bawrite(bp);
else
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index 8a4746fd93a..dbae2898ac7 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_log.c,v 1.27 2015/01/13 18:51:27 kettenis Exp $ */
+/* $OpenBSD: subr_log.c,v 1.28 2015/02/10 21:56:09 miod Exp $ */
/* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */
/*
@@ -207,7 +207,7 @@ logread(dev_t dev, struct uio *uio, int flag)
l = min(l, uio->uio_resid);
if (l == 0)
break;
- error = uiomove(&mbp->msg_bufc[mbp->msg_bufr], (int)l, uio);
+ error = uiomovei(&mbp->msg_bufc[mbp->msg_bufr], (int)l, uio);
if (error)
break;
mbp->msg_bufr += l;
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 0f505c2cb2d..5947ed501b5 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.68 2014/12/19 05:59:21 tedu Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.69 2015/02/10 21:56:10 miod Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -317,7 +317,7 @@ pipe_read(struct file *fp, off_t *poff, struct uio *uio, struct ucred *cred)
size = rpipe->pipe_buffer.cnt;
if (size > uio->uio_resid)
size = uio->uio_resid;
- error = uiomove(&rpipe->pipe_buffer.buffer[rpipe->pipe_buffer.out],
+ error = uiomovei(&rpipe->pipe_buffer.buffer[rpipe->pipe_buffer.out],
size, uio);
if (error) {
break;
@@ -516,7 +516,7 @@ retrywrite:
/* Transfer first segment */
- error = uiomove(&wpipe->pipe_buffer.buffer[wpipe->pipe_buffer.in],
+ error = uiomovei(&wpipe->pipe_buffer.buffer[wpipe->pipe_buffer.in],
segsize, uio);
if (error == 0 && segsize < size) {
@@ -531,7 +531,7 @@ retrywrite:
panic("Expected pipe buffer wraparound disappeared");
#endif
- error = uiomove(&wpipe->pipe_buffer.buffer[0],
+ error = uiomovei(&wpipe->pipe_buffer.buffer[0],
size - segsize, uio);
}
if (error == 0) {
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 419f6e65d90..c0ec4f0e259 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.120 2015/01/13 10:07:58 mpf Exp $ */
+/* $OpenBSD: tty.c,v 1.121 2015/02/10 21:56:10 miod Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -1781,7 +1781,7 @@ loop:
if (cc == 0) {
cc = MIN(uio->uio_resid, OBUFSIZ);
cp = obuf;
- error = uiomove(cp, cc, uio);
+ error = uiomovei(cp, cc, uio);
if (error) {
cc = 0;
break;
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 2c64ccf885c..d54d455bc79 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_pty.c,v 1.69 2014/11/18 23:55:01 krw Exp $ */
+/* $OpenBSD: tty_pty.c,v 1.70 2015/02/10 21:56:10 miod Exp $ */
/* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */
/*
@@ -463,7 +463,7 @@ ptcread(dev_t dev, struct uio *uio, int flag)
if (pti->pt_send & TIOCPKT_IOCTL) {
cc = MIN(uio->uio_resid,
sizeof(tp->t_termios));
- error = uiomove(&tp->t_termios, cc, uio);
+ error = uiomovei(&tp->t_termios, cc, uio);
if (error)
return (error);
}
@@ -498,7 +498,7 @@ ptcread(dev_t dev, struct uio *uio, int flag)
bufcc = cc;
if (cc <= 0)
break;
- error = uiomove(buf, cc, uio);
+ error = uiomovei(buf, cc, uio);
}
ttwakeupwr(tp);
if (bufcc)
@@ -531,7 +531,7 @@ again:
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomove(cp, cc, uio);
+ error = uiomovei(cp, cc, uio);
if (error)
goto done;
/* check again for safety */
@@ -555,7 +555,7 @@ again:
if (cc > bufcc)
bufcc = cc;
cp = buf;
- error = uiomove(cp, cc, uio);
+ error = uiomovei(cp, cc, uio);
if (error)
goto done;
/* check again for safety */
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 17149a97281..e7a1f94addb 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket.c,v 1.135 2014/12/11 19:21:57 tedu Exp $ */
+/* $OpenBSD: uipc_socket.c,v 1.136 2015/02/10 21:56:10 miod Exp $ */
/* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */
/*
@@ -514,7 +514,7 @@ nopages:
if (atomic && top == 0 && len < mlen)
MH_ALIGN(m, len);
}
- error = uiomove(mtod(m, caddr_t), (int)len,
+ error = uiomovei(mtod(m, caddr_t), (int)len,
uio);
resid = uio->uio_resid;
m->m_len = len;
@@ -640,7 +640,7 @@ soreceive(struct socket *so, struct mbuf **paddr, struct uio *uio,
if (error)
goto bad;
do {
- error = uiomove(mtod(m, caddr_t),
+ error = uiomovei(mtod(m, caddr_t),
(int) min(uio->uio_resid, m->m_len), uio);
m = m_free(m);
} while (uio->uio_resid && error == 0 && m);
@@ -852,7 +852,7 @@ dontblock:
SBLASTMBUFCHK(&so->so_rcv, "soreceive uiomove");
resid = uio->uio_resid;
splx(s);
- uio_error = uiomove(mtod(m, caddr_t) + moff, len, uio);
+ uio_error = uiomovei(mtod(m, caddr_t) + moff, len, uio);
s = splsoftnet();
if (uio_error)
uio->uio_resid = resid - len;