Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/include/asm Tweak get_user and put_user.
details: https://anonhg.NetBSD.org/src/rev/1b9ca6b97dc3
branches: trunk
changeset: 1027826:1b9ca6b97dc3
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 00:50:11 2021 +0000
description:
Tweak get_user and put_user.
- Add type check to get_user.
- Use temporary for put_user, since argument might not be lvalue.
- Clarify argument names.
diffstat:
sys/external/bsd/drm2/include/asm/uaccess.h | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diffs (28 lines):
diff -r 112c6f290b83 -r 1b9ca6b97dc3 sys/external/bsd/drm2/include/asm/uaccess.h
--- a/sys/external/bsd/drm2/include/asm/uaccess.h Sun Dec 19 00:50:01 2021 +0000
+++ b/sys/external/bsd/drm2/include/asm/uaccess.h Sun Dec 19 00:50:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uaccess.h,v 1.3 2017/09/10 22:51:48 maya Exp $ */
+/* $NetBSD: uaccess.h,v 1.4 2021/12/19 00:50:11 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -63,11 +63,14 @@
return -copyout(kernel_addr, user_addr, len);
}
-#define get_user(KERNEL_LOC, USER_ADDR) \
- copy_from_user(&(KERNEL_LOC), (USER_ADDR), sizeof(KERNEL_LOC))
+#define get_user(KERNEL_LVAL, USER_PTR) \
+ copy_from_user(&(KERNEL_LVAL), (USER_PTR), sizeof(*(USER_PTR)) + \
+ 0*sizeof(&(KERNEL_LVAL) - (USER_PTR)))
-#define put_user(KERNEL_LOC, USER_ADDR) \
- copy_to_user((USER_ADDR), &(KERNEL_LOC), sizeof(KERNEL_LOC))
+#define put_user(KERNEL_RVAL, USER_PTR) ({ \
+ const typeof(*(USER_PTR)) __put_user_tmp = (KERNEL_RVAL); \
+ copy_to_user((USER_PTR), &__put_user_tmp, sizeof(__put_user_tmp)); \
+})
#if 0
/*
Home |
Main Index |
Thread Index |
Old Index