aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2007-12-26 04:37:16 -0500
committerPaul Mundt <lethal@linux-sh.org>2008-01-27 23:19:02 -0500
commit0465b9fb5f6b57f00a6f5bf2169e30e8f3c7d66c (patch)
tree08b10ec77f301aa8e15d1a033f526b212e2f911f
parent31a49c4bf8f964b7a9897baa889916d71b51d9c1 (diff)
sh: Fix get_user()/put_user() build error.
Fixes the build error caused by -Werror on gcc 3.x compilers: arch/sh/kernel/signal_32.c: In function `sys_sigaction': arch/sh/kernel/signal_32.c:66: warning: initialization discards qualifiers from pointer target type arch/sh/kernel/signal_32.c:67: warning: initialization discards qualifiers from pointer target type arch/sh/kernel/signal_32.c:69: warning: initialization discards qualifiers from pointer target type arch/sh/kernel/signal_32.c:70: warning: initialization discards qualifiers from pointer target type The mismatch in question was introduced by commit-id 9c5a4eec79b3eb8876d2e7fddfa1e040a7650e55. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--include/asm-sh/uaccess_32.h64
1 files changed, 28 insertions, 36 deletions
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h
index 59a9f20c2dc..b6082f3c1dc 100644
--- a/include/asm-sh/uaccess_32.h
+++ b/include/asm-sh/uaccess_32.h
@@ -95,11 +95,9 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
95} 95}
96#endif /* CONFIG_MMU */ 96#endif /* CONFIG_MMU */
97 97
98static inline int access_ok(int type, const void __user *p, unsigned long size) 98#define access_ok(type, addr, size) \
99{ 99 (__chk_user_ptr(addr), \
100 unsigned long addr = (unsigned long)p; 100 __access_ok((unsigned long __force)(addr), (size)))
101 return __access_ok(addr, size);
102}
103 101
104/* 102/*
105 * Uh, these should become the main single-value transfer routines ... 103 * Uh, these should become the main single-value transfer routines ...
@@ -113,18 +111,16 @@ static inline int access_ok(int type, const void __user *p, unsigned long size)
113 * (a) re-use the arguments for side effects (sizeof is ok) 111 * (a) re-use the arguments for side effects (sizeof is ok)
114 * (b) require any knowledge of processes at this stage 112 * (b) require any knowledge of processes at this stage
115 */ 113 */
116#define put_user(x,ptr) __put_user_check((x),(ptr),sizeof(*(ptr))) 114#define put_user(x,ptr) __put_user_check((x), (ptr), sizeof(*(ptr)))
117#define get_user(x,ptr) __get_user_check((x),(ptr),sizeof(*(ptr))) 115#define get_user(x,ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))
118 116
119/* 117/*
120 * The "__xxx" versions do not do address space checking, useful when 118 * The "__xxx" versions do not do address space checking, useful when
121 * doing multiple accesses to the same area (the user has to do the 119 * doing multiple accesses to the same area (the user has to do the
122 * checks by hand with "access_ok()") 120 * checks by hand with "access_ok()")
123 */ 121 */
124#define __put_user(x,ptr) \ 122#define __put_user(x,ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
125 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr))) 123#define __get_user(x,ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
126#define __get_user(x,ptr) \
127 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
128 124
129struct __large_struct { unsigned long buf[100]; }; 125struct __large_struct { unsigned long buf[100]; };
130#define __m(x) (*(struct __large_struct __user *)(x)) 126#define __m(x) (*(struct __large_struct __user *)(x))
@@ -132,7 +128,6 @@ struct __large_struct { unsigned long buf[100]; };
132#define __get_user_size(x,ptr,size,retval) \ 128#define __get_user_size(x,ptr,size,retval) \
133do { \ 129do { \
134 retval = 0; \ 130 retval = 0; \
135 __chk_user_ptr(ptr); \
136 switch (size) { \ 131 switch (size) { \
137 case 1: \ 132 case 1: \
138 __get_user_asm(x, ptr, retval, "b"); \ 133 __get_user_asm(x, ptr, retval, "b"); \
@@ -151,24 +146,22 @@ do { \
151 146
152#define __get_user_nocheck(x,ptr,size) \ 147#define __get_user_nocheck(x,ptr,size) \
153({ \ 148({ \
154 long __gu_err, __gu_val; \ 149 long __gu_err; \
155 __typeof__(*(ptr)) *__pu_addr = (ptr); \ 150 unsigned long __gu_val; \
156 __get_user_size(__gu_val, (__pu_addr), (size), __gu_err); \ 151 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
152 __chk_user_ptr(ptr); \
153 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
157 (x) = (__typeof__(*(ptr)))__gu_val; \ 154 (x) = (__typeof__(*(ptr)))__gu_val; \
158 __gu_err; \ 155 __gu_err; \
159}) 156})
160 157
161#define __get_user_check(x,ptr,size) \ 158#define __get_user_check(x,ptr,size) \
162({ \ 159({ \
163 long __gu_err, __gu_val; \ 160 long __gu_err = -EFAULT; \
164 __typeof__(*(ptr)) *__pu_addr = (ptr); \ 161 unsigned long __gu_val = 0; \
165 __chk_user_ptr(__pu_addr); \ 162 const __typeof__(*(ptr)) *__gu_addr = (ptr); \
166 if (likely(__addr_ok((unsigned long)(__pu_addr)))) { \ 163 if (likely(access_ok(VERIFY_READ, __gu_addr, (size)))) \
167 __get_user_size(__gu_val, (__pu_addr), (size), __gu_err);\ 164 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
168 } else { \
169 __gu_err = -EFAULT; \
170 __gu_val = 0; \
171 } \
172 (x) = (__typeof__(*(ptr)))__gu_val; \ 165 (x) = (__typeof__(*(ptr)))__gu_val; \
173 __gu_err; \ 166 __gu_err; \
174}) 167})
@@ -199,7 +192,6 @@ extern void __get_user_unknown(void);
199#define __put_user_size(x,ptr,size,retval) \ 192#define __put_user_size(x,ptr,size,retval) \
200do { \ 193do { \
201 retval = 0; \ 194 retval = 0; \
202 __chk_user_ptr(ptr); \
203 switch (size) { \ 195 switch (size) { \
204 case 1: \ 196 case 1: \
205 __put_user_asm(x, ptr, retval, "b"); \ 197 __put_user_asm(x, ptr, retval, "b"); \
@@ -218,22 +210,22 @@ do { \
218 } \ 210 } \
219} while (0) 211} while (0)
220 212
221#define __put_user_nocheck(x,ptr,size) \ 213#define __put_user_nocheck(x,ptr,size) \
222({ \ 214({ \
223 long __pu_err; \ 215 long __pu_err; \
224 __put_user_size((x),(ptr),(size),__pu_err); \ 216 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
225 __pu_err; \ 217 __chk_user_ptr(ptr); \
218 __put_user_size((x), __pu_addr, (size), __pu_err); \
219 __pu_err; \
226}) 220})
227 221
228#define __put_user_check(x,ptr,size) \ 222#define __put_user_check(x,ptr,size) \
229({ \ 223({ \
230 long __pu_err; \ 224 long __pu_err = -EFAULT; \
231 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 225 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
232 \ 226 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \
233 if (likely(__addr_ok((unsigned long)__pu_addr))) \ 227 __put_user_size((x), __pu_addr, (size), \
234 __put_user_size((x),__pu_addr,(size),__pu_err); \ 228 __pu_err); \
235 else \
236 __pu_err = -EFAULT; \
237 __pu_err; \ 229 __pu_err; \
238}) 230})
239 231