About
http://user-mode-linux.sourceforge.net/work/current/2.6/2.6.16-rc4/patches/uaccess-warning

I read the patch which was rejected and noticed that you put there style 
changes to get_user. They should be kept while the rest of the patch thrown 
away, obviously, as discussed, but reading that made me wonder at this 
(changes are just whitespace fixups):

-        const __typeof__(ptr) __private_ptr = ptr; \
-        __typeof__(*(__private_ptr)) __private_val; \
[...]
-       if (__copy_from_user(&__private_val, (__private_ptr), \
-           sizeof(*(__private_ptr))) == 0) {\

Given that __private_ptr is a const pointer, __private_val is a const value, 
where we store something with __copy_from_user.
That's likely why GCC complains.

To fix that, we should remove some excess constness. Try the attached patch (I 
haven't GCC 4.1 installed).

Also, I wonder why all this complicate and extra type-checked calls are 
needed.

The i386 source use typeof only in 1 case, for put_user:
when I put_user((short)b, (unsigned long *) c) I must first cast (i.e. 
zero-extend) b to a long and only after write it to c; writing the 4/8 bytes 
pointed to by &b would be meaningless.

All this IMHO, obviously.
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
Index: linux-2.6.git/include/asm-um/uaccess.h
===================================================================
--- linux-2.6.git.orig/include/asm-um/uaccess.h
+++ linux-2.6.git/include/asm-um/uaccess.h
@@ -42,7 +42,7 @@
 #define __get_user(x, ptr) \
 ({ \
         const __typeof__(ptr) __private_ptr = ptr; \
-        __typeof__(*(__private_ptr)) __private_val; \
+        __typeof__(*(ptr)) __private_val; \
         int __private_ret = -EFAULT; \
         (x) = (__typeof__(*(__private_ptr)))0; \
 	if (__copy_from_user(&__private_val, (__private_ptr), \
@@ -55,7 +55,7 @@
 
 #define get_user(x, ptr) \
 ({ \
-        const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
+        __typeof__((*(ptr))) __user *private_ptr = (ptr); \
         (access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
 	 __get_user(x, private_ptr) : ((x) = 0, -EFAULT)); \
 })

Reply via email to