summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Kempf <stefan@cvs.openbsd.org>2016-01-13 17:05:26 +0000
committerStefan Kempf <stefan@cvs.openbsd.org>2016-01-13 17:05:26 +0000
commit9a43d369da9c7adb042927bfc2031119cae9d1f0 (patch)
tree91a2b41b2ae4c2a5236d7abf2ba7c5f71acf392b
parent3bf9f9bcdd8d2d15f2c5d802803a82a6abc652d2 (diff)
Convert to uiomove(); from Martin Natano, thanks!
ok deraadt@
-rw-r--r--sys/kern/subr_log.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index bfdb370df4a..27dcc512c75 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_log.c,v 1.36 2016/01/07 12:27:07 bluhm Exp $ */
+/* $OpenBSD: subr_log.c,v 1.37 2016/01/13 17:05:25 stefan Exp $ */
/* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */
/*
@@ -180,7 +180,7 @@ int
logread(dev_t dev, struct uio *uio, int flag)
{
struct msgbuf *mbp = msgbufp;
- long l;
+ size_t l;
int s;
int error = 0;
@@ -202,13 +202,14 @@ logread(dev_t dev, struct uio *uio, int flag)
logsoftc.sc_state &= ~LOG_RDWAIT;
while (uio->uio_resid > 0) {
- l = mbp->msg_bufx - mbp->msg_bufr;
- if (l < 0)
+ if (mbp->msg_bufx >= mbp->msg_bufr)
+ l = mbp->msg_bufx - mbp->msg_bufr;
+ else
l = mbp->msg_bufs - mbp->msg_bufr;
- l = min(l, uio->uio_resid);
+ l = ulmin(l, uio->uio_resid);
if (l == 0)
break;
- error = uiomovei(&mbp->msg_bufc[mbp->msg_bufr], (int)l, uio);
+ error = uiomove(&mbp->msg_bufc[mbp->msg_bufr], l, uio);
if (error)
break;
mbp->msg_bufr += l;