Fri Oct 29 15:27:50 2010 UTC ()
minor knf


(pooka)
diff -r1.6 -r1.7 src/sys/rump/librump/rumpkern/rumpcopy.c

cvs diff -r1.6 -r1.7 src/sys/rump/librump/rumpkern/rumpcopy.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/rumpcopy.c 2010/10/27 20:44:49 1.6
+++ src/sys/rump/librump/rumpkern/rumpcopy.c 2010/10/29 15:27:50 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: rumpcopy.c,v 1.6 2010/10/27 20:44:49 pooka Exp $ */ 1/* $NetBSD: rumpcopy.c,v 1.7 2010/10/29 15:27:50 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2009 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,54 +16,56 @@ @@ -16,54 +16,56 @@
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE. 25 * SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: rumpcopy.c,v 1.6 2010/10/27 20:44:49 pooka Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: rumpcopy.c,v 1.7 2010/10/29 15:27:50 pooka Exp $");
30 30
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/lwp.h> 32#include <sys/lwp.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34 34
35#include <rump/rump.h> 35#include <rump/rump.h>
36 36
37#include "rump_private.h" 37#include "rump_private.h"
38 38
39int 39int
40copyin(const void *uaddr, void *kaddr, size_t len) 40copyin(const void *uaddr, void *kaddr, size_t len)
41{ 41{
 42
42 if (__predict_false(uaddr == NULL && len)) { 43 if (__predict_false(uaddr == NULL && len)) {
43 return EFAULT; 44 return EFAULT;
44 } 45 }
45 46
46 if (curproc->p_vmspace == &vmspace0) { 47 if (curproc->p_vmspace == &vmspace0) {
47 memcpy(kaddr, uaddr, len); 48 memcpy(kaddr, uaddr, len);
48 } else { 49 } else {
49 rumpuser_sp_copyin(uaddr, kaddr, len); 50 rumpuser_sp_copyin(uaddr, kaddr, len);
50 } 51 }
51 return 0; 52 return 0;
52} 53}
53 54
54int 55int
55copyout(const void *kaddr, void *uaddr, size_t len) 56copyout(const void *kaddr, void *uaddr, size_t len)
56{ 57{
 58
57 if (__predict_false(uaddr == NULL && len)) { 59 if (__predict_false(uaddr == NULL && len)) {
58 return EFAULT; 60 return EFAULT;
59 } 61 }
60 62
61 if (curproc->p_vmspace == &vmspace0) { 63 if (curproc->p_vmspace == &vmspace0) {
62 memcpy(uaddr, kaddr, len); 64 memcpy(uaddr, kaddr, len);
63 } else { 65 } else {
64 rumpuser_sp_copyout(kaddr, uaddr, len); 66 rumpuser_sp_copyout(kaddr, uaddr, len);
65 } 67 }
66 return 0; 68 return 0;
67} 69}
68 70
69int 71int