Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add prototype for uiomove_frombuf. Change uiomove_fromb...



details:   https://anonhg.NetBSD.org/src/rev/0807485a455e
branches:  trunk
changeset: 565846:0807485a455e
user:      matt <matt%NetBSD.org@localhost>
date:      Wed Apr 21 20:31:50 2004 +0000

description:
Add prototype for uiomove_frombuf.  Change uiomove_frombuf to use size_t
for its length argument (to be the same as uiomove).  Remove code that
dealt with length being negative.

diffstat:

 sys/kern/kern_subr.c |  19 +++++++------------
 sys/sys/systm.h      |   3 ++-
 2 files changed, 9 insertions(+), 13 deletions(-)

diffs (65 lines):

diff -r 74093c1d2824 -r 0807485a455e sys/kern/kern_subr.c
--- a/sys/kern/kern_subr.c      Wed Apr 21 20:10:10 2004 +0000
+++ b/sys/kern/kern_subr.c      Wed Apr 21 20:31:50 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_subr.c,v 1.110 2004/04/21 18:40:38 itojun Exp $   */
+/*     $NetBSD: kern_subr.c,v 1.111 2004/04/21 20:31:50 matt Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.110 2004/04/21 18:40:38 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_subr.c,v 1.111 2004/04/21 20:31:50 matt Exp $");
 
 #include "opt_ddb.h"
 #include "opt_md.h"
@@ -207,24 +207,19 @@
 
 /*
  * Wrapper for uiomove() that validates the arguments against a known-good
- * kernel buffer.  Currently, uiomove accepts a signed (n) argument, which
- * is almost definitely a bad thing, so we catch that here as well.  We
- * return a runtime failure, but it might be desirable to generate a runtime
- * assertion failure instead.
+ * kernel buffer.
  */
 int
-uiomove_frombuf(void *buf, int buflen, struct uio *uio)
+uiomove_frombuf(void *buf, size_t buflen, struct uio *uio)
 {
-       unsigned int offset, n;
+       size_t offset;
 
        if (uio->uio_offset < 0 || uio->uio_resid < 0 ||
            (offset = uio->uio_offset) != uio->uio_offset)
                return (EINVAL);
-       if (buflen <= 0 || offset >= buflen)
+       if (offset >= buflen)
                return (0);
-       if ((n = buflen - offset) > INT_MAX)
-               return (EINVAL);
-       return (uiomove((char *)buf + offset, n, uio));
+       return (uiomove((char *)buf + offset, buflen - offset, uio));
 }
 
 /*
diff -r 74093c1d2824 -r 0807485a455e sys/sys/systm.h
--- a/sys/sys/systm.h   Wed Apr 21 20:10:10 2004 +0000
+++ b/sys/sys/systm.h   Wed Apr 21 20:31:50 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: systm.h,v 1.170 2004/01/23 05:01:19 simonb Exp $       */
+/*     $NetBSD: systm.h,v 1.171 2004/04/21 20:31:50 matt Exp $ */
 
 /*-
  * Copyright (c) 1982, 1988, 1991, 1993
@@ -344,6 +344,7 @@
 void   trace_exit __P((struct lwp *, register_t, void *, register_t [], int));
 
 int    uiomove __P((void *, size_t, struct uio *));
+int    uiomove_frombuf __P((void *, size_t, struct uio *));
 
 #ifdef _KERNEL
 int    setjmp  __P((label_t *));



Home | Main Index | Thread Index | Old Index