All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] Real fix for rejected patch uaccess-warning
@ 2006-03-07 19:31 Blaisorblade
  2006-03-09 16:57 ` Jeff Dike
  0 siblings, 1 reply; 6+ messages in thread
From: Blaisorblade @ 2006-03-07 19:31 UTC (permalink / raw)
  To: Jeff Dike; +Cc: user-mode-linux-devel

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

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

[-- Attachment #2: uml-fix-const-warns-gcc-4_1 --]
[-- Type: text/x-diff, Size: 874 bytes --]

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)); \
 })

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-24  1:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-07 19:31 [uml-devel] Real fix for rejected patch uaccess-warning Blaisorblade
2006-03-09 16:57 ` Jeff Dike
2006-03-10 15:22   ` Blaisorblade
2006-03-23 20:58     ` Jeff Dike
2006-03-23 23:52       ` Blaisorblade
2006-03-24  1:54         ` Jeff Dike

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.